mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
qemu_hotplug: generate vioserial address list on demand
Dropping the caching of virtio serial address set. Instead of using the cached address set, a function in qemu_hotplug.c now recalculates it on demand. Credit goes to Cole Robinson.
This commit is contained in:
parent
40c284f0a6
commit
925fa4b905
@ -1551,44 +1551,58 @@ qemuDomainChrRemove(virDomainDefPtr vmdef,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainAttachChrDeviceAssignAddr(qemuDomainObjPrivatePtr priv,
|
qemuDomainAttachChrDeviceAssignAddr(virDomainDefPtr def,
|
||||||
|
qemuDomainObjPrivatePtr priv,
|
||||||
virDomainChrDefPtr chr)
|
virDomainChrDefPtr chr)
|
||||||
{
|
{
|
||||||
|
int ret = -1;
|
||||||
|
virDomainVirtioSerialAddrSetPtr vioaddrs = NULL;
|
||||||
|
|
||||||
|
if (!(vioaddrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
||||||
chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
|
chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
|
||||||
if (virDomainVirtioSerialAddrAutoAssign(NULL, priv->vioserialaddrs,
|
if (virDomainVirtioSerialAddrAutoAssign(NULL, vioaddrs,
|
||||||
&chr->info, true) < 0)
|
&chr->info, true) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
return 1;
|
ret = 1;
|
||||||
|
|
||||||
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
||||||
chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) {
|
chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_PCI) {
|
||||||
if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &chr->info) < 0)
|
if (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &chr->info) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
return 1;
|
ret = 1;
|
||||||
|
|
||||||
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
||||||
chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) {
|
chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) {
|
||||||
if (virDomainUSBAddressEnsure(priv->usbaddrs, &chr->info) < 0)
|
if (virDomainUSBAddressEnsure(priv->usbaddrs, &chr->info) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
return 1;
|
ret = 1;
|
||||||
|
|
||||||
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
|
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
|
||||||
chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
|
chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
|
||||||
if (virDomainVirtioSerialAddrAutoAssign(NULL, priv->vioserialaddrs,
|
if (virDomainVirtioSerialAddrAutoAssign(NULL, vioaddrs,
|
||||||
&chr->info, false) < 0)
|
&chr->info, false) < 0)
|
||||||
return -1;
|
goto cleanup;
|
||||||
return 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret == 1)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL ||
|
if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL ||
|
||||||
chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
_("Unsupported address type for character device"));
|
_("Unsupported address type for character device"));
|
||||||
return -1;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virDomainVirtioSerialAddrSetFree(vioaddrs);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
||||||
@ -1611,7 +1625,7 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
|||||||
if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
|
if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((rc = qemuDomainAttachChrDeviceAssignAddr(priv, chr)) < 0)
|
if ((rc = qemuDomainAttachChrDeviceAssignAddr(vm->def, priv, chr)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (rc == 1)
|
if (rc == 1)
|
||||||
need_release = true;
|
need_release = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user