mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
qemu: Assign device addresses in PostParse
This wires up qemuDomainAssignAddresses into the new virDomainDefAssignAddressesCallback, so it's always triggered via virDomainDefPostParse. We are essentially doing this already with open coded calls sprinkled about. qemu argv parse output changes slightly since previously it wasn't hitting qemuDomainAssignAddresses.
This commit is contained in:
parent
f891390fa7
commit
5d7314bbcf
@ -2301,9 +2301,34 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuDomainDefAssignAddresses(virDomainDef *def,
|
||||
virCapsPtr caps ATTRIBUTE_UNUSED,
|
||||
unsigned int parseFlags ATTRIBUTE_UNUSED,
|
||||
void *opaque)
|
||||
{
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
|
||||
def->emulator)))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virObjectUnref(qemuCaps);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
virDomainDefParserConfig virQEMUDriverDomainDefParserConfig = {
|
||||
.devicesPostParseCallback = qemuDomainDeviceDefPostParse,
|
||||
.domainPostParseCallback = qemuDomainDefPostParse,
|
||||
.assignAddressesCallback = qemuDomainDefAssignAddresses,
|
||||
.features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
|
||||
VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN
|
||||
};
|
||||
|
@ -1771,7 +1771,6 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
||||
virObjectEventPtr event = NULL;
|
||||
virObjectEventPtr event2 = NULL;
|
||||
unsigned int start_flags = VIR_QEMU_PROCESS_START_COLD;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||
VIR_DOMAIN_DEF_PARSE_ABI_UPDATE;
|
||||
@ -1799,12 +1798,6 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
||||
if (virDomainCreateXMLEnsureACL(conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator)))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
||||
driver->xmlopt,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
@ -1858,7 +1851,6 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
|
||||
qemuDomainEventQueue(driver, event2);
|
||||
}
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(qemuCaps);
|
||||
virNWFilterUnlockFilterUpdates();
|
||||
return dom;
|
||||
}
|
||||
@ -7249,7 +7241,6 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
|
||||
virDomainObjPtr vm = NULL;
|
||||
virDomainPtr dom = NULL;
|
||||
virObjectEventPtr event = NULL;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
virQEMUDriverConfigPtr cfg;
|
||||
virCapsPtr caps = NULL;
|
||||
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
|
||||
@ -7272,12 +7263,6 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
|
||||
if (virDomainDefineXMLFlagsEnsureACL(conn, def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator)))
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
||||
driver->xmlopt,
|
||||
0, &oldDef)))
|
||||
@ -7328,7 +7313,6 @@ static virDomainPtr qemuDomainDefineXMLFlags(virConnectPtr conn, const char *xml
|
||||
virDomainDefFree(def);
|
||||
virDomainObjEndAPI(&vm);
|
||||
qemuDomainEventQueue(driver, event);
|
||||
virObjectUnref(qemuCaps);
|
||||
virObjectUnref(caps);
|
||||
virObjectUnref(cfg);
|
||||
return dom;
|
||||
@ -15975,9 +15959,6 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn,
|
||||
if (qemuAssignDeviceAliases(def, qemuCaps) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (qemuDomainAssignAddresses(def, qemuCaps, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!(vm = virDomainObjListAdd(driver->domains, def,
|
||||
driver->xmlopt,
|
||||
VIR_DOMAIN_OBJ_LIST_ADD_LIVE |
|
||||
|
@ -29,7 +29,9 @@
|
||||
</disk>
|
||||
<controller type='usb' index='0'/>
|
||||
<controller type='pci' index='0' model='pci-root'/>
|
||||
<controller type='scsi' index='0'/>
|
||||
<controller type='scsi' index='0'>
|
||||
<address type='spapr-vio' reg='0x2000'/>
|
||||
</controller>
|
||||
<input type='keyboard' bus='usb'/>
|
||||
<input type='mouse' bus='usb'/>
|
||||
<graphics type='sdl'/>
|
||||
|
@ -1403,7 +1403,7 @@ mymain(void)
|
||||
QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PCI_MULTIFUNCTION);
|
||||
DO_TEST("pseries-vio-user-assigned",
|
||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST_FAILURE("pseries-vio-address-clash",
|
||||
DO_TEST_PARSE_ERROR("pseries-vio-address-clash",
|
||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
|
||||
DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
|
||||
|
@ -37,13 +37,9 @@ struct testInfo {
|
||||
};
|
||||
|
||||
static int
|
||||
qemuXML2XMLPreFormatCallback(virDomainDefPtr def, const void *opaque)
|
||||
qemuXML2XMLPreFormatCallback(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
||||
const void *opaque ATTRIBUTE_UNUSED)
|
||||
{
|
||||
const struct testInfo *info = opaque;
|
||||
|
||||
if (qemuDomainAssignAddresses(def, info->qemuCaps, NULL))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -153,9 +149,6 @@ testCompareStatusXMLToXMLFiles(const void *opaque)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (qemuDomainAssignAddresses(obj->def, data->qemuCaps, NULL))
|
||||
goto cleanup;
|
||||
|
||||
/* format it back */
|
||||
if (!(actual = virDomainObjFormat(driver.xmlopt, obj, NULL,
|
||||
VIR_DOMAIN_DEF_FORMAT_SECURE))) {
|
||||
|
Loading…
Reference in New Issue
Block a user