[libvirt PATCH] docs: compiling: mention build dir
by Ján Tomko
Our docs have not been fully updated to reflect the separate
build directory.
Suggested-by: Laszlo Ersek <lersek(a)redhat.com>
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
docs/compiling.html.in | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/compiling.html.in b/docs/compiling.html.in
index c2c9d9f0ed..df6074780f 100644
--- a/docs/compiling.html.in
+++ b/docs/compiling.html.in
@@ -98,15 +98,17 @@ $ ninja -C build
<pre>
$ su -
# service libvirtd stop (or systemctl stop libvirtd.service)
-# /home/to/your/checkout/src/libvirtd
+# /home/to/your/checkout/build/src/libvirtd
</pre>
<p>
- It is also possible to run virsh directly from the source tree
+ It is also possible to run virsh directly from the build tree
using the ./run script (which sets some environment variables):
</p>
<pre>
+$ pwd
+/home/to/your/checkout/build
$ ./run ./tools/virsh ....
</pre>
</body>
--
2.29.2
3 years, 9 months
[libvirt PATCH] news: document virtiofs boot order
by Ján Tomko
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
NEWS.rst | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/NEWS.rst b/NEWS.rst
index 7a2d6649b4..8b8a132e41 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -18,6 +18,11 @@ v7.1.0 (unreleased)
The virtio-pmem is a virtio variant of NVDIMM and just like NVDIMM
virtio-pmem also allows accessing host pages bypassing guest page cache.
+ * Introduce ``<boot order/>`` for ``<filesystem>``
+
+ Booting is possible from virtiofs filesystems. Introduce an option
+ to control the boot order, like we do for other bootable devices.
+
* **Improvements**
* **Bug fixes**
--
2.29.2
3 years, 9 months
[libvirt PATCH 0/7] Add boot order to virtiofs
by Ján Tomko
Sadly, the replies changes for older QEMUs are synthetic.
Separated for easier review.
Also available on gitlab:
git fetch https://gitlab.com/janotomko/libvirt/ virtiofs-bootindex
https://gitlab.com/janotomko/libvirt/-/tree/virtiofs-bootindex
And a broken pipeline:
https://gitlab.com/janotomko/libvirt/-/pipelines/248162273
Ján Tomko (7):
tests: switch vhost-user-fs-hugepages to use boot order
conf: add boot order to filesystem
qemu: add QEMU_CAPS_VHOST_USER_FS_BOOTINDEX
fixup: vhost-user-fs-device properties
fixup: renumber
Add validation for virtiofs boot order setting
qemu: format bootindex for vhost-user-fs
docs/schemas/domaincommon.rng | 3 +
src/conf/domain_conf.c | 5 +-
src/conf/domain_validate.c | 17 ++-
src/qemu/qemu_capabilities.c | 8 +
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 3 +
src/qemu/qemu_validate.c | 6 +
.../caps_4.2.0.aarch64.replies | 131 ++++++++++++----
.../caps_4.2.0.s390x.replies | 119 ++++++++++++---
.../caps_4.2.0.x86_64.replies | 131 ++++++++++++----
.../caps_5.0.0.aarch64.replies | 136 +++++++++++++----
.../caps_5.0.0.ppc64.replies | 124 +++++++++++++---
.../caps_5.0.0.riscv64.replies | 120 ++++++++++++---
.../caps_5.0.0.x86_64.replies | 136 +++++++++++++----
.../caps_5.1.0.x86_64.replies | 136 +++++++++++++----
.../caps_5.2.0.aarch64.replies | 136 +++++++++++++----
.../caps_5.2.0.ppc64.replies | 124 +++++++++++++---
.../caps_5.2.0.riscv64.replies | 120 ++++++++++++---
.../caps_5.2.0.s390x.replies | 124 +++++++++++++---
.../caps_5.2.0.x86_64.replies | 136 +++++++++++++----
.../caps_6.0.0.x86_64.replies | 140 ++++++++++++++----
.../caps_6.0.0.x86_64.xml | 1 +
...vhost-user-fs-hugepages.x86_64-latest.args | 3 +-
.../vhost-user-fs-hugepages.xml | 3 +-
24 files changed, 1534 insertions(+), 329 deletions(-)
--
2.29.2
3 years, 9 months
[PATCH] conf: rename virDomainCheckVirtioOptions
by Boris Fiuczynski
Rename virDomainCheckVirtioOptions into
virDomainCheckVirtioOptionsAreAbent since it checks if all virtio
options are absent. The old name was very misleading.
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/conf/domain_validate.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index dd4c6e0fb3..a2f236c299 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -227,7 +227,7 @@ virSecurityDeviceLabelDefValidate(virSecurityDeviceLabelDefPtr *seclabels,
static int
-virDomainCheckVirtioOptions(virDomainVirtioOptionsPtr virtio)
+virDomainCheckVirtioOptionsAreAbsent(virDomainVirtioOptionsPtr virtio)
{
if (!virtio)
return 0;
@@ -316,7 +316,7 @@ virDomainDiskDefValidate(const virDomainDef *def,
return -1;
}
- if (virDomainCheckVirtioOptions(disk->virtio) < 0)
+ if (virDomainCheckVirtioOptionsAreAbsent(disk->virtio) < 0)
return -1;
}
@@ -1363,7 +1363,7 @@ virDomainNetDefValidate(const virDomainNetDef *net)
}
if (!virDomainNetIsVirtioModel(net) &&
- virDomainCheckVirtioOptions(net->virtio) < 0) {
+ virDomainCheckVirtioOptionsAreAbsent(net->virtio) < 0) {
return -1;
}
@@ -1513,7 +1513,7 @@ virDomainVsockDefValidate(const virDomainVsockDef *vsock)
}
if (!virDomainVsockIsVirtioModel(vsock) &&
- virDomainCheckVirtioOptions(vsock->virtio) < 0)
+ virDomainCheckVirtioOptionsAreAbsent(vsock->virtio) < 0)
return -1;
return 0;
--
2.26.2
3 years, 9 months
[PATCH] docs: Clarify the documentation of the <css> elements
by Thomas Huth
The channel subsystem elements describe a channel in the I/O subsystem
of a s390x machine, and not a normal device (like a disk or network card).
Reword the documentation here to make it this a little bit clearer.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1898074
Signed-off-by: Thomas Huth <thuth(a)redhat.com>
---
docs/formatnode.html.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index 1010a37a3d..8fbd3e6ece 100644
--- a/docs/formatnode.html.in
+++ b/docs/formatnode.html.in
@@ -396,15 +396,15 @@
</dl>
</dd>
<dt><code>css</code></dt>
- <dd>Describes a Channel SubSystem (CSS) device commonly found on
- the S390 architecture. Sub-elements include:
+ <dd>Describes a channel in the Channel SubSystem (CSS) commonly found
+ on the S390 architecture. Sub-elements include:
<dl>
<dt><code>cssid</code></dt>
<dd>The channel subsystem identifier.</dd>
<dt><code>ssid</code></dt>
<dd>The subchannel-set identifier.</dd>
<dt><code>devno</code></dt>
- <dd>The device number.</dd>
+ <dd>The subchannel number.</dd>
<dt><code>capability</code></dt>
<dd>
This optional element can occur multiple times. If it
--
2.27.0
3 years, 9 months
[PATCH] qemu: Add virtio related options to vsock
by Boris Fiuczynski
Add virtio related options iommu, ats and packed as driver element attributes
to vsock devices. Ex:
<vsock model='virtio'>
<cid auto='no' address='3'/>
<driver iommu='on'/>
</vsock>
Signed-off-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
docs/formatdomain.rst | 2 +
docs/schemas/domaincommon.rng | 5 +++
src/conf/domain_conf.c | 34 +++++++++++++--
src/conf/domain_conf.h | 1 +
src/qemu/qemu_command.c | 3 ++
src/qemu/qemu_validate.c | 3 ++
.../vhost-vsock-ccw-iommu.s390x-latest.args | 42 +++++++++++++++++++
.../vhost-vsock-ccw-iommu.xml | 33 +++++++++++++++
tests/qemuxml2argvtest.c | 1 +
.../vhost-vsock-ccw-iommu.s390x-latest.xml | 37 ++++++++++++++++
tests/qemuxml2xmltest.c | 2 +
11 files changed, 160 insertions(+), 3 deletions(-)
create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
create mode 100644 tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
create mode 100644 tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index c738078b90..a09868bed5 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -7433,6 +7433,8 @@ devices <#elementsVirtioTransitional>`__ for more details. The optional
attribute ``address`` of the ``cid`` element specifies the CID assigned to the
guest. If the attribute ``auto`` is set to ``yes``, libvirt will assign a free
CID automatically on domain startup. :since:`Since 4.4.0`
+The optional ``driver`` element allows to specify virtio options, see
+`Virtio-specific options <#elementsVirtio>`__ for more details. :since:`Since 7.1.0`
::
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index a4bddcf132..232587e690 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4883,6 +4883,11 @@
<optional>
<ref name="alias"/>
</optional>
+ <optional>
+ <element name="driver">
+ <ref name="virtioOptions"/>
+ </element>
+ </optional>
</interleave>
</element>
</define>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dab4f10326..b94204cb4f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2457,6 +2457,7 @@ virDomainVsockDefFree(virDomainVsockDefPtr vsock)
virObjectUnref(vsock->privateData);
virDomainDeviceInfoClear(&vsock->info);
+ VIR_FREE(vsock->virtio);
VIR_FREE(vsock);
}
@@ -5321,7 +5322,16 @@ virDomainNetDefPostParse(virDomainNetDefPtr net)
}
-static void
+static bool
+virDomainVsockIsVirtioModel(const virDomainVsockDef *vsock)
+{
+ return (vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO ||
+ vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_TRANSITIONAL ||
+ vsock->model == VIR_DOMAIN_VSOCK_MODEL_VIRTIO_NON_TRANSITIONAL);
+}
+
+
+static int
virDomainVsockDefPostParse(virDomainVsockDefPtr vsock)
{
if (vsock->auto_cid == VIR_TRISTATE_BOOL_ABSENT) {
@@ -5330,6 +5340,12 @@ virDomainVsockDefPostParse(virDomainVsockDefPtr vsock)
else
vsock->auto_cid = VIR_TRISTATE_BOOL_YES;
}
+
+ if (!virDomainVsockIsVirtioModel(vsock) &&
+ virDomainCheckVirtioOptions(vsock->virtio) < 0)
+ return -1;
+
+ return 0;
}
@@ -5410,8 +5426,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
break;
case VIR_DOMAIN_DEVICE_VSOCK:
- virDomainVsockDefPostParse(dev->data.vsock);
- ret = 0;
+ ret = virDomainVsockDefPostParse(dev->data.vsock);
break;
case VIR_DOMAIN_DEVICE_MEMORY:
@@ -15711,6 +15726,11 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
if (virDomainDeviceInfoParseXML(xmlopt, node, &vsock->info, flags) < 0)
return NULL;
+ if (virDomainVirtioOptionsParseXML(virXPathNode("./driver", ctxt),
+ &vsock->virtio) < 0)
+ return NULL;
+
+
return g_steal_pointer(&vsock);
}
@@ -22897,6 +22917,10 @@ virDomainVsockDefCheckABIStability(virDomainVsockDefPtr src,
return false;
}
+ if (src->virtio && dst->virtio &&
+ !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio))
+ return false;
+
if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info))
return false;
@@ -28087,6 +28111,7 @@ virDomainVsockDefFormat(virBufferPtr buf,
g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
g_auto(virBuffer) cidAttrBuf = VIR_BUFFER_INITIALIZER;
+ g_auto(virBuffer) drvAttrBuf = VIR_BUFFER_INITIALIZER;
if (vsock->model) {
virBufferAsprintf(&attrBuf, " model='%s'",
@@ -28103,6 +28128,9 @@ virDomainVsockDefFormat(virBufferPtr buf,
virDomainDeviceInfoFormat(&childBuf, &vsock->info, 0);
+ virDomainVirtioOptionsFormat(&drvAttrBuf, vsock->virtio);
+
+ virXMLFormatElement(&childBuf, "driver", &drvAttrBuf, NULL);
virXMLFormatElement(buf, "vsock", &attrBuf, &childBuf);
}
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 95ad052891..0a5d151150 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2543,6 +2543,7 @@ struct _virDomainVsockDef {
virTristateBool auto_cid;
virDomainDeviceInfo info;
+ virDomainVirtioOptionsPtr virtio;
};
struct _virDomainVirtioOptions {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1ec302d4ac..4986ca8b08 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9733,6 +9733,9 @@ qemuBuildVsockDevStr(virDomainDefPtr def,
virBufferAsprintf(&buf, ",id=%s", vsock->info.alias);
virBufferAsprintf(&buf, ",guest-cid=%u", vsock->guest_cid);
virBufferAsprintf(&buf, ",vhostfd=%s%u", fdprefix, priv->vhostfd);
+
+ qemuBuildVirtioOptionsStr(&buf, vsock->virtio);
+
if (qemuBuildDeviceAddressStr(&buf, def, &vsock->info, qemuCaps) < 0)
return NULL;
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index a060bd98ba..cb9311cb9c 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4200,6 +4200,9 @@ qemuValidateDomainDeviceDefVsock(const virDomainVsockDef *vsock,
"vsock"))
return -1;
+ if (qemuValidateDomainVirtioOptions(vsock->virtio, qemuCaps) < 0)
+ return -1;
+
return 0;
}
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
new file mode 100644
index 0000000000..aed32eef25
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.s390x-latest.args
@@ -0,0 +1,42 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-s390x \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine s390-ccw-virtio,accel=tcg,usb=off,dump-guest-core=off,\
+memory-backend=s390.ram \
+-cpu qemu \
+-m 214 \
+-object memory-backend-ram,id=s390.ram,size=224395264 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-boot strict=on \
+-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1",\
+"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw",\
+"file":"libvirt-1-storage"}' \
+-device virtio-blk-ccw,devno=fe.0.0000,drive=libvirt-1-format,id=virtio-disk0,\
+bootindex=1 \
+-device virtio-balloon-ccw,id=balloon0,devno=fe.0.0001 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-device vhost-vsock-ccw,id=vsock0,guest-cid=4,vhostfd=6789,iommu_platform=on,\
+devno=fe.0.0002 \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
new file mode 100644
index 0000000000..ba9cdc82bf
--- /dev/null
+++ b/tests/qemuxml2argvdata/vhost-vsock-ccw-iommu.xml
@@ -0,0 +1,33 @@
+<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='s390x' machine='s390-ccw-virtio'>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-s390x</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </disk>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </memballoon>
+ <panic model='s390'/>
+ <vsock model='virtio'>
+ <cid auto='no' address='4'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
+ <driver iommu='on'/>
+ </vsock>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index cf77224fc3..c5d82ac72e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -3400,6 +3400,7 @@ mymain(void)
DO_TEST_CAPS_LATEST("vhost-vsock-auto");
DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw", "s390x");
DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-auto", "s390x");
+ DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-iommu", "s390x");
DO_TEST_CAPS_VER("launch-security-sev", "2.12.0");
DO_TEST_CAPS_VER("launch-security-sev-missing-platform-info", "2.12.0");
diff --git a/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
new file mode 100644
index 0000000000..dbfe082a6f
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/vhost-vsock-ccw-iommu.s390x-latest.xml
@@ -0,0 +1,37 @@
+<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='s390x' machine='s390-ccw-virtio'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu mode='custom' match='exact' check='none'>
+ <model fallback='forbid'>qemu</model>
+ </cpu>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-s390x</emulator>
+ <disk type='block' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/HostVG/QEMUGuest1'/>
+ <target dev='hda' bus='virtio'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0000'/>
+ </disk>
+ <controller type='pci' index='0' model='pci-root'/>
+ <memballoon model='virtio'>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0001'/>
+ </memballoon>
+ <panic model='s390'/>
+ <vsock model='virtio'>
+ <cid auto='no' address='4'/>
+ <address type='ccw' cssid='0xfe' ssid='0x0' devno='0x0002'/>
+ <driver iommu='on'/>
+ </vsock>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 9553a8a4f8..50dd970789 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -1403,6 +1403,8 @@ mymain(void)
QEMU_CAPS_CCW);
DO_TEST("vhost-vsock-ccw-auto", QEMU_CAPS_DEVICE_VHOST_VSOCK,
QEMU_CAPS_CCW);
+ DO_TEST_CAPS_ARCH_LATEST("vhost-vsock-ccw-iommu", "s390x");
+
DO_TEST_CAPS_LATEST("vhost-user-fs-fd-memory");
DO_TEST_CAPS_LATEST("vhost-user-fs-hugepages");
--
2.26.2
3 years, 9 months
[libvirt PATCH 00/11] Random bits found by clang-tidy
by Tim Wiederhake
clang-tidy is a static code analysis tool under the llvm umbrella. It is
primarily meant to be used on C++ code bases, but some of the checks it
provides also apply to C.
The findings vary in severity and contain pseudo-false-positives, i.e.
clang-tidy is flagging potential execution flows that could happen in
theory but are virtually impossible in real life: In function
`virGetUnprivSGIOSysfsPath`, variables `maj` and `min` would be read
unintialized if `stat()` failed and set `errno` to a negative value, to name
just one example.
The main source of false positive findings is the lack of support for
`__attribute__((cleanup))` in clang-tidy, which is heavily used in libvirt
through glib's `g_autofree` and `g_auto()` macros:
#include <stdlib.h>
void freeptr(int** p) {
if (*p)
free(*p);
}
int main() {
__attribute__((cleanup(freeptr))) int *ptr = NULL;
ptr = calloc(sizeof(int), 1);
return 0; /* flagged as memory leak of `ptr` */
}
This sadly renders clang-tidy's analysis of dynamic memory useless, hiding all
real issues that it could otherwise find.
Meson provides excellent integration for clang-tidy (a "clang-tidy" target is
automatically generated if a ".clang-tidy" configuration file is present
in the project's root directory). The amount of false-positives and the slow
analysis, triggering time-outs in the CI, make this tool unfit for inclusion
in libvirt's GitLab CI though.
The patches in this series are the result of fixing some of the issues
reported by running
CC=clang meson build
ninja -C build # generate sources and header files
ninja -C build clang-tidy
with the following `.clang-tidy` configuration file:
---
Checks: >
*,
-abseil-*,
-android-*,
-boost-*,
-cppcoreguidelines-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-llvm-*,
-modernize-*,
-mpi-,
-objc-,
-openmp-,
-zircon-*,
-readability-braces-around-statements,
-readability-magic-numbers
WarningsAsErrors: '*'
HeaderFilterRegex: ''
FormatStyle: none
...
Regards,
Tim
Tim Wiederhake (11):
virfile: Remove redundant #ifndef
xen: Fix indentation in xenParseXLSpice
qemu_tpm: Fix indentation in qemuTPMEmulatorBuildCommand
virsh-domain: Fix error handling of pthread_sigmask
Replace bzero() with memset()
udevGetIntSysfsAttr: Return -1 for missing attributes
virhostuptime: Fix rounding in uptime calculation
tests: Prevent malloc with size 0
vircryptotest: Directly assign string to avoid memcpy
vircommand: Remove NULL check in virCommandAddArg
vircommand: Simplify virCommandAddArg
src/libxl/xen_xl.c | 5 ++---
src/node_device/node_device_udev.c | 5 ++++-
src/qemu/qemu_tpm.c | 8 +++++---
src/util/virarptable.c | 2 +-
src/util/vircommand.c | 12 +-----------
src/util/virfile.c | 4 ++--
src/util/virhostuptime.c | 4 +++-
tests/commandhelper.c | 2 +-
tests/vircryptotest.c | 5 +----
tests/virpcimock.c | 2 +-
tools/virsh-domain.c | 8 ++++----
11 files changed, 25 insertions(+), 32 deletions(-)
--
2.26.2
3 years, 9 months
[PATCH] remote: Add libvirtd dependency to virt-guest-shutdown.target
by Jim Fehlig
When restarting libvirt services and sockets *and* libvirt-guests.service
is running, the latter will sometimes hang when trying to connect to
libvirtd. Even though libvirt-guests has 'Wants=libvirtd.service' and
'After=libvirtd.service', we can see via journalctl that it is not
shutdown before libvirtd when executing something like
systemctl try-restart libvirtd.service libvirtd.socket \
libvirtd-ro.socket virtlockd.service virtlockd.socket \
virtlogd.service virtlogd.socket virt-guest-shutdown.target
Oct 28 15:53:31 systemd[1]: Stopping Virtualization daemon...
Oct 28 15:53:31 systemd[1]: libvirtd.service: Succeeded.
Oct 28 15:53:31 systemd[1]: Stopped Virtualization daemon.
Oct 28 15:53:31 systemd[1]: libvirtd-admin.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: libvirtd-ro.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: libvirtd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Stopping Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt local socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:53:31 systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:53:31 systemd[1]: virtlockd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:53:31 systemd[1]: virtlogd.socket: Succeeded.
Oct 28 15:53:31 systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:53:31 systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
In this case, the try-restart command hung and libvirt-guests was stuck
trying to connect to libvirtd. In the following case, the try-restart
worked since libvirtd was started again before libvirt-guests was stopped!
Oct 28 15:19:02 systemd[1]: Stopping Virtualization daemon...
Oct 28 15:19:02 systemd[1]: Stopped Virtualization daemon.
Oct 28 15:19:02 systemd[1]: Closed Libvirt admin socket.
Oct 28 15:19:02 systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:19:02 systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:19:02 systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:19:02 systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:19:02 systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:19:02 systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:19:02 systemd[1]: Closed Libvirt local socket.
Oct 28 15:19:02 systemd[1]: Stopping Libvirt local socket.
Oct 28 15:19:02 systemd[1]: Listening on Libvirt local socket.
Oct 28 15:19:02 systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:19:02 systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:19:02 systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:19:02 systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:19:02 systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:19:02 systemd[1]: Starting Virtualization daemon...
Oct 28 15:19:02 systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Oct 28 15:19:02 systemd[1]: Started Virtualization daemon.
Oct 28 15:19:02 libvirt-guests.sh[4912]: Running guests on default URI: no running guests.
Oct 28 15:19:02 systemd[1]: Stopped Suspend/Resume Running libvirt Guests.
Oct 28 15:19:02 systemd[1]: Stopped target Libvirt guests shutdown.
Oct 28 15:19:02 systemd[1]: Stopping Libvirt guests shutdown.
Oct 28 15:19:02 systemd[1]: Reached target Libvirt guests shutdown.
Oct 28 15:19:02 systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Oct 28 15:19:02 systemd[1]: Started Suspend/Resume Running libvirt Guests.
Adding 'Requires=libvirtd.service' to virt-guest-shutdown.target results
in expected behavior
Oct 28 15:40:00 systemd[1]: Stopping Suspend/Resume Running libvirt Guests...
Oct 28 15:40:00 libvirt-guests.sh[5245]: Running guests on default URI: no running guests.
Oct 28 15:40:00 systemd[1]: Stopped Suspend/Resume Running libvirt Guests.
Oct 28 15:40:00 systemd[1]: Stopped target Libvirt guests shutdown.
Oct 28 15:40:00 systemd[1]: Stopping Libvirt guests shutdown.
Oct 28 15:40:00 systemd[1]: Stopping Virtualization daemon...
Oct 28 15:40:00 systemd[1]: Stopped Virtualization daemon.
Oct 28 15:40:00 systemd[1]: Closed Virtual machine log manager socket.
Oct 28 15:40:00 systemd[1]: Stopping Virtual machine log manager socket.
Oct 28 15:40:00 systemd[1]: Listening on Virtual machine log manager socket.
Oct 28 15:40:00 systemd[1]: Closed Libvirt admin socket.
Oct 28 15:40:00 systemd[1]: Stopping Libvirt admin socket.
Oct 28 15:40:00 systemd[1]: Closed Libvirt local read-only socket.
Oct 28 15:40:00 systemd[1]: Stopping Libvirt local read-only socket.
Oct 28 15:40:00 systemd[1]: Closed Libvirt local socket.
Oct 28 15:40:00 systemd[1]: Stopping Libvirt local socket.
Oct 28 15:40:00 systemd[1]: Listening on Libvirt local socket.
Oct 28 15:40:00 systemd[1]: Listening on Libvirt admin socket.
Oct 28 15:40:00 systemd[1]: Listening on Libvirt local read-only socket.
Oct 28 15:40:00 systemd[1]: Closed Virtual machine lock manager socket.
Oct 28 15:40:00 systemd[1]: Stopping Virtual machine lock manager socket.
Oct 28 15:40:00 systemd[1]: Listening on Virtual machine lock manager socket.
Oct 28 15:40:00 systemd[1]: Starting Virtualization daemon...
Oct 28 15:40:00 systemd[1]: Started Virtualization daemon.
Oct 28 15:40:00 systemd[1]: Reached target Libvirt guests shutdown.
Oct 28 15:40:00 systemd[1]: Starting Suspend/Resume Running libvirt Guests...
Oct 28 15:40:00 systemd[1]: Started Suspend/Resume Running libvirt Guests.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
I asked about this on the dev list but it is probably best to send a
patch for discussion instead.
https://www.redhat.com/archives/libvir-list/2020-October/msg01492.html
src/remote/virt-guest-shutdown.target | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/remote/virt-guest-shutdown.target b/src/remote/virt-guest-shutdown.target
index 25d4aaa267..e2efa3e63a 100644
--- a/src/remote/virt-guest-shutdown.target
+++ b/src/remote/virt-guest-shutdown.target
@@ -1,3 +1,4 @@
[Unit]
Description=Libvirt guests shutdown
+Requires=libvirtd.service
Documentation=https://libvirt.org
--
2.28.0
3 years, 9 months
failed to start vm after add vsock device
by longguang.yue
Hi, all:
there is no error when launch qemu-kvm from cli directly, but vm fails to start via libvirtd.
i have tried to chmod 0666 /dev/vhost-vsock.
error: internal error: qemu unexpectedly closed the monitor: 2021-01-26T13:06:06.403097Z qemu-kvm: -device vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=4: vhost-vsock: failed to open vhost device: Unknown error -13
<qemu:commandline>
<qemu:arg value='-device'/>
<qemu:arg value='vhost-vsock-pci,id=vhost-vsock-pci0,guest-cid=4'/>
</qemu:commandline>
thanks
3 years, 9 months