[PATCH 0/5] Implement some IOThread related APIs for test driver
by Luke Yue
- Implement virDomainAddIOThread
- Implement virDomainDelIOThread
- Implement virDomainGetIOThreadInfo
- Add tests for these APIs
Luke Yue (5):
conf: domain: Introduce and use virDomainAddIOThreadCheck()
test_driver: Implement virDomainAddIOThread and virDomainDelIOThread
conf: domain: Introduce and use virDomainGetIOThreadsConfig()
test_driver: Implement virDomainGetIOThreadInfo
tests: Test IOThread related functions for test driver
examples/xml/test/testdomfc4.xml | 4 +
src/conf/domain_conf.c | 126 +++++++++++++++++++++
src/conf/domain_conf.h | 12 ++
src/libvirt_private.syms | 3 +
src/qemu/qemu_driver.c | 113 +------------------
src/test/test_driver.c | 186 +++++++++++++++++++++++++++++++
tests/virshtest.c | 40 +++++++
7 files changed, 376 insertions(+), 108 deletions(-)
--
2.32.0
3 years, 5 months
[libvirt PATCH 00/10] virHashNew refactorings
by Tim Wiederhake
"virHashNew" cannot return NULL, yet we check for NULL in various places.
This series is the first of several that remove these checks. Where
applicable, the functions are refactored to use automatic memory management
by means of g_autoptr etc. as well.
Tim Wiederhake (10):
qemuMonitorGetAllBlockStatsInfo: Clean up line break
qemuMonitorGetAllBlockStatsInfo: Remove superfluous variable
initialization
qemuMonitorGetAllBlockStatsInfo: Assign hash table only on success
qemuMonitorGetAllBlockStatsInfo: Use automatic memory management
qemuMonitorGetBlockInfo: Remove superfluous variable "ret"
qemuMonitorGetBlockInfo: Use automatic memory management
qemuMonitorGetBlockInfo: `virHashNew` cannot return NULL
qemuMonitorGetChardevInfo: Remove superfluous variable "ret"
qemuMonitorGetChardevInfo: Use automatic memory management
qemuMonitorGetChardevInfo: `virHashNew` cannot return NULL
src/qemu/qemu_monitor.c | 54 ++++++++++++-----------------------------
1 file changed, 16 insertions(+), 38 deletions(-)
--
2.31.1
3 years, 5 months
crash in virQEMUCapsProbeQMPTPM
by Olaf Hering
I got a couple of "g_strv_contains: assertion 'strv != NULL' failed" in the past days.
It seems qemuMonitorGetTPMModels can write NULL into "models" in "virQEMUCapsProbeQMPTPM()".
As a result g_strv_contains will crash with G_DEBUG=fatal-warnings
This is libvirt.git#15073504db and qemu.git#13d5f87cc3
Olaf
3 years, 5 months
[PATCHv2 0/4] Add qemu support setting qos via ovs on ovs interface
by zhangjl02
---
diff to v1:
- move qemuDomainDefIsOvsport from src/qemu/qemu_domain.c to
src/conf/domain_conf.c
- call virCommandFree(cmd)free cmd before reusing it.
- add g_autofree to variables.
- reduce usage of virReportError(), and coupled it with return -1.
- fix remove port qos error.
- optimise code structure.
Thanks to Michal Privoznik for helping reviewing these patches.
Now libvirt use tc rules to manage interface's qos. But when an interface
is created by ovs, there is no qos setting result in ovs database. Therefore,
qos of ovs port should be set via ovs management command.
We add a function to tell whether a port definition is an ovs managed virtual
port. Change default qdisc rules, which return 0 directly if the port is ovs
managed(When the ovs port is set noqueue, qos config on this port will not
work). Add ovs management function of setting and cleaning qos. Then check if
the port is an ovs managed port during its life cycle, and call the ovs
management function to set or clean qos settings.
zhangjl02 (4):
virDomain: interface: add virDomainNetDefIsOvsport
virDomain: interface: add virNetDevOpenvswitchInterfaceSetQos and
virNetDevOpenvswitchInterfaceClearQos
qemu: interface: remove setting noqueue for ovs port
qemu: interface: check and use ovs command to set qos of ovs managed
port
src/conf/domain_conf.c | 8 +
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 3 +
src/qemu/qemu_command.c | 10 +-
src/qemu/qemu_domain.c | 3 +-
src/qemu/qemu_driver.c | 22 ++-
src/qemu/qemu_hotplug.c | 39 +++--
src/qemu/qemu_process.c | 10 +-
src/util/virnetdevopenvswitch.c | 271 ++++++++++++++++++++++++++++++++
src/util/virnetdevopenvswitch.h | 11 ++
10 files changed, 362 insertions(+), 17 deletions(-)
--
2.30.2.windows.1
3 years, 5 months
[PATCH] domstats:add haltpolling time statistic interface
by Yang Fei
This patch add the ability to statistic the halt polling time when
VM execute HLT(arm is WFI).
In actual services, the execution of the HLT instruction by the
guest is an important cause of virtualization overhead. The halt
polling feature is introduced to solve this problem. When a guest
idle VM exit occurs, the host continues polling for a period of
time to reduce the guest service delay. This mechanism may cause
the CPU usage to be 100% when the physical CPU is idle. If the
guest service model is woken up at an interval to process a small
amount of traffic, and the interval is shorter than kvm halt_poll_ns.
The host polls the block time of the entire VM and the CPU usage
increases to 100%.
The kernel provides the capability of collecting statistics on the
halt polling time after v5.8, Introduced by commit
<cb953129bfe5c0f2da835a0469930873fb7e71df>. It is rendered in debugfs.
Therefore, we can use this kernel feature to provide the halt poll
time to the user to obtain a more accurate CPU usage as required.
Signed-off-by: Yang Fei <yangfei85(a)huawei.com>
---
src/libvirt_private.syms | 2 +
src/qemu/qemu_driver.c | 29 +++++++++++++
src/util/virutil.c | 89 ++++++++++++++++++++++++++++++++++++++++
src/util/virutil.h | 9 ++++
4 files changed, 129 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 68e4b6aab8..f92213b8c2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3479,6 +3479,8 @@ virDoesUserExist;
virDoubleToStr;
virFormatIntDecimal;
virFormatIntPretty;
+virGetCpuHaltPollTime;
+virGetDebugFsKvmValue;
virGetDeviceID;
virGetDeviceUnprivSGIO;
virGetGroupID;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 235f575901..3a2b530ecf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17812,6 +17812,32 @@ qemuDomainGetStatsCpuCache(virQEMUDriver *driver,
return ret;
}
+#ifdef __linux__
+static int
+qemuDomainGetStatsCpuHaltPollTime(virDomainObj *dom,
+ virTypedParamList *params)
+{
+ unsigned long long haltPollSuccess = 0;
+ unsigned long long haltPollFail = 0;
+ pid_t pid = dom->pid;
+
+ if (virGetCpuHaltPollTime(pid, &haltPollSuccess, &haltPollFail) != 0)
+ return -1;
+ if (virTypedParamListAddULLong(params, haltPollSuccess, "haltpollsuccess.time") < 0)
+ return -1;
+ if (virTypedParamListAddULLong(params, haltPollFail, "haltpollfail.time") < 0)
+ return -1;
+
+ return 0;
+}
+#else
+static int
+qemuDomainGetStatsCpuHaltPollTime(virDomainObj *dom,
+ virTypedParamList *params)
+{
+ return -1;
+}
+#endif
static int
qemuDomainGetStatsCpuCgroup(virDomainObj *dom,
@@ -17852,6 +17878,9 @@ qemuDomainGetStatsCpu(virQEMUDriver *driver,
if (qemuDomainGetStatsCpuCache(driver, dom, params) < 0)
return -1;
+ if (qemuDomainGetStatsCpuHaltPollTime(dom, params) < 0)
+ return -1;
+
return 0;
}
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 311cbbf93a..8715deaca5 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1936,3 +1936,92 @@ virPipeNonBlock(int fds[2])
{
return virPipeImpl(fds, true, true);
}
+
+int
+virGetDebugFsKvmValue(struct dirent *ent,
+ const char *path,
+ const char *filename,
+ unsigned long long *value)
+{
+ g_autofree char *valToStr = NULL;
+ g_autofree char *valPath = NULL;
+ int rc = -1;
+ int ret = -1;
+
+ valPath = g_strdup_printf("%s/%s/%s", path, ent->d_name, filename);
+
+ if ((rc = virFileReadAll(valPath, 16, &valToStr)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to read from '%s'"), valPath);
+ goto cleanup;
+ }
+
+ /* Terminated with '\n' has sometimes harmful effects to the caller */
+ if (rc > 0 && (valToStr)[rc - 1] == '\n')
+ (valToStr)[rc - 1] = '\0';
+
+ /* 10 is a Cardinality, must be between 2 and 36 inclusive,
+ * or special value 0. Used in fuction strtoull()
+ */
+ if (virStrToLong_ull(valToStr, NULL, 10, value) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to parse '%s' as an integer"), valToStr);
+ goto cleanup;
+ }
+
+ ret = 0;
+cleanup:
+ return ret;
+}
+
+int
+virGetCpuHaltPollTime(pid_t pid,
+ unsigned long long *haltPollSuccess,
+ unsigned long long *haltPollFail)
+{
+ g_autofree char *pidToStr = NULL;
+ g_autofree char *debugFsPath = NULL;
+ g_autofree char *completePath = NULL;
+ struct dirent *ent = NULL;
+ DIR *dir = NULL;
+ int ret = -1;
+ int flag = 0;
+
+ if (!(debugFsPath = virFileFindMountPoint("debugfs"))) {
+ virReportSystemError(errno, "%s",
+ _("unable to find debugfs mountpoint"));
+ goto cleanup;
+ }
+
+ completePath = g_strdup_printf("%s/%s", debugFsPath, "kvm");
+ if (virDirOpen(&dir, completePath) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "%s %s", "Can not open directory", completePath);
+ return ret;
+ }
+
+ pidToStr = g_strdup_printf("%d", pid);
+ while (virDirRead(dir, &ent, NULL) > 0) {
+ if (strncmp(ent->d_name, pidToStr, strlen(pidToStr)) == 0 &&
+ ent->d_name[strlen(pidToStr)] == '-') {
+ flag = 1;
+ break;
+ }
+ }
+
+ if (flag == 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not find VM(Pid %s) in '%s'"), pidToStr, completePath);
+ goto cleanup;
+ }
+
+ if (virGetDebugFsKvmValue(ent, completePath, "halt_poll_success_ns", haltPollSuccess) < 0 ||
+ virGetDebugFsKvmValue(ent, completePath, "halt_poll_fail_ns", haltPollFail) < 0) {
+ goto cleanup;
+ }
+
+ ret = 0;
+cleanup:
+ closedir(dir);
+ return ret;
+}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 854b494890..b3c1e8a0bc 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -225,3 +225,12 @@ int virPipeQuiet(int fds[2]);
* Returns: -1 on error, 0 on success
*/
int virPipeNonBlock(int fds[2]);
+
+int virGetDebugFsKvmValue(struct dirent *ent,
+ const char *path,
+ const char *filename,
+ unsigned long long *value);
+
+int virGetCpuHaltPollTime(pid_t pid,
+ unsigned long long *haltPollSuccess,
+ unsigned long long *haltPollFail);
--
2.23.0
3 years, 5 months
[PATCH 0/3] Threshold event improvements
by Peter Krempa
Peter Krempa (3):
storage_source: Add flag storing whether threshold event was
registered with index
qemu: Prevent two threshold events when it was registered with index
virDomainSetBlockThreshold: Document that two events are fired when
index isn't used
src/conf/storage_source_conf.h | 5 +++++
src/libvirt-domain.c | 4 ++++
src/qemu/qemu_domain.c | 8 ++++++++
src/qemu/qemu_driver.c | 4 ++++
src/qemu/qemu_process.c | 3 ++-
tests/qemustatusxml2xmldata/modern-in.xml | 1 +
6 files changed, 24 insertions(+), 1 deletion(-)
--
2.31.1
3 years, 5 months
[PATCH libvirt v1] conf: verify for duplicate hostdevs
by Shalini Chellathurai Saroja
It is possible to define/edit(in shut off state) a domain XML with
same hostdev device repeated more than once, as shown below. This
behavior is not expected. So, this patch fixes it.
vser1:
<domain type='kvm'>
[...]
<devices>
[...]
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
<source>
<address uuid='8e782fea-e5f4-45fa-a0f9-024cf66e5009'/>
</source>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0005'/>
</hostdev>
<hostdev mode='subsystem' type='mdev' managed='no' model='vfio-ccw'>
<source>
<address uuid='8e782fea-e5f4-45fa-a0f9-024cf66e5009'/>
</source>
<address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0006'/>
</hostdev>
[...]
</devices>
</domain>
$ virsh define vser1
Domain 'vser1' defined from vser1
Signed-off-by: Shalini Chellathurai Saroja <shalini(a)linux.ibm.com>
Reviewed-by: Bjoern Walk <bwalk(a)linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 2 +
src/conf/domain_validate.c | 21 ++++++++++
src/libvirt_private.syms | 1 +
.../hostdev-mdev-duplicate.err | 1 +
.../hostdev-mdev-duplicate.xml | 41 +++++++++++++++++++
.../hostdev-pci-duplicate.err | 1 +
.../hostdev-pci-duplicate.xml | 40 ++++++++++++++++++
.../hostdev-scsi-duplicate.err | 1 +
.../hostdev-scsi-duplicate.xml | 40 ++++++++++++++++++
.../hostdev-usb-duplicate.err | 1 +
.../hostdev-usb-duplicate.xml | 40 ++++++++++++++++++
tests/qemuxml2argvtest.c | 8 ++++
13 files changed, 198 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-duplicate.err
create mode 100644 tests/qemuxml2argvdata/hostdev-mdev-duplicate.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-pci-duplicate.err
create mode 100644 tests/qemuxml2argvdata/hostdev-pci-duplicate.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-scsi-duplicate.err
create mode 100644 tests/qemuxml2argvdata/hostdev-scsi-duplicate.xml
create mode 100644 tests/qemuxml2argvdata/hostdev-usb-duplicate.err
create mode 100644 tests/qemuxml2argvdata/hostdev-usb-duplicate.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f65509d8..5746f69e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15369,7 +15369,7 @@ virDomainHostdevMatchCaps(virDomainHostdevDef *a,
}
-static int
+int
virDomainHostdevMatch(virDomainHostdevDef *a,
virDomainHostdevDef *b)
{
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f706c498..4d9d499b 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3590,6 +3590,8 @@ virDomainHostdevDef *
virDomainHostdevRemove(virDomainDef *def, size_t i);
int virDomainHostdevFind(virDomainDef *def, virDomainHostdevDef *match,
virDomainHostdevDef **found);
+int virDomainHostdevMatch(virDomainHostdevDef *a,
+ virDomainHostdevDef *b);
virDomainGraphicsListenDef *
virDomainGraphicsGetListen(virDomainGraphicsDef *def, size_t i);
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 2124d25d..df2ab473 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -1068,7 +1068,25 @@ virDomainDefDuplicateDiskInfoValidate(const virDomainDef *def)
return 0;
}
+static int
+virDomainDefDuplicateHostdevInfoValidate(const virDomainDef *def)
+{
+ size_t i;
+ size_t j;
+ for (i = 0; i < def->nhostdevs; i++) {
+ for (j = i + 1; j < def->nhostdevs; j++) {
+ if (virDomainHostdevMatch(def->hostdevs[i],
+ def->hostdevs[j])) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("Hostdev already exists in the domain configuration"));
+ return -1;
+ }
+ }
+ }
+
+ return 0;
+}
/**
* virDomainDefDuplicateDriveAddressesValidate:
@@ -1529,6 +1547,9 @@ virDomainDefValidateInternal(const virDomainDef *def,
if (virDomainDefDuplicateDiskInfoValidate(def) < 0)
return -1;
+ if (virDomainDefDuplicateHostdevInfoValidate(def) < 0)
+ return -1;
+
if (virDomainDefDuplicateDriveAddressesValidate(def) < 0)
return -1;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 2efa7876..f0d1b7b4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -457,6 +457,7 @@ virDomainHostdevDefFree;
virDomainHostdevDefNew;
virDomainHostdevFind;
virDomainHostdevInsert;
+virDomainHostdevMatch;
virDomainHostdevModeTypeToString;
virDomainHostdevRemove;
virDomainHostdevSubsysPCIBackendTypeToString;
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-duplicate.err b/tests/qemuxml2argvdata/hostdev-mdev-duplicate.err
new file mode 100644
index 00000000..590afd30
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-duplicate.err
@@ -0,0 +1 @@
+XML error: Hostdev already exists in the domain configuration
diff --git a/tests/qemuxml2argvdata/hostdev-mdev-duplicate.xml b/tests/qemuxml2argvdata/hostdev-mdev-duplicate.xml
new file mode 100644
index 00000000..1c5e3263
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-mdev-duplicate.xml
@@ -0,0 +1,41 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <controller type='usb' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
+ </controller>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <audio id='1' type='none'/>
+ <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+ </hostdev>
+ <hostdev mode='subsystem' type='mdev' managed='no' model='vfio-pci'>
+ <source>
+ <address uuid='53764d0e-85a0-42b4-af5c-2046b460b1dc'/>
+ </source>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
+ </hostdev>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-pci-duplicate.err b/tests/qemuxml2argvdata/hostdev-pci-duplicate.err
new file mode 100644
index 00000000..590afd30
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-pci-duplicate.err
@@ -0,0 +1 @@
+XML error: Hostdev already exists in the domain configuration
diff --git a/tests/qemuxml2argvdata/hostdev-pci-duplicate.xml b/tests/qemuxml2argvdata/hostdev-pci-duplicate.xml
new file mode 100644
index 00000000..c744fddf
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-pci-duplicate.xml
@@ -0,0 +1,40 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <hostdev mode='subsystem' type='pci' managed='yes'>
+ <source>
+ <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='pci' managed='yes'>
+ <source>
+ <address domain='0x0000' bus='0x06' slot='0x12' function='0x5'/>
+ </source>
+ </hostdev>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-scsi-duplicate.err b/tests/qemuxml2argvdata/hostdev-scsi-duplicate.err
new file mode 100644
index 00000000..590afd30
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-scsi-duplicate.err
@@ -0,0 +1 @@
+XML error: Hostdev already exists in the domain configuration
diff --git a/tests/qemuxml2argvdata/hostdev-scsi-duplicate.xml b/tests/qemuxml2argvdata/hostdev-scsi-duplicate.xml
new file mode 100644
index 00000000..ea367de3
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-scsi-duplicate.xml
@@ -0,0 +1,40 @@
+<domain type='qemu'>
+ <name>QEMUGuest2</name>
+ <uuid>c7a5fdbd-edaf-9466-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <source dev='/dev/HostVG/QEMUGuest2'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='scsi' index='0' model='virtio-scsi'/>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host0'/>
+ <address bus='0' target='0' unit='0'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='scsi' managed='yes'>
+ <source>
+ <adapter name='scsi_host0'/>
+ <address bus='0' target='0' unit='0'/>
+ </source>
+ </hostdev>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/hostdev-usb-duplicate.err b/tests/qemuxml2argvdata/hostdev-usb-duplicate.err
new file mode 100644
index 00000000..590afd30
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-usb-duplicate.err
@@ -0,0 +1 @@
+XML error: Hostdev already exists in the domain configuration
diff --git a/tests/qemuxml2argvdata/hostdev-usb-duplicate.xml b/tests/qemuxml2argvdata/hostdev-usb-duplicate.xml
new file mode 100644
index 00000000..533a9059
--- /dev/null
+++ b/tests/qemuxml2argvdata/hostdev-usb-duplicate.xml
@@ -0,0 +1,40 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='i686' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-i386</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='ide'/>
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+ </disk>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <hostdev mode='subsystem' type='usb' managed='no'>
+ <source>
+ <address bus='14' device='6'/>
+ </source>
+ </hostdev>
+ <hostdev mode='subsystem' type='usb' managed='no'>
+ <source>
+ <address bus='14' device='6'/>
+ </source>
+ </hostdev>
+ <memballoon model='none'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7fed871c..b9f96532 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1915,8 +1915,11 @@ mymain(void)
DO_TEST("hostdev-usb-address", NONE);
DO_TEST("hostdev-usb-address-device", NONE);
DO_TEST("hostdev-usb-address-device-boot", NONE);
+ DO_TEST_PARSE_ERROR("hostdev-usb-duplicate", NONE);
DO_TEST("hostdev-pci-address", QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("hostdev-pci-address-device", QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST_PARSE_ERROR("hostdev-pci-duplicate",
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("hostdev-vfio",
QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST("hostdev-vfio-multidomain",
@@ -1927,6 +1930,8 @@ mymain(void)
QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address",
QEMU_CAPS_DEVICE_VFIO_PCI);
+ DO_TEST_PARSE_ERROR("hostdev-mdev-duplicate",
+ QEMU_CAPS_DEVICE_VFIO_PCI);
DO_TEST_CAPS_LATEST("hostdev-mdev-display-spice-opengl");
DO_TEST_CAPS_LATEST("hostdev-mdev-display-spice-egl-headless");
DO_TEST_CAPS_LATEST("hostdev-mdev-display-vnc");
@@ -2856,6 +2861,9 @@ mymain(void)
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_DEVICE_VHOST_SCSI,
QEMU_CAPS_DEVICE_PCIE_ROOT_PORT,
QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY);
+ DO_TEST_PARSE_ERROR("hostdev-scsi-duplicate",
+ QEMU_CAPS_VIRTIO_SCSI,
+ QEMU_CAPS_DEVICE_VHOST_SCSI);
DO_TEST_CAPS_VER("mlock-on", "3.0.0");
DO_TEST_CAPS_VER("mlock-off", "3.0.0");
--
2.30.2
3 years, 5 months
[libvirt PATCH v2 0/5] mdev tweaks
by Jonathon Jongsma
A few minor fixes to mdev support in the nodedev driver
Changes in v2:
- split out the error-reporting macro into a separate commit as recommended by Peter
- Since virCommandRun() may report an error, ensure that the
virMdevctl$COMMAND() functions always set an error to make error-handling
consistent. v1 tried to return an error message and have the caller report
the error.
- Added a new patch (destroying inactive device)
Jonathon Jongsma (5):
nodedev: Remove useless device name from error message
nodedev: Handle NULL command variable
nodedev: add macro to handle command errors
nodedev: handle mdevctl errors consistently
nodedev: improve error message when destroying an inactive device
src/node_device/node_device_driver.c | 147 +++++++++++++++++----------
1 file changed, 94 insertions(+), 53 deletions(-)
--
2.31.1
3 years, 5 months