[PATCH v2] virQEMUDriverGetDomainCapabilities: Validate arguments
by Michal Privoznik
When calling virConnectGetDomainCapabilities() (exposed as virsh
domcapabilities) users have option to specify whatever sub-set of
{ emulatorbin, arch, machine, virttype } they want. Then we have
a logic (hidden in virQEMUCapsCacheLookupDefault()) that picks
qemuCaps that satisfy values passed by user. And whatever was not
specified is then set to the default value as specified by picked
qemuCaps. For instance: if no machine type was provided but
emulatorbin was, then the machine type is set to the default one
as defined by the emulatorbin.
Or, when just virttype was set then the remaining three values
are set to their respective defaults. Except, we have a crasher
in this case:
# virsh domcapabilities --virttype hvf
error: Disconnected from qemu:///system due to end of file
error: failed to get emulator capabilities
error: End of file while reading data: Input/output error
This is because for 'hvf' virttype (at least my) QEMU does not
have any machine type. Therefore, @machine is set to NULL and the
rest of the code does not expect that.
What we can do about this is to validate all arguments. Well,
except for the emulatorbin which is obtained from passed
qemuCaps. This also fixes the issue when domcapabilities for a
virttype of a different driver are requested, or a different
arch.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
v2 of:
https://listman.redhat.com/archives/libvir-list/2022-December/236460.html
diff to v1:
- validate @arch, @virttype as well, not just @machine
src/qemu/qemu_conf.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ae5bbcd138..6760bef14c 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1454,6 +1454,27 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriver *driver,
g_autoptr(virDomainCaps) domCaps = NULL;
const char *path = virQEMUCapsGetBinary(qemuCaps);
+ if (!virQEMUCapsIsArchSupported(qemuCaps, arch)) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("Emulator '%s' does not support arch '%s'"),
+ path, virArchToString(arch));
+ return NULL;
+ }
+
+ if (!virQEMUCapsIsVirtTypeSupported(qemuCaps, virttype)) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("Emulator '%s' does not support virt type '%s'"),
+ path, virDomainVirtTypeToString(virttype));
+ return NULL;
+ }
+
+ if (!virQEMUCapsIsMachineSupported(qemuCaps, virttype, machine)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("Emulator '%s' does not support machine type '%s'"),
+ path, NULLSTR(machine));
+ return NULL;
+ }
+
if (!(domCaps = virDomainCapsNew(path, machine, arch, virttype)))
return NULL;
--
2.38.2
1 year, 11 months
[PATCH v1 0/7] qemu_capabilities: Report Hyper-V Enlightenments in domcapabilities
by Michal Privoznik
Michal Prívozník (7):
domain_capabilities:
s/qemuDomainCapsFeatureFormatSimple/virDomainCapsFeatureFormatSimple/
qemu_capabilities: Decrease scope of @hash in
virQEMUCapsProbeQMPHostCPU()
qemuMonitorJSONMakeCPUModel: Introduce @hv_passthrough argument
qemuMonitorJSONGetCPUModelExpansion: Introduce @hv_passthrough
argument
qemu_capabilities: Query for Hyper-V Enlightenments
domain_capabilities: Expose Hyper-V Enlightenments
qemu_capabilities: Report Hyper-V Enlightenments in domcapabilities
docs/formatdomaincaps.rst | 15 +
src/conf/domain_capabilities.c | 28 +-
src/conf/domain_capabilities.h | 8 +
src/conf/schemas/domaincaps.rng | 10 +
src/qemu/qemu_capabilities.c | 86 ++++-
src/qemu/qemu_driver.c | 3 +-
src/qemu/qemu_monitor.c | 5 +-
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 21 +-
src/qemu/qemu_monitor_json.h | 1 +
tests/cputest.c | 2 +-
.../domaincapsdata/qemu_4.2.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_4.2.0-tcg.x86_64.xml | 1 +
.../qemu_4.2.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_4.2.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.0.0-tcg.x86_64.xml | 1 +
.../qemu_5.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.0.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_5.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_5.1.0.sparc.xml | 1 +
tests/domaincapsdata/qemu_5.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.2.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_5.2.0-tcg.x86_64.xml | 1 +
.../qemu_5.2.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_5.2.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.0.0-tcg.x86_64.xml | 1 +
.../qemu_6.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.s390x.xml | 1 +
tests/domaincapsdata/qemu_6.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_6.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.2.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_6.2.0-tcg.x86_64.xml | 1 +
.../qemu_6.2.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.2.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_6.2.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_6.2.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_7.0.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_7.0.0-tcg.x86_64.xml | 1 +
.../qemu_7.0.0-virt.aarch64.xml | 1 +
tests/domaincapsdata/qemu_7.0.0.aarch64.xml | 1 +
tests/domaincapsdata/qemu_7.0.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_7.0.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_7.1.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_7.1.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_7.1.0.ppc64.xml | 1 +
tests/domaincapsdata/qemu_7.1.0.x86_64.xml | 1 +
.../domaincapsdata/qemu_7.2.0-q35.x86_64.xml | 1 +
.../domaincapsdata/qemu_7.2.0-tcg.x86_64.xml | 1 +
tests/domaincapsdata/qemu_7.2.0.x86_64.xml | 1 +
.../caps_4.2.0.aarch64.replies | 45 +++
.../caps_4.2.0.x86_64.replies | 317 ++++++++++++++++
.../caps_5.0.0.aarch64.replies | 46 +++
.../caps_5.0.0.x86_64.replies | 318 ++++++++++++++++
.../caps_5.1.0.x86_64.replies | 323 ++++++++++++++++
.../caps_5.2.0.aarch64.replies | 47 +++
.../caps_5.2.0.x86_64.replies | 324 ++++++++++++++++
.../caps_6.0.0.aarch64.replies | 47 +++
.../caps_6.0.0.x86_64.replies | 336 +++++++++++++++++
.../caps_6.1.0.x86_64.replies | 338 +++++++++++++++++
.../caps_6.2.0.aarch64.replies | 47 +++
.../caps_6.2.0.x86_64.replies | 348 +++++++++++++++++
.../caps_7.0.0.aarch64.replies | 48 +++
.../caps_7.0.0.x86_64.replies | 352 +++++++++++++++++
.../caps_7.1.0.x86_64.replies | 353 ++++++++++++++++++
.../caps_7.2.0.x86_64.replies | 353 ++++++++++++++++++
79 files changed, 3850 insertions(+), 24 deletions(-)
--
2.38.2
1 year, 11 months
[PATCH 0/7] qemu: Cleanup code around TPM seclabels
by Michal Privoznik
*** BLURB HERE ***
Michal Prívozník (7):
qemu_security: Rework qemuSecurityCleanupTPMEmulator()
qemu_security: Rename qemuSecurityCleanupTPMEmulator()
qemu_security: Introduce qemuSecuritySetTPMLabels()
qemu_tpm: Restore TPM labels on failed start
qemu_tpm: Open code qemuSecurityStartTPMEmulator()
qemu_security: Drop qemuSecurityStartTPMEmulator()
docs: Recommend static seclabels for migration on shared storage
docs/drvqemu.rst | 7 ++++
src/qemu/qemu_security.c | 90 ++++++++++------------------------------
src/qemu/qemu_security.h | 17 +++-----
src/qemu/qemu_tpm.c | 15 ++++---
4 files changed, 43 insertions(+), 86 deletions(-)
--
2.38.2
1 year, 11 months
[PATCH v2] i386: Deprecate the -no-hpet QEMU command line option
by Thomas Huth
The HPET setting has been turned into a machine property a while ago
already, so we should finally do the next step and deprecate the
legacy CLI option, too.
Signed-off-by: Thomas Huth <thuth(a)redhat.com>
---
v2:
- Rebased to current version from master branch / adjusted version info
- Dropped the descrpition in hw/i386/pc.c (already done via another patch)
Note: The "hpet" property should now show up in the output of the
"query-command-line-options" QMP command since commit 2f129fc107b4a, so
it should be feasible for libvirt now to properly probe for the property .
docs/about/deprecated.rst | 6 ++++++
softmmu/vl.c | 1 +
qemu-options.hx | 2 +-
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 93affe3669..2ae6a79b21 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -114,6 +114,12 @@ form is preferred.
Using ``-drive if=none`` to configure the OTP device of the sifive_u
RISC-V machine is deprecated. Use ``-drive if=pflash`` instead.
+``-no-hpet`` (since 8.0)
+''''''''''''''''''''''''
+
+The HPET setting has been turned into a machine property.
+Use ``-machine hpet=off`` instead.
+
QEMU Machine Protocol (QMP) commands
------------------------------------
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 798e1dc933..9bd0e52d01 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -3259,6 +3259,7 @@ void qemu_init(int argc, char **argv)
qdict_put_str(machine_opts_dict, "acpi", "off");
break;
case QEMU_OPTION_no_hpet:
+ warn_report("-no-hpet is deprecated, use '-machine hpet=off' instead");
qdict_put_str(machine_opts_dict, "hpet", "off");
break;
case QEMU_OPTION_no_reboot:
diff --git a/qemu-options.hx b/qemu-options.hx
index 7f99d15b23..a3adb4163e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2542,7 +2542,7 @@ DEF("no-hpet", 0, QEMU_OPTION_no_hpet,
"-no-hpet disable HPET\n", QEMU_ARCH_I386)
SRST
``-no-hpet``
- Disable HPET support.
+ Disable HPET support. Deprecated, use '-machine hpet=off' instead.
ERST
DEF("acpitable", HAS_ARG, QEMU_OPTION_acpitable,
--
2.31.1
1 year, 11 months
Re: [PATCH] qemu: fix several codecheck in qemu_monitor.c
by Jiang Jiacheng
Ping...
On 2022/12/8 20:49, Jiang Jiacheng wrote:
> 1.clear passwd in debug log
> 2.alignment
> 3.use the same variable name for function definition and declaration
>
> Signed-off-by: Jiang Jiacheng <jiangjiacheng(a)huawei.com>
> ---
> src/qemu/qemu_monitor.c | 8 ++++----
> src/qemu/qemu_monitor.h | 6 +++---
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 80f262cec7..de9a1b26f6 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -943,7 +943,7 @@ qemuMonitorInitBalloonObjectPath(qemuMonitor *mon,
> case VIR_DOMAIN_MEMBALLOON_MODEL_XEN:
> case VIR_DOMAIN_MEMBALLOON_MODEL_NONE:
> virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> - _("invalid model for virtio-balloon-pci"));
> + _("invalid model for virtio-balloon-pci"));
> return;
> case VIR_DOMAIN_MEMBALLOON_MODEL_LAST:
> default:
> @@ -2053,8 +2053,8 @@ qemuMonitorSetPassword(qemuMonitor *mon,
> if (!protocol)
> return -1;
>
> - VIR_DEBUG("protocol=%s, password=%p, action_if_connected=%s",
> - protocol, password, action_if_connected);
> + VIR_DEBUG("protocol=%s, action_if_connected=%s",
> + protocol, action_if_connected);
>
> QEMU_CHECK_MONITOR(mon);
>
> @@ -3485,7 +3485,7 @@ qemuMonitorBlockExportAdd(qemuMonitor *mon,
>
> int
> qemuMonitorGetTPMModels(qemuMonitor *mon,
> - char ***tpmmodels)
> + char ***tpmmodels)
> {
> VIR_DEBUG("tpmmodels=%p", tpmmodels);
>
> diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
> index c690fc3655..7278f2e706 100644
> --- a/src/qemu/qemu_monitor.h
> +++ b/src/qemu/qemu_monitor.h
> @@ -627,8 +627,8 @@ struct _qemuMonitorCPUInfo {
> };
> typedef struct _qemuMonitorCPUInfo qemuMonitorCPUInfo;
>
> -void qemuMonitorCPUInfoFree(qemuMonitorCPUInfo *list,
> - size_t nitems);
> +void qemuMonitorCPUInfoFree(qemuMonitorCPUInfo *cpus,
> + size_t ncpus);
> int qemuMonitorGetCPUInfo(qemuMonitor *mon,
> qemuMonitorCPUInfo **vcpus,
> size_t maxvcpus,
> @@ -1184,7 +1184,7 @@ int qemuMonitorNBDServerAdd(qemuMonitor *mon,
> const char *export,
> bool writable,
> const char *bitmap);
> -int qemuMonitorNBDServerStop(qemuMonitor *);
> +int qemuMonitorNBDServerStop(qemuMonitor *mon);
>
> int qemuMonitorBlockExportAdd(qemuMonitor *mon,
> virJSONValue **props);
2 years
Re: [PATCH] conf: check vhost-user queues with vcpus
by Jiang Jiacheng
Ping...
On 2022/12/8 20:49, Jiang Jiacheng wrote:
> With kernel without the ref patch, if queues > vcpus, interrupts
> will be centralized on one vcpu affecting guest performance. After
> the ref patch merged, the queues whose number is greater than the
> number of vcpus will not be used.
>
> Considering the above, it's better to check the counts of vhost-user
> queues and vcpus.
>
> ref:
> https://patchwork.kernel.org/project/linux-scsi/cover/1553682995-5682-1-g...
>
> Signed-off-by: Jiang Jiacheng <jiangjiacheng(a)huawei.com>
> ---
> src/conf/domain_validate.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
> index 95b8d9b419..6106e79999 100644
> --- a/src/conf/domain_validate.c
> +++ b/src/conf/domain_validate.c
> @@ -308,7 +308,7 @@ virSecurityDeviceLabelDefValidate(virSecurityDeviceLabelDef **seclabels,
>
>
> static int
> -virDomainDiskVhostUserValidate(const virDomainDiskDef *disk)
> +virDomainDiskVhostUserValidate(const virDomainDef *def, const virDomainDiskDef *disk)
> {
> if (disk->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
> virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> @@ -465,6 +465,12 @@ virDomainDiskVhostUserValidate(const virDomainDiskDef *disk)
> return -1;
> }
>
> + if (disk->queues > virDomainDefGetVcpus(def)) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> + _("vhost-user disk queues must <= vcpus"));
> + return -1;
> + }
> +
> return 0;
> }
>
> @@ -807,7 +813,7 @@ virDomainDiskDefValidate(const virDomainDef *def,
> }
>
> if (disk->src->type == VIR_STORAGE_TYPE_VHOST_USER &&
> - virDomainDiskVhostUserValidate(disk) < 0) {
> + virDomainDiskVhostUserValidate(def, disk) < 0) {
> return -1;
> }
>
2 years
[PATCH V3 0/7] qemu: support updating device's bootindex
by Jiang Jiacheng
Support updating device's(support cdrom, disk and network) bootindex
online in virDomainUpdateDeviceFlags. The new bootindex will take effect
after guest rebooting. Enable bootindex can be set to 0, it means cancel
the device's bootindex.
To use this feature, we need to get the device's xml first and modify
the boot order in the xml, then use 'virsh update-device <domain> <xml>
--flag' to update the bootindex. Note that the flag should be --config
or --persistent if the vm is running.
Jiang Jiacheng (7):
qemu: Introduce qemuDomainChangeBootIndex to update device's bootindex
qemu: Marking a device's bootindex can be changed
qemu: check the bootIndex could be changed or not
qemu: Support update disk's bootindex
qemu: Support update net's bootindex
qemu: Support set bootindex to 0 to cancel bootindex setting
test: add a test for bootIndex = 0 provided by the user
diff to v2:
* improve function description and commit message
* move functions in qemu_conf.c to qemu_domain.c
* add a test for bootindex = 0 provided by user
* fix a bug in logical of checking bootindex
src/conf/device_conf.h | 3 +
src/conf/domain_conf.c | 10 ++-
src/conf/domain_postparse.c | 8 ++-
src/conf/schemas/domaincommon.rng | 2 +-
src/qemu/qemu_conf.c | 41 +++++++++++
src/qemu/qemu_conf.h | 5 ++
src/qemu/qemu_domain.c | 69 +++++++++++++++++-
src/qemu/qemu_domain.h | 9 +++
src/qemu/qemu_driver.c | 32 +++++++++
src/qemu/qemu_hotplug.c | 17 +++--
src/qemu/qemu_monitor.c | 12 ++++
src/qemu/qemu_monitor.h | 6 ++
src/qemu/qemu_monitor_json.c | 22 ++++++
src/qemu/qemu_monitor_json.h | 6 ++
tests/qemuxml2argvdata/boot-order-set-0.xml | 72 +++++++++++++++++++
tests/qemuxml2xmloutdata/boot-order-set-0.xml | 72 +++++++++++++++++++
tests/qemuxml2xmltest.c | 1 +
17 files changed, 376 insertions(+), 11 deletions(-)
create mode 100644 tests/qemuxml2argvdata/boot-order-set-0.xml
create mode 100644 tests/qemuxml2xmloutdata/boot-order-set-0.xml
--
2.33.0
2 years
[PATCH] qemu: implement QEMU NBD source reconnect delay attribute
by Christian Nautze
Currently it's only possible to set this parameter during domain
creation via QEMU commandline passthrough feature.
With the new delay attribute it's also possible to set this
parameter if you want to attach a new NBD disk
using "virsh attach-device domain device.xml" e.g.:
<disk type='network' device='disk'>
<driver name='qemu' type='raw'/>
<source protocol='nbd' name='foo'>
<host name='example.org' port='6000'/>
<reconnect enabled='yes' delay='10'/>
</source>
<target dev='vdb' bus='virtio'/>
</disk>
Signed-off-by: Christian Nautze <christian.nautze(a)exoscale.ch>
---
docs/formatdomain.rst | 10 ++++++--
src/conf/domain_conf.c | 19 +++++++++++++++
src/conf/schemas/domaincommon.rng | 3 +++
src/conf/schemas/storagecommon.rng | 5 ++++
src/conf/storage_source_conf.c | 1 +
src/conf/storage_source_conf.h | 4 ++++
src/qemu/qemu_block.c | 4 +++-
src/qemu/qemu_domain.c | 9 ++++++++
.../disk-network-nbd.x86_64-latest.args | 23 +++++++++++--------
tests/qemuxml2argvdata/disk-network-nbd.xml | 8 +++++++
tests/qemuxml2xmloutdata/disk-network-nbd.xml | 9 ++++++++
11 files changed, 82 insertions(+), 13 deletions(-)
diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index d7fffc6e0b..3fbeba644a 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -2938,13 +2938,19 @@ paravirtualized driver is specified via the ``disk`` element.
are intended to be default, then the entire element may be omitted.
``reconnect``
For disk type ``vhostuser`` configures reconnect timeout if the connection
- is lost. It has two mandatory attributes:
+ is lost. This is set with the two mandatory attributes ``enabled`` and
+ ``timeout``. For disk type ``network`` and protocol ``nbd`` the QEMU NBD
+ reconnect delay can be set via the mandatory attributes ``enabled``
+ and ``delay``:
``enabled``
If the reconnect feature is enabled, accepts ``yes`` and ``no``
``timeout``
The amount of seconds after which hypervisor tries to reconnect.
-
+ ``delay``
+ The amount of seconds during which all requests are paused and will be rerun
+ after a successful reconnect. After that time, any delayed requests and all
+ future requests before a successful reconnect will immediately fail.
For a "file" or "volume" disk type which represents a cdrom or floppy (the
``device`` attribute), it is possible to define policy what to do with the
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6c088ff295..909c78ef28 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7024,6 +7024,22 @@ virDomainDiskSourceNetworkParse(xmlNodePtr node,
src->tlsFromConfig = !!value;
}
+ if (src->protocol == VIR_STORAGE_NET_PROTOCOL_NBD) {
+ xmlNodePtr cur;
+ if ((cur = virXPathNode("./reconnect", ctxt))) {
+ virTristateBool enabled;
+ if (virXMLPropTristateBool(cur, "enabled", VIR_XML_PROP_NONE,
+ &enabled) < 0)
+ return -1;
+
+ if (enabled == VIR_TRISTATE_BOOL_YES) {
+ if (virXMLPropUInt(cur, "delay", 10, VIR_XML_PROP_REQUIRED,
+ &src->reconnectDelay) < 0)
+ return -1;
+ }
+ }
+ }
+
/* for historical reasons we store the volume and image name in one XML
* element although it complicates thing when attempting to access them. */
if (src->path &&
@@ -21729,6 +21745,9 @@ virDomainDiskSourceFormatNetwork(virBuffer *attrBuf,
virBufferAddLit(childBuf, "/>\n");
}
+ if (src->reconnectDelay) {
+ virBufferAsprintf(childBuf, "<reconnect enabled='yes' delay='%u'/>\n", src->reconnectDelay);
+ }
virBufferEscapeString(childBuf, "<snapshot name='%s'/>\n", src->snapshot);
virBufferEscapeString(childBuf, "<config file='%s'/>\n", src->configFile);
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
index c588a48fd2..72587416fe 100644
--- a/src/conf/schemas/domaincommon.rng
+++ b/src/conf/schemas/domaincommon.rng
@@ -2184,6 +2184,9 @@
</optional>
<ref name="diskSourceCommon"/>
<ref name="diskSourceNetworkHost"/>
+ <optional>
+ <ref name="reconnect"/>
+ </optional>
<optional>
<ref name="encryption"/>
</optional>
diff --git a/src/conf/schemas/storagecommon.rng b/src/conf/schemas/storagecommon.rng
index 76714c9aad..2842376e78 100644
--- a/src/conf/schemas/storagecommon.rng
+++ b/src/conf/schemas/storagecommon.rng
@@ -61,6 +61,11 @@
<ref name="unsignedInt"/>
</attribute>
</optional>
+ <optional>
+ <attribute name="delay">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
</element>
</define>
diff --git a/src/conf/storage_source_conf.c b/src/conf/storage_source_conf.c
index 2b4cf5e241..edfd17c77c 100644
--- a/src/conf/storage_source_conf.c
+++ b/src/conf/storage_source_conf.c
@@ -810,6 +810,7 @@ virStorageSourceCopy(const virStorageSource *src,
def->sslverify = src->sslverify;
def->readahead = src->readahead;
def->timeout = src->timeout;
+ def->reconnectDelay = src->reconnectDelay;
def->metadataCacheMaxSize = src->metadataCacheMaxSize;
/* storage driver metadata are not copied */
diff --git a/src/conf/storage_source_conf.h b/src/conf/storage_source_conf.h
index f2440cec6a..b60a4b3346 100644
--- a/src/conf/storage_source_conf.h
+++ b/src/conf/storage_source_conf.h
@@ -290,6 +290,10 @@ struct _virStorageSource {
unsigned long long readahead; /* size of the readahead buffer in bytes */
unsigned long long timeout; /* connection timeout in seconds */
+ /* NBD QEMU reconnect-delay option,
+ * 0 as default value */
+ unsigned int reconnectDelay;
+
virStorageSourceNVMeDef *nvme; /* type == VIR_STORAGE_TYPE_NVME */
virDomainChrSourceDef *vhostuser; /* type == VIR_STORAGE_TYPE_VHOST_USER */
diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c
index 8a6f601b29..6913c380a0 100644
--- a/src/qemu/qemu_block.c
+++ b/src/qemu/qemu_block.c
@@ -530,6 +530,7 @@ qemuBlockStorageSourceGetNBDProps(virStorageSource *src,
"S:export", src->path,
"S:tls-creds", tlsAlias,
"S:tls-hostname", tlsHostname,
+ "p:reconnect-delay", src->reconnectDelay,
NULL) < 0)
return NULL;
@@ -1817,7 +1818,8 @@ qemuBlockGetBackingStoreString(virStorageSource *src,
src->ncookies == 0 &&
src->sslverify == VIR_TRISTATE_BOOL_ABSENT &&
src->timeout == 0 &&
- src->readahead == 0) {
+ src->readahead == 0 &&
+ src->reconnectDelay == 0) {
switch ((virStorageNetProtocol) src->protocol) {
case VIR_STORAGE_NET_PROTOCOL_NBD:
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5c05032ce3..840d857f78 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4927,6 +4927,15 @@ qemuDomainValidateStorageSource(virStorageSource *src,
}
}
+ if (src->reconnectDelay > 0) {
+ if (actualType != VIR_STORAGE_TYPE_NETWORK ||
+ src->protocol != VIR_STORAGE_NET_PROTOCOL_NBD) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("reconnect delay is supported only with NBD protocol"));
+ return -1;
+ }
+ }
+
if (src->query &&
(actualType != VIR_STORAGE_TYPE_NETWORK ||
(src->protocol != VIR_STORAGE_NET_PROTOCOL_HTTPS &&
diff --git a/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args b/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args
index 21e619af3e..e8d13b0bd4 100644
--- a/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-network-nbd.x86_64-latest.args
@@ -28,21 +28,24 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
-no-acpi \
-boot strict=on \
-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \
--blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"node-name":"libvirt-5-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"node-name":"libvirt-6-storage","auto-read-only":true,"discard":"unmap"}' \
+-blockdev '{"node-name":"libvirt-6-format","read-only":false,"driver":"raw","file":"libvirt-6-storage"}' \
+-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"libvirt-6-format","id":"virtio-disk0","bootindex":1}' \
+-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"export":"bar","node-name":"libvirt-5-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-5-format","read-only":false,"driver":"raw","file":"libvirt-5-storage"}' \
--device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x2","drive":"libvirt-5-format","id":"virtio-disk0","bootindex":1}' \
--blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"export":"bar","node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap"}' \
+-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"libvirt-5-format","id":"virtio-disk1"}' \
+-blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"6000"},"node-name":"libvirt-4-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-4-format","read-only":false,"driver":"raw","file":"libvirt-4-storage"}' \
--device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x3","drive":"libvirt-4-format","id":"virtio-disk1"}' \
--blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"6000"},"node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
+-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"libvirt-4-format","id":"virtio-disk2"}' \
+-blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"6000"},"export":"bar","node-name":"libvirt-3-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-3-format","read-only":false,"driver":"raw","file":"libvirt-3-storage"}' \
--device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x4","drive":"libvirt-3-format","id":"virtio-disk2"}' \
--blockdev '{"driver":"nbd","server":{"type":"inet","host":"::1","port":"6000"},"export":"bar","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
+-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"libvirt-3-format","id":"virtio-disk3"}' \
+-blockdev '{"driver":"nbd","server":{"type":"unix","path":"/var/run/nbdsock"},"export":"bar","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw","file":"libvirt-2-storage"}' \
--device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x5","drive":"libvirt-2-format","id":"virtio-disk3"}' \
--blockdev '{"driver":"nbd","server":{"type":"unix","path":"/var/run/nbdsock"},"export":"bar","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
+-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"libvirt-2-format","id":"virtio-disk4"}' \
+-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","port":"6000"},"export":"foo","reconnect-delay":10,"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 '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x6","drive":"libvirt-1-format","id":"virtio-disk4"}' \
+-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x7","drive":"libvirt-1-format","id":"virtio-disk5"}' \
-audiodev '{"id":"audio1","driver":"none"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-network-nbd.xml b/tests/qemuxml2argvdata/disk-network-nbd.xml
index 8ac6cc3b7b..243ffeb1ed 100644
--- a/tests/qemuxml2argvdata/disk-network-nbd.xml
+++ b/tests/qemuxml2argvdata/disk-network-nbd.xml
@@ -49,6 +49,14 @@
</source>
<target dev='vde' bus='virtio'/>
</disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='nbd' name='foo'>
+ <host name='example.org' port='6000'/>
+ <reconnect enabled='yes' delay='10'/>
+ </source>
+ <target dev='vdf' bus='virtio'/>
+ </disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
diff --git a/tests/qemuxml2xmloutdata/disk-network-nbd.xml b/tests/qemuxml2xmloutdata/disk-network-nbd.xml
index f8dcca4bab..ed0c760d5b 100644
--- a/tests/qemuxml2xmloutdata/disk-network-nbd.xml
+++ b/tests/qemuxml2xmloutdata/disk-network-nbd.xml
@@ -54,6 +54,15 @@
<target dev='vde' bus='virtio'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</disk>
+ <disk type='network' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source protocol='nbd' name='foo'>
+ <host name='example.org' port='6000'/>
+ <reconnect enabled='yes' delay='10'/>
+ </source>
+ <target dev='vdf' bus='virtio'/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+ </disk>
<controller type='usb' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
--
2.34.1
2 years
[PATCH] qemumonitortestutils: Fix line counting in qemuMonitorTestProcessFileEntries()
by Michal Privoznik
It just so happens that our JSON snippets in
qemucapabilitiesdata/*.replies files are separated by an empty
line. These empty lines are then overwritten to make a single
line JSON. Nevertheless, the line counter @line is not
incremented which then leads to a misleading numbers in errors:
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tests/qemumonitortestutils.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 46791931b0..4e99c4b54e 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -1302,6 +1302,9 @@ qemuMonitorTestProcessFileEntries(char *inputstr,
continue;
}
+ /* We've seen a new line, increment the counter */
+ line++;
+
/* Cut off a single reply. */
*(tmp + 1) = '\0';
--
2.38.2
2 years
[PATCH 0/3] Introduce and use virDirOpenSorted()
by Michal Privoznik
Whiles working on Hyper-V patches I've posted yesterday I ran
domaincapstest occasionally and was puzzled for a moment that qemu-7.2.0
wasn't tested. Well it is, but it's harder to see immediately because
individual test cases are in 'random' order:
11) qemu_7.2.0.x86_64 ... OK
....
46) qemu_5.1.0.sparc ... OK
47) qemu_6.1.0.x86_64 ... OK
48) qemu_6.1.0-q35.x86_64 ... OK
49) qemu_6.1.0-tcg.x86_64 ... OK
50) qemu_7.0.0.ppc64 ... OK
51) qemu_6.2.0.x86_64 ... OK
52) qemu_6.2.0-q35.x86_64 ... OK
53) qemu_6.2.0-tcg.x86_64 ... OK
Huge thanks to Martin, who helped me realize (in 2/3) that 'struct
dirent' while declared as 'char d_name[256]' is rather peculiar and a
little dance is needed to copy it properly.
Michal Prívozník (3):
util: Introduce a wrapper struct around DIR
util: Introduce virDirOpenSorted()
tests: Use virDirOpenSorted()
build-aux/syntax-check.mk | 2 +-
src/bhyve/bhyve_capabilities.c | 2 +-
src/bhyve/bhyve_firmware.c | 2 +-
src/conf/capabilities.c | 8 +-
src/conf/virdomainobjlist.c | 2 +-
src/conf/virnetworkobj.c | 8 +-
src/conf/virnwfilterbindingobjlist.c | 2 +-
src/conf/virnwfilterobj.c | 2 +-
src/conf/virsecretobj.c | 2 +-
src/conf/virstorageobj.c | 4 +-
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 2 +-
src/openvz/openvz_conf.c | 2 +-
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_interop_config.c | 2 +-
src/security/security_selinux.c | 4 +-
src/storage/storage_backend_iscsi.c | 2 +-
src/storage/storage_util.c | 10 +-
src/util/vircgroup.c | 4 +-
src/util/vircgroupv1.c | 2 +-
src/util/vircommand.c | 2 +-
src/util/virdevmapper.c | 2 +-
src/util/virfile.c | 146 ++++++++++++++++++++++-----
src/util/virfile.h | 16 +--
src/util/virhook.c | 4 +-
src/util/virhostcpu.c | 6 +-
src/util/virmdev.c | 4 +-
src/util/virnetdev.c | 2 +-
src/util/virnuma.c | 2 +-
src/util/virpci.c | 8 +-
src/util/virprocess.c | 2 +-
src/util/virresctrl.c | 8 +-
src/util/virscsi.c | 4 +-
src/util/virscsihost.c | 2 +-
src/util/virusb.c | 2 +-
src/util/virutil.c | 4 +-
src/util/virvhba.c | 6 +-
tests/testutilsqemu.c | 8 +-
tests/virschematest.c | 4 +-
tools/virt-host-validate-common.c | 2 +-
41 files changed, 201 insertions(+), 102 deletions(-)
--
2.38.2
2 years