Nowadays we only support qemu 0.12.0+ which provides QEMU_CAPS_DEVICE,
so this is all dead code.
---
src/qemu/qemu_process.c | 471 +++---------------------------------------------
1 file changed, 27 insertions(+), 444 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index d465b4f..0c0b471 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2434,31 +2434,29 @@ qemuProcessInitPasswords(virConnectPtr conn,
goto cleanup;
}
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- for (i = 0; i < vm->def->ndisks; i++) {
- size_t secretLen;
+ for (i = 0; i < vm->def->ndisks; i++) {
+ size_t secretLen;
- if (!vm->def->disks[i]->src->encryption ||
- !virDomainDiskGetSource(vm->def->disks[i]))
- continue;
+ if (!vm->def->disks[i]->src->encryption ||
+ !virDomainDiskGetSource(vm->def->disks[i]))
+ continue;
- VIR_FREE(secret);
- if (qemuProcessGetVolumeQcowPassphrase(conn,
- vm->def->disks[i],
- &secret, &secretLen) < 0)
- goto cleanup;
+ VIR_FREE(secret);
+ if (qemuProcessGetVolumeQcowPassphrase(conn,
+ vm->def->disks[i],
+ &secret, &secretLen) < 0)
+ goto cleanup;
- VIR_FREE(alias);
- if (VIR_STRDUP(alias, vm->def->disks[i]->info.alias) < 0)
- goto cleanup;
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
- goto cleanup;
- ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- ret = -1;
- if (ret < 0)
- goto cleanup;
- }
+ VIR_FREE(alias);
+ if (VIR_STRDUP(alias, vm->def->disks[i]->info.alias) < 0)
+ goto cleanup;
+ if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+ goto cleanup;
+ ret = qemuMonitorSetDrivePassphrase(priv->mon, alias, secret);
+ if (qemuDomainObjExitMonitor(driver, vm) < 0)
+ ret = -1;
+ if (ret < 0)
+ goto cleanup;
}
cleanup:
@@ -2469,400 +2467,6 @@ qemuProcessInitPasswords(virConnectPtr conn,
}
-#define QEMU_PCI_VENDOR_INTEL 0x8086
-#define QEMU_PCI_VENDOR_LSI_LOGIC 0x1000
-#define QEMU_PCI_VENDOR_REDHAT 0x1af4
-#define QEMU_PCI_VENDOR_CIRRUS 0x1013
-#define QEMU_PCI_VENDOR_REALTEK 0x10ec
-#define QEMU_PCI_VENDOR_AMD 0x1022
-#define QEMU_PCI_VENDOR_ENSONIQ 0x1274
-#define QEMU_PCI_VENDOR_VMWARE 0x15ad
-#define QEMU_PCI_VENDOR_QEMU 0x1234
-
-#define QEMU_PCI_PRODUCT_DISK_VIRTIO 0x1001
-
-#define QEMU_PCI_PRODUCT_BALLOON_VIRTIO 0x1002
-
-#define QEMU_PCI_PRODUCT_NIC_NE2K 0x8029
-#define QEMU_PCI_PRODUCT_NIC_PCNET 0x2000
-#define QEMU_PCI_PRODUCT_NIC_RTL8139 0x8139
-#define QEMU_PCI_PRODUCT_NIC_E1000 0x100E
-#define QEMU_PCI_PRODUCT_NIC_VIRTIO 0x1000
-
-#define QEMU_PCI_PRODUCT_VGA_CIRRUS 0x00b8
-#define QEMU_PCI_PRODUCT_VGA_VMWARE 0x0405
-#define QEMU_PCI_PRODUCT_VGA_STDVGA 0x1111
-
-#define QEMU_PCI_PRODUCT_AUDIO_AC97 0x2415
-#define QEMU_PCI_PRODUCT_AUDIO_ES1370 0x5000
-
-#define QEMU_PCI_PRODUCT_CONTROLLER_PIIX 0x7010
-#define QEMU_PCI_PRODUCT_CONTROLLER_LSI 0x0012
-
-#define QEMU_PCI_PRODUCT_WATCHDOG_I63000ESB 0x25ab
-
-static int
-qemuProcessAssignNextPCIAddress(virDomainDeviceInfo *info,
- int vendor,
- int product,
- qemuMonitorPCIAddress *addrs,
- int naddrs)
-{
- bool found = false;
- size_t i;
-
- VIR_DEBUG("Look for %x:%x out of %d", vendor, product, naddrs);
-
- for (i = 0; i < naddrs; i++) {
- VIR_DEBUG("Maybe %x:%x", addrs[i].vendor, addrs[i].product);
- if (addrs[i].vendor == vendor &&
- addrs[i].product == product) {
- VIR_DEBUG("Match %zu", i);
- found = true;
- break;
- }
- }
- if (!found)
- return -1;
-
- /* Blank it out so this device isn't matched again */
- addrs[i].vendor = 0;
- addrs[i].product = 0;
-
- if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
- info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-
- if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
- info->addr.pci.domain = addrs[i].addr.domain;
- info->addr.pci.bus = addrs[i].addr.bus;
- info->addr.pci.slot = addrs[i].addr.slot;
- info->addr.pci.function = addrs[i].addr.function;
- }
-
- return 0;
-}
-
-static int
-qemuProcessGetPCIDiskVendorProduct(virDomainDiskDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- switch (def->bus) {
- case VIR_DOMAIN_DISK_BUS_VIRTIO:
- *vendor = QEMU_PCI_VENDOR_REDHAT;
- *product = QEMU_PCI_PRODUCT_DISK_VIRTIO;
- break;
-
- default:
- return -1;
- }
-
- return 0;
-}
-
-static int
-qemuProcessGetPCINetVendorProduct(virDomainNetDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- if (!def->model)
- return -1;
-
- if (STREQ(def->model, "ne2k_pci")) {
- *vendor = QEMU_PCI_VENDOR_REALTEK;
- *product = QEMU_PCI_PRODUCT_NIC_NE2K;
- } else if (STREQ(def->model, "pcnet")) {
- *vendor = QEMU_PCI_VENDOR_AMD;
- *product = QEMU_PCI_PRODUCT_NIC_PCNET;
- } else if (STREQ(def->model, "rtl8139")) {
- *vendor = QEMU_PCI_VENDOR_REALTEK;
- *product = QEMU_PCI_PRODUCT_NIC_RTL8139;
- } else if (STREQ(def->model, "e1000")) {
- *vendor = QEMU_PCI_VENDOR_INTEL;
- *product = QEMU_PCI_PRODUCT_NIC_E1000;
- } else if (STREQ(def->model, "virtio")) {
- *vendor = QEMU_PCI_VENDOR_REDHAT;
- *product = QEMU_PCI_PRODUCT_NIC_VIRTIO;
- } else {
- VIR_INFO("Unexpected NIC model %s, cannot get PCI address",
- def->model);
- return -1;
- }
- return 0;
-}
-
-static int
-qemuProcessGetPCIControllerVendorProduct(virDomainControllerDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- switch (def->type) {
- case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
- *vendor = QEMU_PCI_VENDOR_LSI_LOGIC;
- *product = QEMU_PCI_PRODUCT_CONTROLLER_LSI;
- break;
-
- case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
- /* XXX we could put in the ISA bridge address, but
- that's not technically the FDC's address */
- return -1;
-
- case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
- *vendor = QEMU_PCI_VENDOR_INTEL;
- *product = QEMU_PCI_PRODUCT_CONTROLLER_PIIX;
- break;
-
- default:
- VIR_INFO("Unexpected controller type %s, cannot get PCI address",
- virDomainControllerTypeToString(def->type));
- return -1;
- }
-
- return 0;
-}
-
-static int
-qemuProcessGetPCIVideoVendorProduct(virDomainVideoDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- switch (def->type) {
- case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
- *vendor = QEMU_PCI_VENDOR_CIRRUS;
- *product = QEMU_PCI_PRODUCT_VGA_CIRRUS;
- break;
-
- case VIR_DOMAIN_VIDEO_TYPE_VGA:
- *vendor = QEMU_PCI_VENDOR_QEMU;
- *product = QEMU_PCI_PRODUCT_VGA_STDVGA;
- break;
-
- case VIR_DOMAIN_VIDEO_TYPE_VMVGA:
- *vendor = QEMU_PCI_VENDOR_VMWARE;
- *product = QEMU_PCI_PRODUCT_VGA_VMWARE;
- break;
-
- default:
- return -1;
- }
- return 0;
-}
-
-static int
-qemuProcessGetPCISoundVendorProduct(virDomainSoundDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- switch (def->model) {
- case VIR_DOMAIN_SOUND_MODEL_ES1370:
- *vendor = QEMU_PCI_VENDOR_ENSONIQ;
- *product = QEMU_PCI_PRODUCT_AUDIO_ES1370;
- break;
-
- case VIR_DOMAIN_SOUND_MODEL_AC97:
- *vendor = QEMU_PCI_VENDOR_INTEL;
- *product = QEMU_PCI_PRODUCT_AUDIO_AC97;
- break;
-
- default:
- return -1;
- }
-
- return 0;
-}
-
-static int
-qemuProcessGetPCIWatchdogVendorProduct(virDomainWatchdogDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- switch (def->model) {
- case VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB:
- *vendor = QEMU_PCI_VENDOR_INTEL;
- *product = QEMU_PCI_PRODUCT_WATCHDOG_I63000ESB;
- break;
-
- default:
- return -1;
- }
-
- return 0;
-}
-
-
-static int
-qemuProcessGetPCIMemballoonVendorProduct(virDomainMemballoonDefPtr def,
- unsigned *vendor,
- unsigned *product)
-{
- switch (def->model) {
- case VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO:
- *vendor = QEMU_PCI_VENDOR_REDHAT;
- *product = QEMU_PCI_PRODUCT_BALLOON_VIRTIO;
- break;
-
- default:
- return -1;
- }
-
- return 0;
-}
-
-
-/*
- * This entire method assumes that PCI devices in 'info pci'
- * match ordering of devices specified on the command line
- * wrt to devices of matching vendor+product
- *
- * XXXX this might not be a valid assumption if we assign
- * some static addrs on CLI. Have to check that...
- */
-static int
-qemuProcessDetectPCIAddresses(virDomainObjPtr vm,
- qemuMonitorPCIAddress *addrs,
- int naddrs)
-{
- unsigned int vendor = 0, product = 0;
- size_t i;
-
- /* XXX should all these vendor/product IDs be kept in the
- * actual device data structure instead ?
- */
-
- for (i = 0; i < vm->def->ndisks; i++) {
- if (qemuProcessGetPCIDiskVendorProduct(vm->def->disks[i], &vendor,
&product) < 0)
- continue;
-
- if (qemuProcessAssignNextPCIAddress(&(vm->def->disks[i]->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for VirtIO disk %s"),
- vm->def->disks[i]->dst);
- return -1;
- }
- }
-
- for (i = 0; i < vm->def->nnets; i++) {
- if (qemuProcessGetPCINetVendorProduct(vm->def->nets[i], &vendor,
&product) < 0)
- continue;
-
- if (qemuProcessAssignNextPCIAddress(&(vm->def->nets[i]->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for %s NIC"),
- vm->def->nets[i]->model);
- return -1;
- }
- }
-
- for (i = 0; i < vm->def->ncontrollers; i++) {
- if (qemuProcessGetPCIControllerVendorProduct(vm->def->controllers[i],
&vendor, &product) < 0)
- continue;
-
- if
(qemuProcessAssignNextPCIAddress(&(vm->def->controllers[i]->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for controller %s"),
-
virDomainControllerTypeToString(vm->def->controllers[i]->type));
- return -1;
- }
- }
-
- for (i = 0; i < vm->def->nvideos; i++) {
- if (qemuProcessGetPCIVideoVendorProduct(vm->def->videos[i], &vendor,
&product) < 0)
- continue;
-
- if (qemuProcessAssignNextPCIAddress(&(vm->def->videos[i]->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for video adapter %s"),
-
virDomainVideoTypeToString(vm->def->videos[i]->type));
- return -1;
- }
- }
-
- for (i = 0; i < vm->def->nsounds; i++) {
- if (qemuProcessGetPCISoundVendorProduct(vm->def->sounds[i], &vendor,
&product) < 0)
- continue;
-
- if (qemuProcessAssignNextPCIAddress(&(vm->def->sounds[i]->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for sound adapter %s"),
-
virDomainSoundModelTypeToString(vm->def->sounds[i]->model));
- return -1;
- }
- }
-
-
- if (vm->def->watchdog &&
- qemuProcessGetPCIWatchdogVendorProduct(vm->def->watchdog, &vendor,
&product) == 0) {
- if (qemuProcessAssignNextPCIAddress(&(vm->def->watchdog->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for watchdog %s"),
-
virDomainWatchdogModelTypeToString(vm->def->watchdog->model));
- return -1;
- }
- }
-
- if (vm->def->memballoon &&
- qemuProcessGetPCIMemballoonVendorProduct(vm->def->memballoon, &vendor,
&product) == 0) {
- if (qemuProcessAssignNextPCIAddress(&(vm->def->memballoon->info),
- vendor, product,
- addrs, naddrs) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("cannot find PCI address for balloon %s"),
-
virDomainMemballoonModelTypeToString(vm->def->memballoon->model));
- return -1;
- }
- }
-
- /* XXX console (virtio) */
-
-
- /* ... and now things we don't have in our xml */
-
- /* XXX USB controller ? */
-
- /* XXX what about other PCI devices (ie bridges) */
-
- return 0;
-}
-
-static int
-qemuProcessInitPCIAddresses(virQEMUDriverPtr driver,
- virDomainObjPtr vm,
- int asyncJob)
-{
- qemuDomainObjPrivatePtr priv = vm->privateData;
- int naddrs;
- int ret = -1;
- qemuMonitorPCIAddress *addrs = NULL;
-
- if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
- return -1;
- naddrs = qemuMonitorGetAllPCIAddresses(priv->mon,
- &addrs);
- if (qemuDomainObjExitMonitor(driver, vm) < 0)
- goto cleanup;
-
- if (naddrs > 0)
- ret = qemuProcessDetectPCIAddresses(vm, addrs, naddrs);
-
- cleanup:
- VIR_FREE(addrs);
-
- return ret;
-}
-
-
static int
qemuProcessPrepareChardevDevice(virDomainDefPtr def ATTRIBUTE_UNUSED,
virDomainChrDefPtr dev,
@@ -3630,9 +3234,8 @@ qemuProcessReconnect(void *opaque)
goto cleanup;
}
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE))
- if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, obj)) < 0)
- goto error;
+ if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, obj)) < 0)
+ goto error;
/* if domain requests security driver we haven't loaded, report error, but
* do not kill the domain
@@ -4780,11 +4383,9 @@ qemuProcessLaunch(virConnectPtr conn,
* we also need to populate the PCI address set cache for later
* use in hotplug
*/
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- VIR_DEBUG("Assigning domain PCI addresses");
- if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
- goto cleanup;
- }
+ VIR_DEBUG("Assigning domain PCI addresses");
+ if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+ goto cleanup;
VIR_DEBUG("Checking for any possible (non-fatal) issues");
@@ -5036,14 +4637,6 @@ qemuProcessLaunch(virConnectPtr conn,
if (qemuProcessInitPasswords(conn, driver, vm, asyncJob) < 0)
goto cleanup;
- /* If we have -device, then addresses are assigned explicitly.
- * If not, then we have to detect dynamic ones here */
- if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- VIR_DEBUG("Determining domain device PCI addresses");
- if (qemuProcessInitPCIAddresses(driver, vm, asyncJob) < 0)
- goto cleanup;
- }
-
/* set default link states */
/* qemu doesn't support setting this on the command line, so
* enter the monitor */
@@ -5682,11 +5275,9 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
* we also need to populate the PCI address set cache for later
* use in hotplug
*/
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- VIR_DEBUG("Assigning domain PCI addresses");
- if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
+ VIR_DEBUG("Assigning domain PCI addresses");
+ if ((qemuDomainAssignAddresses(vm->def, priv->qemuCaps, vm)) < 0)
goto error;
- }
if ((timestamp = virTimeStringNow()) == NULL)
goto error;
@@ -5719,14 +5310,6 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
if (qemuProcessDetectIOThreadPIDs(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
goto error;
- /* If we have -device, then addresses are assigned explicitly.
- * If not, then we have to detect dynamic ones here */
- if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- VIR_DEBUG("Determining domain device PCI addresses");
- if (qemuProcessInitPCIAddresses(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
- goto error;
- }
-
VIR_DEBUG("Getting initial memory amount");
qemuDomainObjEnterMonitor(driver, vm);
if (qemuMonitorGetBalloonInfo(priv->mon, &vm->def->mem.cur_balloon) <
0)
--
2.5.0