xapi-project / xen-api

The Xapi Project's XenAPI Server
http://xenproject.org/developers/teams/xapi.html
Other
342 stars 282 forks source link

CA-390277: Reduce record usage on CLI cross-pool migrations #5773

Open psafont opened 5 days ago

psafont commented 5 days ago

Using records in cross-pool migration code is dangerous, as the code interacts with potentially newer hosts. This means that fields in the record might be different from what's expected. In particular, adding an enum field can break the deserialization, and removing a field as well.

Instead, introduce and use a new call get_all_where: this calls allows the host to return a filtered list of object references.

With these changes, only SR records are used. This is done to minimize the number of calls done.

psafont commented 5 days ago

I've verified manually that it works with and without remote-host, and with and without a remote-network, especially using the name label. For the network, the bridge parameter is strange since it needs the reference, not its name (e.g. xenbr0).

# xe vm-migrate live=true remote-username=root remote-password=xxx \
   remote-master=uk-14-05.internal host=uk-14-05 \
   remote-network="Pool-wide network associated with eth0" \
   vm=a8d49c18-69af-fbd4-b4ab-51916073ef15 \
   vif:78502fd1-9b80-cad7-6eb3-cbea04bd1eee=296f1a07-bfc7-8038-7108-f8ddb9cbd322
Performing a storage live migration. Your VM's VDIs will be migrated with the VM.
Will migrate to remote host: uk-14-05, using remote network: Pool-wide network associated with eth0. Here is the VDI mapping:
VDI 807f74a0-be10-48e7-b992-df423e6ff71a -> SR bb7073ab-1e0d-40be-72c8-4653539ce2e7
coveralls commented 4 days ago

Coverage Status

coverage: 44.887%. remained the same when pulling 62dd88d8f44c981311b4aec420ac1f2fc76041e2 on psafont:getallwhere into e61e0acc3d04653ce203db316769c66377897869 on xapi-project:master.

Vincent-lau commented 4 days ago

Looks good to me, as long as the use of SR record is ok....