virDomainDefParseXML -> virDomainDiskDefParseXML -> virDomainDeviceInfoParseXML -> virDomainDeviceAddressParseXML -> virPCIDeviceAddressParseXML

1
2
3
4
5
6
7
8
9
10
if (devaddr) {
if (virDomainParseLegacyDeviceAddress(devaddr,
&def->info.addr.pci) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to parse devaddr parameter '%s'"),
devaddr);
goto error;
}
def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
} else {

qemuDomainSaveInternal ->

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if (!(cookie = qemuDomainSaveCookieNew(vm)))
goto endjob;

if (!(data = virQEMUSaveDataNew(xml, cookie, was_running, compressed,
driver->xmlopt)))
goto endjob;
xml = NULL;

ret = qemuDomainSaveMemory(driver, vm, path, data, compressedpath,
flags, QEMU_ASYNC_JOB_SAVE);
if (ret < 0)
goto endjob;

/* Shut it down */
qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED,
QEMU_ASYNC_JOB_SAVE, 0);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        rc = qemuMonitorMigrateToFd(priv->mon,
QEMU_MONITOR_MIGRATE_BACKGROUND,
fd);

int
qemuMonitorMigrateToFd(qemuMonitorPtr mon,
unsigned int flags,
int fd)
{
int ret;
VIR_DEBUG("fd=%d flags=0x%x", fd, flags);

QEMU_CHECK_MONITOR(mon);

if (qemuMonitorSendFileHandle(mon, "migrate", fd) < 0)
return -1;

ret = qemuMonitorJSONMigrate(mon, flags, "fd:migrate");

if (ret < 0) {
if (qemuMonitorCloseFileHandle(mon, "migrate") < 0)
VIR_WARN("failed to close migration handle");
}

return ret;
}

qemu should support sendFD (qemu is should using a unix socket monitor)

qemu monitor get fd (SCM_RIGHTS)

SCM_RIGHTS
Send or receive a set of open file descriptors from
another process. The data portion contains an integer
array of the file descriptors.

1
2
3
4
/* Perform the migration */
if (qemuMigrationSrcToFile(driver, vm, fd, compressedpath, asyncJob) < 0)
goto cleanup;

1
qemuMonitorJSONMigrate