Persistent Failed to attach device following transient Failed to read product/vendor ID
by Pighin, Anthony (Nokia - CA/Ottawa)
I'm attempting to solve the issue reported here:
https://gitlab.com/libvirt/libvirt/-/issues/345
Hoping the originator of virHostdevDeleteMissingPCIDevices() will be able to comment, as I am still trying to reproduce the issue with additional debug in place.
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index c0ce867596..d43354963e 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -1101,11 +1101,11 @@ virHostdevReAttachPCIDevices(virHostdevManager *mgr,
VIR_ERROR(_("Failed to allocate PCI device list: %s"),
virGetLastErrorMessage());
virResetLastError();
- return;
}
-
- virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs,
- hostdevs, nhostdevs);
+ else {
+ virHostdevReAttachPCIDevicesImpl(mgr, drv_name, dom_name, pcidevs,
+ hostdevs, nhostdevs);
+ }
/* Handle the case where PCI devices from the host went missing
* during the domain lifetime */
2 years, 5 months
[PATCH] qemu: support hotplug cdrom with usb/scsi bus
by minglei.liu
Qemu support hotplug cdrom device with usb or scsi bus,
just unblock these devices in qemuDomainAttachDeviceDiskLiveInternal
and qemuDomainDetachPrepDisk.
Fixes: #261
Signed-off-by: minglei.liu <minglei.liu(a)smartx.com>
---
src/qemu/qemu_hotplug.c | 13 +++-
tests/qemuhotplugtest.c | 18 ++++++
.../qemuhotplug-cdrom-scsi.xml | 6 ++
.../qemuhotplug-cdrom-usb.xml | 6 ++
.../qemuhotplug-base-live+cdrom-scsi.xml | 60 +++++++++++++++++++
.../qemuhotplug-base-live+cdrom-usb.xml | 60 +++++++++++++++++++
6 files changed, 160 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-usb.xml
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 27e68370cf..d917086023 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -992,10 +992,9 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
bool releaseSeclabel = false;
int ret = -1;
- if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM ||
- disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
- _("cdrom/floppy device hotplug isn't supported"));
+ _("floppy device hotplug isn't supported"));
return -1;
}
@@ -1025,6 +1024,10 @@ qemuDomainAttachDeviceDiskLiveInternal(virQEMUDriver *driver,
break;
case VIR_DOMAIN_DISK_BUS_VIRTIO:
+ if (disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) {
+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
+ _("cdrom device with virtio bus isn't supported"));
+ }
if (qemuDomainEnsureVirtioAddress(&releaseVirtio, vm, dev) < 0)
goto cleanup;
break;
@@ -5414,6 +5417,10 @@ qemuDomainDetachPrepDisk(virDomainObj *vm,
case VIR_DOMAIN_DISK_DEVICE_CDROM:
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
+ if ((virDomainDiskBus) disk->bus == VIR_DOMAIN_DISK_BUS_USB ||
+ (virDomainDiskBus) disk->bus == VIR_DOMAIN_DISK_BUS_SCSI) {
+ break;
+ }
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("disk device type '%s' cannot be detached"),
virDomainDiskDeviceTypeToString(disk->device));
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index e98d9845e8..3c9dac241a 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -860,6 +860,24 @@ mymain(void)
DO_TEST_DETACH("base-live", "guestfwd", false, false,
"netdev_del", QMP_OK);
+ DO_TEST_ATTACH("base-live", "cdrom-usb", false, true,
+ "human-monitor-command", HMP("OK\\r\\n"),
+ "device_add", QMP_OK);
+ DO_TEST_DETACH("base-live", "cdrom-usb", true, true,
+ "device_del", QMP_OK);
+ DO_TEST_DETACH("base-live", "cdrom-usb", false, false,
+ "device_del", QMP_DEVICE_DELETED("usb-disk4") QMP_OK,
+ "human-monitor-command", HMP(""));
+
+ DO_TEST_ATTACH("base-live", "cdrom-scsi", false, true,
+ "human-monitor-command", HMP("OK\\r\\n"),
+ "device_add", QMP_OK);
+ DO_TEST_DETACH("base-live", "cdrom-scsi", true, true,
+ "device_del", QMP_OK);
+ DO_TEST_DETACH("base-live", "cdrom-scsi", false, false,
+ "device_del", QMP_DEVICE_DELETED("scsi0-0-0-4") QMP_OK,
+ "human-monitor-command", HMP(""));
+
#define DO_TEST_CPU_GROUP(prefix, vcpus, modernhp, expectfail) \
do { \
cpudata.test = prefix; \
diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml b/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml
new file mode 100644
index 0000000000..da8b94bb22
--- /dev/null
+++ b/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-scsi.xml
@@ -0,0 +1,6 @@
+<disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw' cache='none'/>
+ <source file='/dev/null'/>
+ <target dev='sde' bus='scsi'/>
+ <readonly/>
+</disk>
diff --git a/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml b/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml
new file mode 100644
index 0000000000..efb974090c
--- /dev/null
+++ b/tests/qemuhotplugtestdevices/qemuhotplug-cdrom-usb.xml
@@ -0,0 +1,6 @@
+<disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw' cache='none'/>
+ <source file='/dev/null'/>
+ <target dev='sde' bus='usb'/>
+ <readonly/>
+</disk>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml
new file mode 100644
index 0000000000..c3242a582f
--- /dev/null
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-scsi.xml
@@ -0,0 +1,60 @@
+<domain type='kvm' id='7'>
+ <name>hotplug</name>
+ <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
+ <memory unit='KiB'>4194304</memory>
+ <currentMemory unit='KiB'>4194304</currentMemory>
+ <vcpu placement='static'>4</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw' cache='none'/>
+ <source file='/dev/null'/>
+ <backingStore/>
+ <target dev='sde' bus='scsi'/>
+ <readonly/>
+ <alias name='scsi0-0-0-4'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='4'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <alias name='usb'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <alias name='ide'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <alias name='scsi0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'>
+ <alias name='pci'/>
+ </controller>
+ <controller type='virtio-serial' index='0'>
+ <alias name='virtio-serial0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </controller>
+ <input type='mouse' bus='ps2'>
+ <alias name='input0'/>
+ </input>
+ <input type='keyboard' bus='ps2'>
+ <alias name='input1'/>
+ </input>
+ <audio id='1' type='none'/>
+ <memballoon model='none'/>
+ </devices>
+ <seclabel type='none' model='none'/>
+</domain>
diff --git a/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-usb.xml b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-usb.xml
new file mode 100644
index 0000000000..89317f5dc8
--- /dev/null
+++ b/tests/qemuhotplugtestdomains/qemuhotplug-base-live+cdrom-usb.xml
@@ -0,0 +1,60 @@
+<domain type='kvm' id='7'>
+ <name>hotplug</name>
+ <uuid>d091ea82-29e6-2e34-3005-f02617b36e87</uuid>
+ <memory unit='KiB'>4194304</memory>
+ <currentMemory unit='KiB'>4194304</currentMemory>
+ <vcpu placement='static'>4</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <features>
+ <acpi/>
+ <apic/>
+ <pae/>
+ </features>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>restart</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw' cache='none'/>
+ <source file='/dev/null'/>
+ <backingStore/>
+ <target dev='sde' bus='usb'/>
+ <readonly/>
+ <alias name='usb-disk4'/>
+ <address type='usb' bus='0' port='1'/>
+ </disk>
+ <controller type='usb' index='0'>
+ <alias name='usb'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='ide' index='0'>
+ <alias name='ide'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='scsi' index='0' model='virtio-scsi'>
+ <alias name='scsi0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'>
+ <alias name='pci'/>
+ </controller>
+ <controller type='virtio-serial' index='0'>
+ <alias name='virtio-serial0'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+ </controller>
+ <input type='mouse' bus='ps2'>
+ <alias name='input0'/>
+ </input>
+ <input type='keyboard' bus='ps2'>
+ <alias name='input1'/>
+ </input>
+ <audio id='1' type='none'/>
+ <memballoon model='none'/>
+ </devices>
+ <seclabel type='none' model='none'/>
+</domain>
--
2.27.0
2 years, 5 months
[PATCH] domain_conf: remove else after return / goto
by Kristina Hanicova
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/conf/domain_conf.c | 55 ++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 44a01ab628..bc4b74c1c8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4084,8 +4084,8 @@ virDomainObjGetPersistentDef(virDomainXMLOption *xmlopt,
if (domain->newDef)
return domain->newDef;
- else
- return domain->def;
+
+ return domain->def;
}
@@ -4223,8 +4223,8 @@ virDomainObjGetOneDefState(virDomainObj *vm,
if (virDomainObjIsActive(vm) && flags & VIR_DOMAIN_AFFECT_CONFIG)
return vm->newDef;
- else
- return vm->def;
+
+ return vm->def;
}
@@ -6029,7 +6029,9 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
VIR_XML_PROP_NONZERO,
&scsisrc->sgio)) < 0) {
return -1;
- } else if (rv > 0) {
+ }
+
+ if (rv > 0) {
if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("sgio is only supported for scsi host device"));
@@ -6041,8 +6043,9 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
VIR_XML_PROP_NONE,
&scsisrc->rawio)) < 0) {
return -1;
- } else if (rv > 0 &&
- def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
+ }
+
+ if (rv > 0 && def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("rawio is only supported for scsi host device"));
return -1;
@@ -8056,15 +8059,15 @@ virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
{
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
return virDomainControllerModelSCSITypeFromString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
return virDomainControllerModelUSBTypeFromString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
return virDomainControllerModelPCITypeFromString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
return virDomainControllerModelIDETypeFromString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
return virDomainControllerModelVirtioSerialTypeFromString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA)
return virDomainControllerModelISATypeFromString(model);
return -1;
@@ -8077,15 +8080,15 @@ virDomainControllerModelTypeToString(virDomainControllerDef *def,
{
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
return virDomainControllerModelSCSITypeToString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB)
return virDomainControllerModelUSBTypeToString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
return virDomainControllerModelPCITypeToString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
return virDomainControllerModelIDETypeToString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
return virDomainControllerModelVirtioSerialTypeToString(model);
- else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA)
+ if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA)
return virDomainControllerModelISATypeToString(model);
return NULL;
@@ -9915,9 +9918,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def,
ctxt->node = cur;
- if ((nsources = virXPathNodeSet("./source", ctxt, &sources)) < 0) {
+ if ((nsources = virXPathNodeSet("./source", ctxt, &sources)) < 0)
goto error;
- } else if (nsources > 0) {
+
+ if (nsources > 0) {
/* Parse only the first source element since only one is used
* for chardev devices, the only exception is UDP type, where
* user can specify two source elements. */
@@ -9926,7 +9930,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def,
_("only one source element is allowed for "
"character device"));
goto error;
- } else if (nsources > 2) {
+ }
+ if (nsources > 2) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("only two source elements are allowed for "
"character device"));
@@ -10006,9 +10011,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def,
}
}
- if ((nlogs = virXPathNodeSet("./log", ctxt, &logs)) < 0) {
+ if ((nlogs = virXPathNodeSet("./log", ctxt, &logs)) < 0)
goto error;
- } else if (nlogs == 1) {
+
+ if (nlogs == 1) {
if (virDomainChrSourceDefParseLog(def, logs[0]) < 0)
goto error;
} else if (nlogs > 1) {
@@ -10018,9 +10024,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def,
goto error;
}
- if ((nprotocols = virXPathNodeSet("./protocol", ctxt, &protocols)) < 0) {
+ if ((nprotocols = virXPathNodeSet("./protocol", ctxt, &protocols)) < 0)
goto error;
- } else if (nprotocols == 1) {
+
+ if (nprotocols == 1) {
if (virDomainChrSourceDefParseProtocol(def, protocols[0]) < 0)
goto error;
} else if (nprotocols > 1) {
--
2.35.3
2 years, 5 months
[PATCH] schemas: Update ref acpi for devices
by Han Han
According to a9fe9569ab, the <acpi index='NNN'/> is only for PCI
devices. Remove the ref acpi from devices channel, smartcard, tpm,
redirdev, panic, hub because none of them has PCI address. And add the
ref acpi to iommu device.
Fixes: a9fe9569ab
Signed-off-by: Han Han <hhan(a)redhat.com>
---
src/conf/schemas/domaincommon.rng | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index faa2561665..2f07c25430 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -5409,9 +5409,6 @@
<optional>
<ref name="alias"/>
</optional>
- <optional>
- <ref name="acpi"/>
- </optional>
<optional>
<ref name="address"/>
</optional>
@@ -5453,9 +5450,6 @@
</interleave>
</group>
</choice>
- <optional>
- <ref name="alias"/>
- </optional>
<optional>
<ref name="acpi"/>
</optional>
@@ -5486,9 +5480,6 @@
<optional>
<ref name="alias"/>
</optional>
- <optional>
- <ref name="acpi"/>
- </optional>
<optional>
<ref name="address"/>
</optional>
@@ -5661,6 +5652,9 @@
</optional>
</element>
</optional>
+ <optional>
+ <ref name="acpi"/>
+ </optional>
<optional>
<ref name="address"/>
</optional>
@@ -5772,9 +5766,6 @@
<optional>
<ref name="alias"/>
</optional>
- <optional>
- <ref name="acpi"/>
- </optional>
<optional>
<ref name="address"/>
</optional>
@@ -5794,9 +5785,6 @@
<optional>
<ref name="alias"/>
</optional>
- <optional>
- <ref name="acpi"/>
- </optional>
<optional>
<ref name="address"/>
</optional>
@@ -8048,9 +8036,6 @@
<optional>
<ref name="alias"/>
</optional>
- <optional>
- <ref name="acpi"/>
- </optional>
<optional>
<ref name="address"/>
</optional>
--
2.37.1
2 years, 5 months
[PATCH] domain_conf: rewrite if else condition
by Kristina Hanicova
This patch prevents nesting of if conditions and makes the code
cleaner.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/conf/domain_conf.c | 50 +++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 44a01ab628..6b81c61056 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5309,18 +5309,18 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
{
g_autofree char *type = virXMLPropString(address, "type");
- if (type) {
- if ((info->type = virDomainDeviceAddressTypeFromString(type)) <= 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown address type '%s'"), type);
- return -1;
- }
- } else {
+ if (!type) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("No type specified for device address"));
return -1;
}
+ if ((info->type = virDomainDeviceAddressTypeFromString(type)) <= 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown address type '%s'"), type);
+ return -1;
+ }
+
switch ((virDomainDeviceAddressType) info->type) {
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
if (virPCIDeviceAddressParseXML(address, &info->addr.pci) < 0)
@@ -5996,20 +5996,20 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
* <hostdev>. (the functions we're going to call expect address
* type to already be known).
*/
- if (type) {
- if ((def->source.subsys.type
- = virDomainHostdevSubsysTypeFromString(type)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown host device source address type '%s'"),
- type);
- return -1;
- }
- } else {
+ if (!type) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("missing source address type"));
return -1;
}
+ if ((def->source.subsys.type
+ = virDomainHostdevSubsysTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown host device source address type '%s'"),
+ type);
+ return -1;
+ }
+
if (!(sourcenode = virXPathNode("./source", ctxt))) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <source> element in hostdev device"));
@@ -6304,20 +6304,20 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
* <hostdev>. (the functions we're going to call expect address
* type to already be known).
*/
- if (type) {
- if ((def->source.caps.type
- = virDomainHostdevCapsTypeFromString(type)) < 0) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown host device source address type '%s'"),
- type);
- return -1;
- }
- } else {
+ if (!type) {
virReportError(VIR_ERR_XML_ERROR,
"%s", _("missing source address type"));
return -1;
}
+ if ((def->source.caps.type
+ = virDomainHostdevCapsTypeFromString(type)) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown host device source address type '%s'"),
+ type);
+ return -1;
+ }
+
if (!virXPathNode("./source", ctxt)) {
virReportError(VIR_ERR_XML_ERROR, "%s",
_("Missing <source> element in hostdev device"));
--
2.35.3
2 years, 5 months
[PATCH 0/5] hypervisor: move job object into hypervisor
by Kristina Hanicova
This series moves generalized qemu job object into hypervisor/ and
replaces all other hypervisor-specific job objects.
Kristina Hanicova (5):
qemu & hypervisor: move job object into hypervisor
hypervisor: domain_job: rename members in
virDomainObjPrivateJobCallbacks
LXC: use virDomainJobObj
libxl: use virDomainJobObj
CH: use virDomainJobObj
src/ch/ch_domain.c | 4 +-
src/ch/ch_domain.h | 9 +----
src/hypervisor/domain_job.h | 62 ++++++++++++++++++++++++++++++
src/libxl/libxl_domain.c | 6 +--
src/libxl/libxl_domain.h | 11 +-----
src/lxc/lxc_domain.c | 4 +-
src/lxc/lxc_domain.h | 9 +----
src/qemu/qemu_domain.c | 10 ++---
src/qemu/qemu_domain.h | 2 +-
src/qemu/qemu_domainjob.c | 26 ++++++-------
src/qemu/qemu_domainjob.h | 66 +++-----------------------------
src/qemu/qemu_migration.c | 2 +-
src/qemu/qemu_migration.h | 2 +-
src/qemu/qemu_migration_params.c | 2 +-
src/qemu/qemu_process.c | 12 +++---
15 files changed, 106 insertions(+), 121 deletions(-)
--
2.35.3
2 years, 5 months
[PATCH] hypervisor: domain_job: add and edit description
by Kristina Hanicova
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/hypervisor/domain_job.c | 2 ++
src/hypervisor/domain_job.h | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/hypervisor/domain_job.c b/src/hypervisor/domain_job.c
index 5939d93e47..6a0fbd42b3 100644
--- a/src/hypervisor/domain_job.c
+++ b/src/hypervisor/domain_job.c
@@ -1,4 +1,6 @@
/*
+ * domain_job.c: job functions shared between hypervisor drivers
+ *
* Copyright (C) 2022 Red Hat, Inc.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
diff --git a/src/hypervisor/domain_job.h b/src/hypervisor/domain_job.h
index 30f950ec23..b12e0c8e17 100644
--- a/src/hypervisor/domain_job.h
+++ b/src/hypervisor/domain_job.h
@@ -1,4 +1,6 @@
/*
+ * domain_job.h: job functions shared between hypervisor drivers
+ *
* Copyright (C) 2022 Red Hat, Inc.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
@@ -122,7 +124,8 @@ struct _virDomainJobData {
char *errmsg; /* optional error message for failed completed jobs */
void *privateData; /* private data of hypervisors */
- virDomainJobDataPrivateDataCallbacks *privateDataCb; /* callbacks of private data, hypervisor based */
+ virDomainJobDataPrivateDataCallbacks *privateDataCb; /* callbacks of private data,
+ hypervisor based */
};
--
2.35.3
2 years, 5 months
[PATCH] qemu: domainjob: remove async variable from qemuDomainObjBeginJobInternal()
by Kristina Hanicova
This patch removes variable 'async', which is used only once, and
replaces it with direct comparison with an enum member.
Signed-off-by: Kristina Hanicova <khanicov(a)redhat.com>
---
src/qemu/qemu_domainjob.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domainjob.c b/src/qemu/qemu_domainjob.c
index 1f6d976558..7c6b697959 100644
--- a/src/qemu/qemu_domainjob.c
+++ b/src/qemu/qemu_domainjob.c
@@ -875,7 +875,6 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver,
unsigned long long now;
unsigned long long then;
bool nested = job == VIR_JOB_ASYNC_NESTED;
- bool async = job == VIR_JOB_ASYNC;
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
const char *blocker = NULL;
const char *agentBlocker = NULL;
@@ -903,7 +902,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriver *driver,
then = now + QEMU_JOB_WAIT_TIME;
retry:
- if ((!async && job != VIR_JOB_DESTROY) &&
+ if (job != VIR_JOB_ASYNC &&
+ job != VIR_JOB_DESTROY &&
cfg->maxQueuedJobs &&
priv->job.jobsQueued > cfg->maxQueuedJobs) {
goto error;
--
2.35.3
2 years, 5 months
[libvirt PATCH] nodedev: support 'mtty' device for testing
by Jonathon Jongsma
It would be nice to be able to test the mediated device capabilities
without having physical hardware which supports it. The 'mtty' kernel
module presents a virtual parent device which is capable of creating
'fake' mediated devices, and as such it would be useful for testing.
However, the 'mtty' device is not part of an existing device subsystem
(e.g. PCI, etc), so libvirt ignores it and it does not get added to the
node device list. And because it does not get added to the node device
list, it cannot be used to create child mdevs using `virsh
nodedev-create`.
There is already a node device type capability
VIR_NODE_DEV_CAP_MDEV_TYPES that indicates whether a device supports
creating child mediated devices, but libvirt assumes that this is a
nested capability (in other words, it assumes that the primary
capability of a device is something like PCI). If we allow this
MDEV_TYPES capability to be a primary device capability, then we can
support virtual devices like 'mtty' as a parent for mediated devices.
See https://bugzilla.redhat.com/show_bug.cgi?id=2107031
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/conf/node_device_conf.c | 41 +++++++++++++++++++++++++++-
src/conf/node_device_conf.h | 13 +++++++++
src/libvirt_private.syms | 2 ++
src/node_device/node_device_driver.c | 5 +++-
src/node_device/node_device_udev.c | 25 +++++++++++++++++
src/util/virmdev.c | 28 +++++++++++++++++++
src/util/virmdev.h | 4 +++
7 files changed, 116 insertions(+), 2 deletions(-)
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 364bb489bd..d5bfc098b2 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -772,6 +772,10 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
data->ap_matrix.nmdev_types);
break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
+ virNodeDeviceCapMdevTypesFormat(&buf,
+ data->mdev_parent.mdev_types,
+ data->mdev_parent.nmdev_types);
+ break;
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_VPD:
@@ -2674,6 +2678,11 @@ virNodeDevCapsDefFree(virNodeDevCapsDef *caps)
g_free(data->ap_matrix.mdev_types);
break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
+ for (i = 0; i < data->mdev_parent.nmdev_types; i++)
+ virMediatedDeviceTypeFree(data->mdev_parent.mdev_types[i]);
+ g_free(data->mdev_parent.mdev_types);
+ g_free(data->mdev_parent.address);
+ break;
case VIR_NODE_DEV_CAP_DRM:
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
@@ -2729,6 +2738,11 @@ virNodeDeviceUpdateCaps(virNodeDeviceDef *def)
&cap->data.ap_matrix) < 0)
return -1;
break;
+ case VIR_NODE_DEV_CAP_MDEV_TYPES:
+ if (virNodeDeviceGetMdevParentDynamicCaps(def->sysfs_path,
+ &cap->data.mdev_parent) < 0)
+ return -1;
+ break;
/* all types that (supposedly) don't require any updates
* relative to what's in the cache.
@@ -2742,7 +2756,6 @@ virNodeDeviceUpdateCaps(virNodeDeviceDef *def)
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_SCSI_GENERIC:
- case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_CCW_DEV:
case VIR_NODE_DEV_CAP_VDPA:
@@ -3193,6 +3206,24 @@ virNodeDeviceGetAPMatrixDynamicCaps(const char *sysfsPath,
return 0;
}
+/* virNodeDeviceGetMdevParentDynamicCaps() get info that is stored in sysfs
+ * about devices related to this device, i.e. things that can change
+ * without this device itself changing. These must be refreshed
+ * anytime full XML of the device is requested, because they can
+ * change with no corresponding notification from the kernel/udev.
+ */
+int
+virNodeDeviceGetMdevParentDynamicCaps(const char *sysfsPath,
+ virNodeDevCapMdevParent *mdev_parent)
+{
+ if (virNodeDeviceGetMdevTypesCaps(sysfsPath,
+ &mdev_parent->mdev_types,
+ &mdev_parent->nmdev_types) < 0)
+ return -1;
+ return 0;
+}
+
+
#else
int
@@ -3229,4 +3260,12 @@ virNodeDeviceGetAPMatrixDynamicCaps(const char *sysfsPath G_GNUC_UNUSED,
return -1;
}
+int
+virNodeDeviceGetMdevParentDynamicCaps(const char *sysfsPath G_GNUC_UNUSED,
+ virNodeDevCapMdevParent *mdev_parent G_GNUC_UNUSED)
+{
+ return -1;
+}
+
+
#endif /* __linux__ */
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index a234b4147b..21622c62ac 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -306,6 +306,14 @@ struct _virNodeDevCapAPMatrix {
size_t nmdev_types;
};
+
+typedef struct _virNodeDevCapMdevParent virNodeDevCapMdevParent;
+struct _virNodeDevCapMdevParent {
+ virMediatedDeviceType **mdev_types;
+ size_t nmdev_types;
+ char *address;
+};
+
typedef struct _virNodeDevCapData virNodeDevCapData;
struct _virNodeDevCapData {
virNodeDevCapType type;
@@ -327,6 +335,7 @@ struct _virNodeDevCapData {
virNodeDevCapAPCard ap_card;
virNodeDevCapAPQueue ap_queue;
virNodeDevCapAPMatrix ap_matrix;
+ virNodeDevCapMdevParent mdev_parent;
};
};
@@ -453,6 +462,10 @@ int
virNodeDeviceGetAPMatrixDynamicCaps(const char *sysfsPath,
virNodeDevCapAPMatrix *ap_matrix);
+int
+virNodeDeviceGetMdevParentDynamicCaps(const char *sysfsPath,
+ virNodeDevCapMdevParent *mdev_parent);
+
int
virNodeDeviceUpdateCaps(virNodeDeviceDef *def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f4732f1742..1a5fce22e5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -866,6 +866,7 @@ virNodeDeviceDefParseNode;
virNodeDeviceDefParseString;
virNodeDeviceGetAPMatrixDynamicCaps;
virNodeDeviceGetCSSDynamicCaps;
+virNodeDeviceGetMdevParentDynamicCaps;
virNodeDeviceGetPCIDynamicCaps;
virNodeDeviceGetSCSIHostCaps;
virNodeDeviceGetSCSITargetCaps;
@@ -2723,6 +2724,7 @@ virMediatedDeviceListStealIndex;
virMediatedDeviceModelTypeFromString;
virMediatedDeviceModelTypeToString;
virMediatedDeviceNew;
+virMediatedDeviceParentGetAddress;
virMediatedDeviceSetUsedBy;
virMediatedDeviceTypeFree;
virMediatedDeviceTypeReadAttrs;
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 0178ae8b66..fa3cfcf24c 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -672,6 +672,10 @@ nodeDeviceObjFormatAddress(virNodeDeviceObj *obj)
addr = g_strdup(caps->data.ap_matrix.addr);
break;
+ case VIR_NODE_DEV_CAP_MDEV_TYPES:
+ addr = g_strdup(caps->data.mdev_parent.address);
+ break;
+
case VIR_NODE_DEV_CAP_SYSTEM:
case VIR_NODE_DEV_CAP_USB_DEV:
case VIR_NODE_DEV_CAP_USB_INTERFACE:
@@ -684,7 +688,6 @@ nodeDeviceObjFormatAddress(virNodeDeviceObj *obj)
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_SCSI_GENERIC:
case VIR_NODE_DEV_CAP_DRM:
- case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_CCW_DEV:
case VIR_NODE_DEV_CAP_VDPA:
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 3d69bdedae..e76c1a36b8 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -457,6 +457,28 @@ udevProcessPCI(struct udev_device *device,
}
+static int
+udevProcessMdevParent(struct udev_device *device,
+ virNodeDeviceDef *def)
+{
+ virNodeDevCapMdevParent *mdev_parent = &def->caps->data.mdev_parent;
+
+ udevGenerateDeviceName(device, def, NULL);
+
+ if (virMediatedDeviceParentGetAddress(def->sysfs_path, &mdev_parent->address) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to find address for mdev parent device '%s'"),
+ def->name);
+ return -1;
+ }
+
+ if (virNodeDeviceGetMdevParentDynamicCaps(def->sysfs_path, mdev_parent) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
drmGetMinorType(int minor)
{
@@ -1349,6 +1371,8 @@ udevGetDeviceType(struct udev_device *device,
*type = VIR_NODE_DEV_CAP_VDPA;
else if (STREQ_NULLABLE(subsystem, "matrix"))
*type = VIR_NODE_DEV_CAP_AP_MATRIX;
+ else if (STREQ_NULLABLE(subsystem, "mtty"))
+ *type = VIR_NODE_DEV_CAP_MDEV_TYPES;
VIR_FREE(subsystem);
}
@@ -1404,6 +1428,7 @@ udevGetDeviceDetails(struct udev_device *device,
case VIR_NODE_DEV_CAP_AP_MATRIX:
return udevProcessAPMatrix(device, def);
case VIR_NODE_DEV_CAP_MDEV_TYPES:
+ return udevProcessMdevParent(device, def);
case VIR_NODE_DEV_CAP_VPD:
case VIR_NODE_DEV_CAP_SYSTEM:
case VIR_NODE_DEV_CAP_FC_HOST:
diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index eb566982b1..41d4cef8b9 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -520,6 +520,34 @@ void virMediatedDeviceAttrFree(virMediatedDeviceAttr *attr)
}
+#define MDEV_BUS_DIR "/sys/class/mdev_bus"
+
+
+int
+virMediatedDeviceParentGetAddress(const char *sysfspath,
+ char **address)
+{
+ g_autoptr(DIR) dir = NULL;
+ struct dirent *entry;
+ if (virDirOpen(&dir, MDEV_BUS_DIR) < 0)
+ return -1;
+
+ /* check if one of the links in /sys/class/mdev_bus/ points at the sysfs
+ * path for this device. If so, the link name is treated as the 'address'
+ * for the mdev parent */
+ while (virDirRead(dir, &entry, MDEV_BUS_DIR) > 0) {
+ g_autofree char *tmppath = g_strdup_printf("%s/%s", MDEV_BUS_DIR,
+ entry->d_name);
+
+ if (virFileLinkPointsTo(tmppath, sysfspath)) {
+ *address = g_strdup(entry->d_name);
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
#ifdef __linux__
ssize_t
diff --git a/src/util/virmdev.h b/src/util/virmdev.h
index 4d3655a091..bc8306d0e1 100644
--- a/src/util/virmdev.h
+++ b/src/util/virmdev.h
@@ -149,5 +149,9 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath,
virMediatedDeviceType ***types,
size_t *ntypes);
+int
+virMediatedDeviceParentGetAddress(const char *sysfspath,
+ char **address);
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDevice, virMediatedDeviceFree);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceType, virMediatedDeviceTypeFree);
--
2.35.3
2 years, 5 months
[libvirt PATCH v2 0/5] Ask qemu about migration blockers
by Eugenio Pérez
There are some hardcoded migration blockers in libvirt, like having a net
vhost-vdpa device. While it's true that they cannot be migrated at the moment,
there are plans to be able to migrate them soon.
They'll put a migration blockers in the cases where you cannot migrate them.
Ask qemu about then before rejecting the migration. In case the question is not
possible, assume they're not migratable.
Eugenio Pérez (4):
qemu_monitor_json: Add qemuMonitorJSONGetMigrationBlockers
qemu_monitor: add support for get qemu migration blockers
qemu_migration: get migration blockers before hardcoded checks
qemu_migrate: Do not forbif vDPA devices if can query blockers
Jonathon Jongsma (1):
qemu: introduce capability QEMU_MIGRATION_BLOCKED_REASONS
src/qemu/qemu_capabilities.c | 2 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_migration.c | 38 ++++++++++++++++++-
src/qemu/qemu_monitor.c | 11 ++++++
src/qemu/qemu_monitor.h | 4 ++
src/qemu/qemu_monitor_json.c | 35 +++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 ++
.../caps_6.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_6.0.0.s390x.xml | 1 +
.../caps_6.0.0.x86_64.xml | 1 +
.../caps_6.1.0.x86_64.xml | 1 +
.../caps_6.2.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_6.2.0.ppc64.xml | 1 +
.../caps_6.2.0.x86_64.xml | 1 +
.../caps_7.0.0.aarch64.xml | 1 +
.../qemucapabilitiesdata/caps_7.0.0.ppc64.xml | 1 +
.../caps_7.0.0.x86_64.xml | 1 +
.../caps_7.1.0.x86_64.xml | 1 +
18 files changed, 104 insertions(+), 1 deletion(-)
--
2.31.1
2 years, 5 months