14
15
* Lesser General Public License for more details.
16
17
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
* License along with this library. If not, see
19
* <http://www.gnu.org/licenses/>.
77
79
VIR_ENUM_DECL(qemuMigrationCookieFlag);
78
80
VIR_ENUM_IMPL(qemuMigrationCookieFlag,
79
81
QEMU_MIGRATION_COOKIE_FLAG_LAST,
80
"graphics", "lockstate", "persistent");
82
"graphics", "lockstate", "persistent", "network");
82
84
enum qemuMigrationCookieFeatures {
83
85
QEMU_MIGRATION_COOKIE_GRAPHICS = (1 << QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
84
86
QEMU_MIGRATION_COOKIE_LOCKSTATE = (1 << QEMU_MIGRATION_COOKIE_FLAG_LOCKSTATE),
85
87
QEMU_MIGRATION_COOKIE_PERSISTENT = (1 << QEMU_MIGRATION_COOKIE_FLAG_PERSISTENT),
88
QEMU_MIGRATION_COOKIE_NETWORK = (1 << QEMU_MIGRATION_COOKIE_FLAG_NETWORK),
88
91
typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
101
typedef struct _qemuMigrationCookieNetData qemuMigrationCookieNetData;
102
typedef qemuMigrationCookieNetData *qemuMigrationCookieNetDataPtr;
103
struct _qemuMigrationCookieNetData {
104
int vporttype; /* enum virNetDevVPortProfile */
107
* Array of pointers to saved data. Each VIF will have it's own
113
typedef struct _qemuMigrationCookieNetwork qemuMigrationCookieNetwork;
114
typedef qemuMigrationCookieNetwork *qemuMigrationCookieNetworkPtr;
115
struct _qemuMigrationCookieNetwork {
116
/* How many virtual NICs are we saving data for? */
119
qemuMigrationCookieNetDataPtr net;
98
122
typedef struct _qemuMigrationCookie qemuMigrationCookie;
99
123
typedef qemuMigrationCookie *qemuMigrationCookiePtr;
100
124
struct _qemuMigrationCookie {
166
213
if (virFileReadAll(certfile, 8192, &pemdata) < 0) {
167
qemuReportError(VIR_ERR_INTERNAL_ERROR,
168
_("unable to read server cert %s"), certfile);
214
virReportError(VIR_ERR_INTERNAL_ERROR,
215
_("unable to read server cert %s"), certfile);
172
219
ret = gnutls_x509_crt_init(&cert);
174
qemuReportError(VIR_ERR_INTERNAL_ERROR,
175
_("cannot initialize cert object: %s"),
176
gnutls_strerror(ret));
221
virReportError(VIR_ERR_INTERNAL_ERROR,
222
_("cannot initialize cert object: %s"),
223
gnutls_strerror(ret));
183
230
ret = gnutls_x509_crt_import(cert, &pemdatum, GNUTLS_X509_FMT_PEM);
185
qemuReportError(VIR_ERR_INTERNAL_ERROR,
186
_("cannot load cert data from %s: %s"),
187
certfile, gnutls_strerror(ret));
232
virReportError(VIR_ERR_INTERNAL_ERROR,
233
_("cannot load cert data from %s: %s"),
234
certfile, gnutls_strerror(ret));
306
static qemuMigrationCookieNetworkPtr
307
qemuMigrationCookieNetworkAlloc(struct qemud_driver *driver ATTRIBUTE_UNUSED,
310
qemuMigrationCookieNetworkPtr mig;
313
if (VIR_ALLOC(mig) < 0)
316
mig->nnets = def->nnets;
318
if (VIR_ALLOC_N(mig->net, def->nnets) <0)
321
for (i = 0; i < def->nnets; i++) {
322
virDomainNetDefPtr netptr;
323
virNetDevVPortProfilePtr vport;
325
netptr = def->nets[i];
326
vport = virDomainNetGetActualVirtPortProfile(netptr);
329
mig->net[i].vporttype = vport->virtPortType;
331
switch (vport->virtPortType) {
332
case VIR_NETDEV_VPORT_PROFILE_NONE:
333
case VIR_NETDEV_VPORT_PROFILE_8021QBG:
334
case VIR_NETDEV_VPORT_PROFILE_8021QBH:
336
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
337
if (virNetDevOpenvswitchGetMigrateData(&mig->net[i].portdata,
338
netptr->ifname) != 0) {
339
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
340
_("Unable to run command to get OVS port data for "
341
"interface %s"), netptr->ifname);
355
qemuMigrationCookieNetworkFree(mig);
259
359
static qemuMigrationCookiePtr
260
360
qemuMigrationCookieNew(virDomainObjPtr dom)
277
377
if (!(mig->localHostname = virGetHostname(NULL)))
279
379
if (virGetHostUUID(mig->localHostuuid) < 0) {
280
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
281
_("Unable to obtain host UUID"));
380
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
381
_("Unable to obtain host UUID"));
324
424
qemuDomainObjPrivatePtr priv = dom->privateData;
326
426
if (mig->flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) {
327
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
328
_("Migration lockstate data already present"));
427
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
428
_("Migration lockstate data already present"));
474
qemuMigrationCookieAddNetwork(qemuMigrationCookiePtr mig,
475
struct qemud_driver *driver,
478
if (mig->flags & QEMU_MIGRATION_COOKIE_NETWORK) {
479
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
480
_("Network migration data already present"));
484
if (dom->def->nnets > 0) {
485
mig->network = qemuMigrationCookieNetworkAlloc(driver, dom->def);
488
mig->flags |= QEMU_MIGRATION_COOKIE_NETWORK;
374
495
static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf,
375
496
qemuMigrationCookieGraphicsPtr grap)
514
qemuMigrationCookieNetworkXMLFormat(virBufferPtr buf,
515
qemuMigrationCookieNetworkPtr optr)
520
for (i = 0; i < optr->nnets; i++) {
521
/* If optr->net[i].vporttype is not set, there is nothing to transfer */
522
if (optr->net[i].vporttype != VIR_NETDEV_VPORT_PROFILE_NONE) {
524
virBufferAsprintf(buf, " <network>\n");
527
virBufferAsprintf(buf, " <interface index='%d' vporttype='%s'",
528
i, virNetDevVPortTypeToString(optr->net[i].vporttype));
529
if (optr->net[i].portdata) {
530
virBufferAddLit(buf, ">\n");
531
virBufferEscapeString(buf, " <portdata>%s</portdata>\n",
532
optr->net[i].portdata);
533
virBufferAddLit(buf, " </interface>\n");
535
virBufferAddLit(buf, "/>\n");
540
virBufferAddLit(buf, " </network>\n");
393
545
qemuMigrationCookieXMLFormat(struct qemud_driver *driver,
394
546
virBufferPtr buf,
432
584
if (qemuDomainDefFormatBuf(driver,
434
586
VIR_DOMAIN_XML_INACTIVE |
435
VIR_DOMAIN_XML_SECURE,
587
VIR_DOMAIN_XML_SECURE |
588
VIR_DOMAIN_XML_MIGRATABLE,
439
591
virBufferAdjustIndent(buf, -2);
594
if ((mig->flags & QEMU_MIGRATION_COOKIE_NETWORK) && mig->network)
595
qemuMigrationCookieNetworkXMLFormat(buf, mig->network);
442
597
virBufferAddLit(buf, "</qemu-migration>\n");
476
631
if (!(tmp = virXPathString("string(./graphics/@type)", ctxt))) {
477
qemuReportError(VIR_ERR_INTERNAL_ERROR,
478
"%s", _("missing type attribute in migration data"));
632
virReportError(VIR_ERR_INTERNAL_ERROR,
633
"%s", _("missing type attribute in migration data"));
481
636
if ((grap->type = virDomainGraphicsTypeFromString(tmp)) < 0) {
482
qemuReportError(VIR_ERR_INTERNAL_ERROR,
483
_("unknown graphics type %s"), tmp);
637
virReportError(VIR_ERR_INTERNAL_ERROR,
638
_("unknown graphics type %s"), tmp);
488
643
if (virXPathInt("string(./graphics/@port)", ctxt, &grap->port) < 0) {
489
qemuReportError(VIR_ERR_INTERNAL_ERROR,
490
"%s", _("missing port attribute in migration data"));
644
virReportError(VIR_ERR_INTERNAL_ERROR,
645
"%s", _("missing port attribute in migration data"));
493
648
if (grap->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
494
649
if (virXPathInt("string(./graphics/@tlsPort)", ctxt, &grap->tlsPort) < 0) {
495
qemuReportError(VIR_ERR_INTERNAL_ERROR,
496
"%s", _("missing tlsPort attribute in migration data"));
650
virReportError(VIR_ERR_INTERNAL_ERROR,
651
"%s", _("missing tlsPort attribute in migration data"));
500
655
if (!(grap->listen = virXPathString("string(./graphics/@listen)", ctxt))) {
501
qemuReportError(VIR_ERR_INTERNAL_ERROR,
502
"%s", _("missing listen attribute in migration data"));
656
virReportError(VIR_ERR_INTERNAL_ERROR,
657
"%s", _("missing listen attribute in migration data"));
674
static qemuMigrationCookieNetworkPtr
675
qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
677
qemuMigrationCookieNetworkPtr optr;
680
xmlNodePtr *interfaces = NULL;
682
xmlNodePtr save_ctxt = ctxt->node;
684
if (VIR_ALLOC(optr) < 0)
687
if ((n = virXPathNodeSet("./network/interface", ctxt, &interfaces)) < 0) {
688
virReportError(VIR_ERR_INTERNAL_ERROR,
689
"%s", _("missing interface information"));
694
if (VIR_ALLOC_N(optr->net, optr->nnets) <0)
697
for (i = 0; i < n; i++) {
698
/* portdata is optional, and may not exist */
699
ctxt->node = interfaces[i];
700
optr->net[i].portdata = virXPathString("string(./portdata[1])", ctxt);
702
if (!(vporttype = virXMLPropString(interfaces[i], "vporttype"))) {
703
virReportError(VIR_ERR_INTERNAL_ERROR,
704
"%s", _("missing vporttype attribute in migration data"));
707
optr->net[i].vporttype = virNetDevVPortTypeFromString(vporttype);
710
VIR_FREE(interfaces);
713
ctxt->node = save_ctxt;
719
VIR_FREE(interfaces);
720
qemuMigrationCookieNetworkFree(optr);
520
727
qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
521
728
struct qemud_driver *driver,
536
743
/* Extract domain name */
537
744
if (!(tmp = virXPathString("string(./name[1])", ctxt))) {
538
qemuReportError(VIR_ERR_INTERNAL_ERROR,
539
"%s", _("missing name element in migration data"));
745
virReportError(VIR_ERR_INTERNAL_ERROR,
746
"%s", _("missing name element in migration data"));
542
749
if (STRNEQ(tmp, mig->name)) {
543
qemuReportError(VIR_ERR_INTERNAL_ERROR,
544
_("Incoming cookie data had unexpected name %s vs %s"),
750
virReportError(VIR_ERR_INTERNAL_ERROR,
751
_("Incoming cookie data had unexpected name %s vs %s"),
550
757
/* Extract domain uuid */
551
758
tmp = virXPathString("string(./uuid[1])", ctxt);
553
qemuReportError(VIR_ERR_INTERNAL_ERROR,
554
"%s", _("missing uuid element in migration data"));
760
virReportError(VIR_ERR_INTERNAL_ERROR,
761
"%s", _("missing uuid element in migration data"));
557
764
virUUIDFormat(mig->uuid, uuidstr);
558
765
if (STRNEQ(tmp, uuidstr)) {
559
qemuReportError(VIR_ERR_INTERNAL_ERROR,
560
_("Incoming cookie data had unexpected UUID %s vs %s"),
766
virReportError(VIR_ERR_INTERNAL_ERROR,
767
_("Incoming cookie data had unexpected UUID %s vs %s"),
565
772
/* Check & forbid "localhost" migration */
566
773
if (!(mig->remoteHostname = virXPathString("string(./hostname[1])", ctxt))) {
567
qemuReportError(VIR_ERR_INTERNAL_ERROR,
568
"%s", _("missing hostname element in migration data"));
774
virReportError(VIR_ERR_INTERNAL_ERROR,
775
"%s", _("missing hostname element in migration data"));
571
778
if (STREQ(mig->remoteHostname, mig->localHostname)) {
572
qemuReportError(VIR_ERR_INTERNAL_ERROR,
573
_("Attempt to migrate guest to the same host %s"),
574
mig->remoteHostname);
779
virReportError(VIR_ERR_INTERNAL_ERROR,
780
_("Attempt to migrate guest to the same host %s"),
781
mig->remoteHostname);
578
785
if (!(tmp = virXPathString("string(./hostuuid[1])", ctxt))) {
579
qemuReportError(VIR_ERR_INTERNAL_ERROR,
580
"%s", _("missing hostuuid element in migration data"));
786
virReportError(VIR_ERR_INTERNAL_ERROR,
787
"%s", _("missing hostuuid element in migration data"));
583
790
if (virUUIDParse(tmp, mig->remoteHostuuid) < 0) {
584
qemuReportError(VIR_ERR_INTERNAL_ERROR,
585
"%s", _("malformed hostuuid element in migration data"));
791
virReportError(VIR_ERR_INTERNAL_ERROR,
792
"%s", _("malformed hostuuid element in migration data"));
588
795
if (memcmp(mig->remoteHostuuid, mig->localHostuuid, VIR_UUID_BUFLEN) == 0) {
589
qemuReportError(VIR_ERR_INTERNAL_ERROR,
590
_("Attempt to migrate guest to the same host %s"),
796
virReportError(VIR_ERR_INTERNAL_ERROR,
797
_("Attempt to migrate guest to the same host %s"),
603
810
char *str = virXMLPropString(nodes[i], "name");
605
qemuReportError(VIR_ERR_INTERNAL_ERROR,
606
"%s", _("missing feature name"));
812
virReportError(VIR_ERR_INTERNAL_ERROR,
813
"%s", _("missing feature name"));
610
817
if ((val = qemuMigrationCookieFlagTypeFromString(str)) < 0) {
611
qemuReportError(VIR_ERR_INTERNAL_ERROR,
612
_("Unknown migration cookie feature %s"),
818
virReportError(VIR_ERR_INTERNAL_ERROR,
819
_("Unknown migration cookie feature %s"),
618
825
if ((flags & (1 << val)) == 0) {
619
qemuReportError(VIR_ERR_INTERNAL_ERROR,
620
_("Unsupported migration cookie feature %s"),
826
virReportError(VIR_ERR_INTERNAL_ERROR,
827
_("Unsupported migration cookie feature %s"),
634
841
virXPathBoolean("count(./lockstate) > 0", ctxt)) {
635
842
mig->lockDriver = virXPathString("string(./lockstate[1]/@driver)", ctxt);
636
843
if (!mig->lockDriver) {
637
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
638
_("Missing lock driver name in migration cookie"));
844
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
845
_("Missing lock driver name in migration cookie"));
641
848
mig->lockState = virXPathString("string(./lockstate[1]/leases[1])", ctxt);
646
853
if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) &&
647
854
virXPathBoolean("count(./domain) > 0", ctxt)) {
648
855
if ((n = virXPathNodeSet("./domain", ctxt, &nodes)) > 1) {
649
qemuReportError(VIR_ERR_INTERNAL_ERROR,
650
_("Too many domain elements in "
651
"migration cookie: %d"),
856
virReportError(VIR_ERR_INTERNAL_ERROR,
857
_("Too many domain elements in "
858
"migration cookie: %d"),
655
862
mig->persistent = virDomainDefParseNode(driver->caps, doc, nodes[0],
744
961
/* Parse & validate incoming cookie (if any) */
745
962
if (cookiein && cookieinlen &&
746
963
cookiein[cookieinlen-1] != '\0') {
747
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
748
_("Migration cookie was not NULL terminated"));
964
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
965
_("Migration cookie was not NULL terminated"));
764
981
if (mig->flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) {
765
982
if (!mig->lockDriver) {
766
983
if (virLockManagerPluginUsesState(driver->lockManager)) {
767
qemuReportError(VIR_ERR_INTERNAL_ERROR,
768
_("Missing %s lock state for migration cookie"),
769
virLockManagerPluginGetName(driver->lockManager));
984
virReportError(VIR_ERR_INTERNAL_ERROR,
985
_("Missing %s lock state for migration cookie"),
986
virLockManagerPluginGetName(driver->lockManager));
772
989
} else if (STRNEQ(mig->lockDriver,
773
990
virLockManagerPluginGetName(driver->lockManager))) {
774
qemuReportError(VIR_ERR_INTERNAL_ERROR,
775
_("Source host lock driver %s different from target %s"),
777
virLockManagerPluginGetName(driver->lockManager));
991
virReportError(VIR_ERR_INTERNAL_ERROR,
992
_("Source host lock driver %s different from target %s"),
994
virLockManagerPluginGetName(driver->lockManager));
800
1017
virDomainDefPtr def)
805
1024
if (qemuProcessAutoDestroyActive(driver, vm)) {
806
qemuReportError(VIR_ERR_OPERATION_INVALID,
807
"%s", _("domain is marked for auto destroy"));
1025
virReportError(VIR_ERR_OPERATION_INVALID,
1026
"%s", _("domain is marked for auto destroy"));
810
if ((nsnapshots = virDomainSnapshotObjListNum(&vm->snapshots, NULL,
1029
if ((nsnapshots = virDomainSnapshotObjListNum(vm->snapshots, NULL,
812
qemuReportError(VIR_ERR_OPERATION_INVALID,
813
_("cannot migrate domain with %d snapshots"),
1031
virReportError(VIR_ERR_OPERATION_INVALID,
1032
_("cannot migrate domain with %d snapshots"),
1036
if (virDomainHasDiskMirror(vm)) {
1037
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
1038
_("cannot migrate domain with active block job"));
820
if (def->nhostdevs > 0) {
821
qemuReportError(VIR_ERR_OPERATION_INVALID,
822
"%s", _("Domain with assigned host devices cannot be migrated"));
1045
/* Migration with USB host devices is allowed, all other devices are
1049
for (i = 0; i < def->nhostdevs; i++) {
1050
virDomainHostdevDefPtr hostdev = def->hostdevs[i];
1051
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
1052
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
1058
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
1059
_("Domain with assigned non-USB host devices "
1060
"cannot be migrated"));
848
1086
else if (cfs < 0)
1088
} else if (disk->type == VIR_DOMAIN_DISK_TYPE_NETWORK &&
1089
disk->protocol == VIR_DOMAIN_DISK_PROTOCOL_RBD) {
852
qemuReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
853
_("Migration may lead to data corruption if disks"
854
" use cache != none"));
1093
virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s",
1094
_("Migration may lead to data corruption if disks"
1095
" use cache != none"));
893
1134
qemuDomainObjPrivatePtr priv = vm->privateData;
1137
bool wait_for_spice = false;
1138
bool spice_migrated = false;
896
1139
unsigned long long memProcessed;
897
1140
unsigned long long memRemaining;
898
1141
unsigned long long memTotal;
1143
/* If guest uses SPICE and supports seamles_migration we have to hold up
1144
* migration finish until SPICE server transfers its data */
1145
if (vm->def->ngraphics == 1 &&
1146
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
1147
qemuCapsGet(priv->caps, QEMU_CAPS_SEAMLESS_MIGRATION))
1148
wait_for_spice = true;
900
1150
ret = qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob);
902
1152
/* Guest already exited; nothing further to update. */
919
1176
switch (status) {
920
1177
case QEMU_MONITOR_MIGRATION_STATUS_INACTIVE:
921
1178
priv->job.info.type = VIR_DOMAIN_JOB_NONE;
922
qemuReportError(VIR_ERR_OPERATION_FAILED,
923
_("%s: %s"), job, _("is not active"));
1179
virReportError(VIR_ERR_OPERATION_FAILED,
1180
_("%s: %s"), job, _("is not active"));
926
1183
case QEMU_MONITOR_MIGRATION_STATUS_ACTIVE:
938
1195
case QEMU_MONITOR_MIGRATION_STATUS_COMPLETED:
939
priv->job.info.type = VIR_DOMAIN_JOB_COMPLETED;
1196
if ((wait_for_spice && spice_migrated) || (!wait_for_spice))
1197
priv->job.info.type = VIR_DOMAIN_JOB_COMPLETED;
943
1201
case QEMU_MONITOR_MIGRATION_STATUS_ERROR:
944
1202
priv->job.info.type = VIR_DOMAIN_JOB_FAILED;
945
qemuReportError(VIR_ERR_OPERATION_FAILED,
946
_("%s: %s"), job, _("unexpectedly failed"));
1203
virReportError(VIR_ERR_OPERATION_FAILED,
1204
_("%s: %s"), job, _("unexpectedly failed"));
949
1207
case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED:
950
1208
priv->job.info.type = VIR_DOMAIN_JOB_CANCELLED;
951
qemuReportError(VIR_ERR_OPERATION_ABORTED,
952
_("%s: %s"), job, _("canceled by client"));
1209
virReportError(VIR_ERR_OPERATION_ABORTED,
1210
_("%s: %s"), job, _("canceled by client"));
1309
qemuDomainMigrateOPDRelocate(struct qemud_driver *driver ATTRIBUTE_UNUSED,
1311
qemuMigrationCookiePtr cookie)
1313
virDomainNetDefPtr netptr;
1317
for (i = 0; i < cookie->network->nnets; i++) {
1318
netptr = vm->def->nets[i];
1320
switch (cookie->network->net[i].vporttype) {
1321
case VIR_NETDEV_VPORT_PROFILE_NONE:
1322
case VIR_NETDEV_VPORT_PROFILE_8021QBG:
1323
case VIR_NETDEV_VPORT_PROFILE_8021QBH:
1325
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
1326
if (virNetDevOpenvswitchSetMigrateData(cookie->network->net[i].portdata,
1327
netptr->ifname) != 0) {
1328
virReportSystemError(VIR_ERR_INTERNAL_ERROR,
1329
_("Unable to run command to set OVS port data for "
1330
"interface %s"), netptr->ifname);
1050
1345
/* This is called for outgoing non-p2p migrations when a connection to the
1051
1346
* client which initiated the migration was closed but we were waiting for it
1052
1347
* to follow up with the next phase, that is, in between
1366
1662
* This prevents any other APIs being invoked while incoming
1367
1663
* migration is taking place.
1369
if (qemuMigrationJobContinue(vm) == 0) {
1665
if (!qemuMigrationJobContinue(vm)) {
1371
qemuReportError(VIR_ERR_OPERATION_FAILED,
1372
"%s", _("domain disappeared"));
1667
virReportError(VIR_ERR_OPERATION_FAILED,
1668
"%s", _("domain disappeared"));
1479
1775
if (STRPREFIX(hostname, "localhost")) {
1480
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
1481
_("hostname on destination resolved to localhost,"
1482
" but migration requires an FQDN"));
1776
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
1777
_("hostname on destination resolved to localhost,"
1778
" but migration requires an FQDN"));
1499
1795
* characters in hostname part don't matter.
1501
1797
if (!STRPREFIX (uri_in, "tcp:")) {
1502
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
1503
_("only tcp URIs are supported for KVM/QEMU"
1798
virReportError(VIR_ERR_INVALID_ARG, "%s",
1799
_("only tcp URIs are supported for KVM/QEMU"
1523
1819
p++; /* definitely has a ':' in it, see above */
1524
1820
this_port = virParseNumber (&p);
1525
1821
if (this_port == -1 || p-uri_in != strlen (uri_in)) {
1526
qemuReportError(VIR_ERR_INVALID_ARG,
1527
"%s", _("URI ended with incorrect ':port'"));
1822
virReportError(VIR_ERR_INVALID_ARG,
1823
"%s", _("URI ended with incorrect ':port'"));
1848
2144
if (virLockManagerPluginUsesState(driver->lockManager) &&
1850
qemuReportError(VIR_ERR_INTERNAL_ERROR,
1851
_("Migration with lock driver %s requires"
1853
virLockManagerPluginGetName(driver->lockManager));
2146
virReportError(VIR_ERR_INTERNAL_ERROR,
2147
_("Migration with lock driver %s requires"
2149
virLockManagerPluginGetName(driver->lockManager));
1992
2288
if (ret == 0 &&
1993
2289
qemuMigrationBakeCookie(mig, driver, vm, cookieout, cookieoutlen,
1994
QEMU_MIGRATION_COOKIE_PERSISTENT ) < 0)
2290
QEMU_MIGRATION_COOKIE_PERSISTENT |
2291
QEMU_MIGRATION_COOKIE_NETWORK) < 0) {
1995
2292
VIR_WARN("Unable to encode migration cookie");
1997
2295
qemuMigrationCookieFree(mig);
2096
2394
driver, vm, st, NULLSTR(cookiein), cookieinlen,
2097
2395
cookieout, cookieoutlen, flags, resource);
2099
if (!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
2100
!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
2101
!qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
2102
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
2103
_("Source qemu is too old to support tunnelled migration"));
2397
if (!qemuCapsGet(priv->caps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
2398
!qemuCapsGet(priv->caps, QEMU_CAPS_MIGRATE_QEMU_UNIX) &&
2399
!qemuCapsGet(priv->caps, QEMU_CAPS_MIGRATE_QEMU_EXEC)) {
2400
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
2401
_("Source qemu is too old to support tunnelled migration"));
2107
2405
spec.fwdType = MIGRATION_FWD_STREAM;
2108
2406
spec.fwd.stream = st;
2110
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD)) {
2408
if (qemuCapsGet(priv->caps, QEMU_CAPS_MIGRATE_QEMU_FD)) {
2113
2411
spec.destType = MIGRATION_DEST_FD;
2230
2527
* in qemuDomainObjEnterRemoteWithDriver, so check again
2232
2529
if (!virDomainObjIsActive(vm)) {
2233
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2234
_("guest unexpectedly quit"));
2530
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2531
_("guest unexpectedly quit"));
2238
2535
if (!(flags & VIR_MIGRATE_TUNNELLED) &&
2239
2536
(uri_out == NULL)) {
2240
qemuReportError(VIR_ERR_INTERNAL_ERROR,
2241
_("domainMigratePrepare2 did not set uri"));
2537
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2538
_("domainMigratePrepare2 did not set uri"));
2526
2821
dconn = virConnectOpen(dconnuri);
2527
2822
qemuDomainObjExitRemoteWithDriver(driver, vm);
2528
2823
if (dconn == NULL) {
2529
qemuReportError(VIR_ERR_OPERATION_FAILED,
2530
_("Failed to connect to remote libvirt URI %s"), dconnuri);
2824
virReportError(VIR_ERR_OPERATION_FAILED,
2825
_("Failed to connect to remote libvirt URI %s"), dconnuri);
2547
2842
qemuDomainObjExitRemoteWithDriver(driver, vm);
2550
qemuReportError(VIR_ERR_OPERATION_FAILED, "%s",
2551
_("Destination libvirt does not support peer-to-peer migration protocol"));
2845
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
2846
_("Destination libvirt does not support peer-to-peer migration protocol"));
2555
2850
/* domain may have been stopped while we were talking to remote daemon */
2556
2851
if (!virDomainObjIsActive(vm)) {
2557
qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2558
_("guest unexpectedly quit"));
2852
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
2853
_("guest unexpectedly quit"));
2619
2914
if (!virDomainObjIsActive(vm)) {
2620
qemuReportError(VIR_ERR_OPERATION_INVALID,
2621
"%s", _("domain is not running"));
2915
virReportError(VIR_ERR_OPERATION_INVALID,
2916
"%s", _("domain is not running"));
2625
2920
if (!qemuMigrationIsAllowed(driver, vm, NULL))
2628
2923
if (!(flags & VIR_MIGRATE_UNSAFE) && !qemuMigrationIsSafe(vm->def))
2631
2926
resume = virDomainObjGetState(vm, NULL) == VIR_DOMAIN_RUNNING;
2854
3149
if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
2855
3150
if (virNetDevVPortProfileAssociate(net->ifname,
2856
3151
virDomainNetGetActualVirtPortProfile(net),
2858
3153
virDomainNetGetActualDirectDev(net),
2861
3156
VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH,
2863
qemuReportError(VIR_ERR_OPERATION_FAILED,
2864
_("Port profile Associate failed for %s"),
3158
virReportError(VIR_ERR_OPERATION_FAILED,
3159
_("Port profile Associate failed for %s"),
2868
3163
VIR_DEBUG("Port profile Associate succeeded for %s", net->ifname);
2870
if (virNetDevMacVLanVPortProfileRegisterCallback(net->ifname, net->mac,
3165
if (virNetDevMacVLanVPortProfileRegisterCallback(net->ifname, &net->mac,
2871
3166
virDomainNetGetActualDirectDev(net), def->uuid,
2872
3167
virDomainNetGetActualVirtPortProfile(net),
2873
3168
VIR_NETDEV_VPORT_PROFILE_OP_CREATE))
3011
3311
VIR_DOMAIN_RUNNING_MIGRATED,
3012
3312
QEMU_ASYNC_JOB_MIGRATION_IN) < 0) {
3013
3313
if (virGetLastError() == NULL)
3014
qemuReportError(VIR_ERR_INTERNAL_ERROR,
3015
"%s", _("resume operation failed"));
3314
virReportError(VIR_ERR_INTERNAL_ERROR,
3315
"%s", _("resume operation failed"));
3016
3316
/* Need to save the current error, in case shutting
3017
3317
* down the process overwrites it
3141
3441
VIR_DOMAIN_RUNNING_MIGRATED,
3142
3442
QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) {
3143
3443
if (virGetLastError() == NULL)
3144
qemuReportError(VIR_ERR_INTERNAL_ERROR,
3145
"%s", _("resume operation failed"));
3444
virReportError(VIR_ERR_INTERNAL_ERROR,
3445
"%s", _("resume operation failed"));
3186
3486
* Failure to change migration speed is not fatal. */
3187
3487
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
3188
3488
qemuMonitorSetMigrationSpeed(priv->mon,
3189
QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX);
3190
priv->migMaxBandwidth = QEMU_DOMAIN_FILE_MIG_BANDWIDTH_MAX;
3489
QEMU_DOMAIN_MIG_BANDWIDTH_MAX);
3490
priv->migMaxBandwidth = QEMU_DOMAIN_MIG_BANDWIDTH_MAX;
3191
3491
qemuDomainObjExitMonitorWithDriver(driver, vm);
3194
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
3494
if (qemuCapsGet(priv->caps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
3195
3495
(!compressor || pipe(pipeFD) == 0)) {
3196
3496
/* All right! We can use fd migration, which means that qemu
3197
3497
* doesn't have to open() the file, so while we still have to
3211
3511
VIR_CGROUP_CONTROLLER_DEVICES)) {
3212
3512
if (virCgroupForDomain(driver->cgroup, vm->def->name,
3213
3513
&cgroup, 0) != 0) {
3214
qemuReportError(VIR_ERR_INTERNAL_ERROR,
3215
_("Unable to find cgroup for %s"),
3514
virReportError(VIR_ERR_INTERNAL_ERROR,
3515
_("Unable to find cgroup for %s"),
3219
3519
rc = virCgroupAllowDevicePath(cgroup, path,
3242
3542
if (!compressor) {
3243
3543
const char *args[] = { "cat", NULL };
3245
if (qemuCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
3545
if (qemuCapsGet(priv->caps, QEMU_CAPS_MIGRATE_QEMU_FD) &&
3246
3546
priv->monConfig->type == VIR_DOMAIN_CHR_TYPE_UNIX) {
3247
3547
rc = qemuMonitorMigrateToFd(priv->mon,
3248
3548
QEMU_MONITOR_MIGRATE_BACKGROUND,
3399
3699
msg = _("domain '%s' is not being migrated");
3401
qemuReportError(VIR_ERR_OPERATION_INVALID, msg, vm->def->name);
3701
virReportError(VIR_ERR_OPERATION_INVALID, msg, vm->def->name);
3408
3708
qemuMigrationJobFinish(struct qemud_driver *driver, virDomainObjPtr vm)
3410
3710
return qemuDomainObjEndAsyncJob(driver, vm);