[PATCH 2/2] qemu: support for virtio-blk-pci discard options
by yuxiating
DISCARD and WRITE_ZEROES features for machine type >= 4.0 is enabled by default since
commit 5c81161f804144b146607f890e84613a4cbad95c
virtio-blk: add "discard" and "write-zeroes" properties
Sometimes guestos has bugs DISCARD need to be disabled.
Signed-off-by: yuxiating <yuxiating(a)huawei.com>
---
src/conf/domain_conf.c | 15 +++++++++++++++
src/conf/domain_conf.h | 9 +++++++++
src/conf/domain_validate.c | 6 ++++++
src/libvirt_private.syms | 3 ++-
src/qemu/qemu_command.c | 11 +++++++++++
5 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6127513117..bfe4721e60 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1278,6 +1278,13 @@ VIR_ENUM_IMPL(virDomainDiskDiscard,
"ignore",
);
+VIR_ENUM_IMPL(virDomainDiskDiscardEnable,
+ VIR_DOMAIN_DISK_DISCARD_ENABLE_LAST,
+ "default",
+ "off",
+ "on",
+);
+
VIR_ENUM_IMPL(virDomainDiskDetectZeroes,
VIR_DOMAIN_DISK_DETECT_ZEROES_LAST,
"default",
@@ -8930,6 +8937,10 @@ virDomainDiskDefDriverParseXML(virDomainDiskDef *def,
if (virXMLPropUInt(cur, "queues", 10, VIR_XML_PROP_NONE, &def->queues) < 0)
return -1;
+ if (virXMLPropEnum(cur, "discard_enable", virDomainDiskDiscardEnableTypeFromString,
+ VIR_XML_PROP_NONZERO, &def->discard_enable) < 0)
+ return -1;
+
return 0;
}
@@ -23416,6 +23427,10 @@ virDomainDiskDefFormatDriver(virBuffer *buf,
if (disk->queues)
virBufferAsprintf(&attrBuf, " queues='%u'", disk->queues);
+ if (disk->discard_enable)
+ virBufferAsprintf(&attrBuf, " discard_enable='%s'",
+ virDomainDiskDiscardEnableTypeToString(disk->discard_enable));
+
virDomainVirtioOptionsFormat(&attrBuf, disk->virtio);
if (disk->src->metadataCacheMaxSize > 0) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c7e6df7981..c39694a19e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -457,6 +457,13 @@ typedef enum {
VIR_DOMAIN_DISK_DISCARD_LAST
} virDomainDiskDiscard;
+typedef enum {
+ VIR_DOMAIN_DISK_DISCARD_ENABLE_DEFAULT = 0,
+ VIR_DOMAIN_DISK_DISCARD_ENABLE_OFF,
+ VIR_DOMAIN_DISK_DISCARD_ENABLE_ON,
+ VIR_DOMAIN_DISK_DISCARD_ENABLE_LAST
+} virDomainDiskDiscardEnable;
+
typedef enum {
VIR_DOMAIN_DISK_DETECT_ZEROES_DEFAULT = 0,
VIR_DOMAIN_DISK_DETECT_ZEROES_OFF,
@@ -589,6 +596,7 @@ struct _virDomainDiskDef {
bool diskElementAuth;
bool diskElementEnc;
+ virDomainDiskDiscardEnable discard_enable;
};
@@ -3838,6 +3846,7 @@ VIR_ENUM_DECL(virDomainDiskIo);
VIR_ENUM_DECL(virDomainDeviceSGIO);
VIR_ENUM_DECL(virDomainDiskTray);
VIR_ENUM_DECL(virDomainDiskDiscard);
+VIR_ENUM_DECL(virDomainDiskDiscardEnable);
VIR_ENUM_DECL(virDomainDiskDetectZeroes);
VIR_ENUM_DECL(virDomainDiskModel);
VIR_ENUM_DECL(virDomainDiskMirrorState);
diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c
index 60f7ccdddd..6eb346916a 100644
--- a/src/conf/domain_validate.c
+++ b/src/conf/domain_validate.c
@@ -612,6 +612,12 @@ virDomainDiskDefValidate(const virDomainDef *def,
return -1;
}
+ if (disk->discard_enable) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("discard_enable attribute in disk driver element is only supported by virtio-blk"));
+ return -1;
+ }
+
if (disk->event_idx != VIR_TRISTATE_SWITCH_ABSENT) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk event_idx mode supported only for virtio bus"));
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ab8a6c00c3..52a74dd2d5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1,5 +1,5 @@
-#
# General private symbols. Add symbols here, and see src/meson.build for
+# mainDiskDeviceTypeToString
# more details.
#
# Keep this file sorted by header name, then by symbols with each header.
@@ -377,6 +377,7 @@ virDomainDiskDefParseSource;
virDomainDiskDetectZeroesTypeFromString;
virDomainDiskDetectZeroesTypeToString;
virDomainDiskDeviceTypeToString;
+virDomainDiskDiscardEnableTypeToString;
virDomainDiskDiscardTypeToString;
virDomainDiskEmptySource;
virDomainDiskErrorPolicyTypeFromString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b230314f7f..894c8b17b9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1739,6 +1739,17 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
virBufferAsprintf(&opt, ",num-queues=%u", disk->queues);
}
+ if (disk->discard_enable) {
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_DISCARD)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("virtio-blk discard property isn't supported by this "
+ "QEMU binary"));
+ return NULL;
+ }
+ virBufferAsprintf(&opt, ",discard=%s",
+ virDomainDiskDiscardEnableTypeToString(disk->discard_enable));
+ }
+
qemuBuildVirtioOptionsStr(&opt, disk->virtio);
if (qemuBuildDeviceAddressStr(&opt, def, &disk->info) < 0)
--
2.27.0
3 years, 2 months
RBD encryption support in libvirt
by Or Ozeri
Hi,
I wanted to get your advice on a patch I'm preparing for libvirt.
It touches the code-path that allows using LUKS encryption on top of an RBD image.
We recently added LUKS and LUKS2 encryption support in Ceph's librbd.
We exposed this in qemu in a recent patch by adding new optional "encrypt" member to BlockdevOptionsRbd.
This patch was included in the recent release of qemu 6.1.
To enable libvirt users to use librbd encryption, we need libvirt to use this new "encrypt" when it builds the blockdev options for RBD.
The interesting question is how to define the libvirt XML syntax that will trigger the use of librbd encryption.
My thought was to use the already existing <encryption> tag.
In that case, we just need to add a new format VIR_STORAGE_ENCRYPTION_FORMAT_LUKS2 to the enum virStorageEncryptionFormatType.
This type will be checked in qemuBlockStorageSourceGetRBDProps.
The problem with this approach is that it only works for LUKS2.
librbd encryption also supports LUKS1.
We want to allow the user to choose between the qemu LUKS implementation and the librbd one.
One reason to keep support both is that on the one hand librbd only supports XTS mode.
On the other hand, qemu implementation will not support a chain of uniquely encrypted RBD images (each serving as a backing store for the previous one).
So we need a way in the XML API to support both implementations.
Our current thought is to add a new "engine" attribute to the encryption tag.
By default, encryption will use the QEMU LUKS implementation, unless <encryption engine='rbd' ...> is specified.
To make this more general, we can have engine='backend' instead of engine='rbd' to denote that the encryption is to be delegated to the backend storage properties (instead of the format properties).
This way, the encryption tag will only be parsed in the flow of qemuBlockStorageSourceGetBackendProps, instead of in qemuBlockStorageSourceGetBlockdevProps
We'll appreciate any feedback you have on this.
Thanks,
Or
3 years, 2 months
[PULL 21/22] docs/deprecated: deprecate passing plugin args through `arg=`
by Alex Bennée
From: Mahmoud Mandour <ma.mandourr(a)gmail.com>
Signed-off-by: Mahmoud Mandour <ma.mandourr(a)gmail.com>
Message-Id: <20210802134414.52037-1-ma.mandourr(a)gmail.com>
Reviewed-by: Alex Bennée <alex.bennee(a)linaro.org>
[AJB: fixed up move of deprecated.rst]
Signed-off-by: Alex Bennée <alex.bennee(a)linaro.org>
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 1e1a5e96ad..6e88a84bba 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -139,6 +139,18 @@ The ``-no-quit`` is a synonym for ``-display ...,window-close=off`` which
should be used instead.
+Plugin argument passing through ``arg=<string>`` (since 6.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+Passing TCG plugins arguments through ``arg=`` is redundant is makes the
+command-line less readable, especially when the argument itself consist of a
+name and a value, e.g. ``-plugin plugin_name,arg="arg_name=arg_value"``.
+Therefore, the usage of ``arg`` is redundant. Single-word arguments are treated
+as short-form boolean values, and passed to plugins as ``arg_name=on``.
+However, short-form booleans are deprecated and full explicit ``arg_name=on``
+form is preferred.
+
+
QEMU Machine Protocol (QMP) commands
------------------------------------
--
2.30.2
3 years, 2 months
[PATCH 0/6] network create: add support for validation against schema
by Kristina Hanicova
Kristina Hanicova (6):
api: add public virNetworkCreateXMLFlags() and remote protocol
src: add driver support for networkCreateXMLFlags()
api: add virNetworkCreateFlags
network_conf: add validation against schema in create
network: allow VIR_NETWORK_CREATE_VALIDATE flag
virsh: add support for '--validate' option in create network
docs/manpages/virsh.rst | 4 ++-
include/libvirt/libvirt-network.h | 7 ++++++
src/conf/network_conf.c | 3 ++-
src/driver-network.h | 6 +++++
src/libvirt-network.c | 41 +++++++++++++++++++++++++++++++
src/libvirt_public.syms | 5 ++++
src/network/bridge_driver.c | 20 ++++++++++++---
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 18 +++++++++++++-
src/remote_protocol-structs | 8 ++++++
src/test/test_driver.c | 15 +++++++++--
src/vbox/vbox_network.c | 10 +++++++-
tools/virsh-network.c | 13 +++++++++-
13 files changed, 140 insertions(+), 11 deletions(-)
--
2.31.1
3 years, 2 months
[PATCH 0/4] nwfilter-binding create: add support for validation against schema
by Kristina Hanicova
Kristina Hanicova (4):
api: add virNWFilterBindingCreateFlags
conf: virnwfilterbindingdef: add validation against schema in create
nwfilter_driver: allow VIR_NWFILTER_BINDING_CREATE_VALIDATE flag
virsh: add support for '--validate' option in create nwfilter-binding
docs/manpages/virsh.rst | 5 ++++-
include/libvirt/libvirt-nwfilter.h | 5 +++++
src/conf/virnwfilterbindingdef.c | 14 +++++++++-----
src/conf/virnwfilterbindingdef.h | 3 ++-
src/libvirt-nwfilter.c | 2 +-
src/nwfilter/nwfilter_driver.c | 4 ++--
tools/virsh-nwfilter.c | 10 +++++++++-
7 files changed, 32 insertions(+), 11 deletions(-)
--
2.31.1
3 years, 2 months
[PATCH 0/4] network port create: add support for validation against schema
by Kristina Hanicova
Kristina Hanicova (4):
api: add VIR_NETWORK_PORT_CREATE_VALIDATE flag
conf: virnetworkportdef: add validation against schema in network port
create
bridge_driver: allow VIR_NETWORK_PORT_CREATE_VALIDATE flag
virsh: add support for '--validate' option in create network port
docs/manpages/virsh.rst | 4 +++-
include/libvirt/libvirt-network.h | 1 +
src/conf/domain_conf.c | 2 +-
src/conf/virnetworkportdef.c | 14 +++++++++-----
src/conf/virnetworkportdef.h | 3 ++-
src/libvirt-network.c | 2 +-
src/network/bridge_driver.c | 5 +++--
tools/virsh-network.c | 10 +++++++++-
8 files changed, 29 insertions(+), 12 deletions(-)
--
2.31.1
3 years, 2 months
[PATCH v3 0/5] Implement some job related APIs for test driver
by Luke Yue
v3:
- Fix virDomainGetJobStats when use completed flags
- Introduce testDomainSetDummyData
- Add and refine some tests
Luke Yue (5):
test_driver: Implement virDomainGetJobInfo
test_driver: Implement virDomainGetJobStats
test_driver: Implement virDomainAbortJob
test_driver: Introduce testDomainSetDummyData
virshtest: add test for domjobinfo and domjobabort
src/test/test_driver.c | 274 +++++++++++++++++++++++++++++++++++++++++
tests/virshtest.c | 89 +++++++++++++
2 files changed, 363 insertions(+)
--
2.32.0
3 years, 2 months
[libvirt PATCH v2 0/1] Add a PCI/PCIe device VPD Capability
by Dmitrii Shcherbakov
Add support for deserializing the binary PCI/PCIe VPD format and
exposing VPD resources as XML elements in a new nested capability
of PCI/PCIe devices called 'vpd'.
The VPD format is specified in "I.3. VPD Definitions" in PCI specs
(2.2+) and "6.28.1 VPD Format" PCIe 4.0. As section 6.28 in PCIe 4.0
notes, the PCI Local Bus and PCIe VPD formats are binary compatible
and PCIe 4.0 merely started incorporating what was already present in
PCI specs.
Linux kernel exposes a binary blob in the VPD format via sysfs since
v2.6.26 (commit 94e6108803469a37ee1e3c92dafdd1d59298602f) which requires
a parser to interpret.
There are usage scenarios where information such as the board serial
number needs to be retrieved from PCI(e) VPD. Projects like Nova can
utilize this information for cases which involve virtual interface
plugging on SmartNIC DPUs but there may be other scenarios and types of
information useful to retrieve from VPD. The fact that the format is
binary requires proper parsing instead of substring searching hence the
full parser is proposed. Likewise, checksum validation requires proper
parsing as well.
The patch follows a prior discussion on the mailing list which has
additional context about the use-case but a narrower proposal:
https://listman.redhat.com/archives/libvir-list/2021-May/msg00873.html
https://www.mail-archive.com/libvir-list@redhat.com/msg218165.html
The new functionality is mostly contained in virpcivpd with a
couple of new functions added to virpci. Additionally, the necessary XML
serialization/deserialization and glue code is added to expose the VPD
capability to external clients as XML.
A new capability flag is added along with a new capability in order to
allow for filtering of PCI devices with the VPD capability using virsh:
virsh nodedev-list --cap vpd
sudo virsh nodedev-dumpxml --device pci_dddd_bb_ss_f
In this example having the root uid is required in order to access the
vpd sysfs entry, therefore, the nodedev XML output will only contain
the VPD capability if virsh is run as root.
The capability is treated as dynamic due to the presence of read-write
sections in the VPD format per PCI/PCIe specs (the idea being that
read-write resource fields may potentially be altered by the DPU OS
over time independently from the host OS).
Unit tests cover the parser functionality (including many possible
invalid cases), in-memory representation as well as XML serialization
and deserialization.
Manual functional testing was performed with 2 DPUs and several other
NIC models which expose PCI(e) VPD. Testing have also been performed
for devices that do not have VPD or those that expose a VPD capability
but exhibit invalid behavior (I/O errors while reading a sysfs entry).
Per the existing guidelines, the implementation relies heavily on glib
for various purposes.
https://libvirt.org/glib-adoption.html
The v2 of the patch is rebased on top of Libvirt 7.7.0 and fixes a
couple of minor typos.
Dmitrii Shcherbakov (1):
Add a PCI/PCIe device VPD Capability
build-aux/syntax-check.mk | 4 +-
docs/drvnodedev.html.in | 46 ++
docs/formatnode.html.in | 24 +-
docs/schemas/nodedev.rng | 40 +
include/libvirt/libvirt-nodedev.h | 1 +
po/POTFILES.in | 1 +
src/conf/node_device_conf.c | 258 ++++++
src/conf/node_device_conf.h | 6 +-
src/conf/virnodedeviceobj.c | 7 +-
src/libvirt_private.syms | 17 +
src/node_device/node_device_driver.c | 2 +
src/node_device/node_device_udev.c | 2 +
src/util/meson.build | 1 +
src/util/virpci.c | 60 ++
src/util/virpci.h | 3 +
src/util/virpcivpd.c | 771 +++++++++++++++++
src/util/virpcivpd.h | 106 +++
src/util/virpcivpdpriv.h | 42 +
tests/meson.build | 1 +
.../pci_0000_42_00_0_vpd.xml | 33 +
.../pci_0000_42_00_0_vpd.xml | 1 +
tests/nodedevxml2xmltest.c | 1 +
tests/testutils.c | 51 ++
tests/testutils.h | 6 +
tests/virpcitest.c | 3 +
tests/virpcivpdtest.c | 777 ++++++++++++++++++
tools/virsh-nodedev.c | 3 +
27 files changed, 2262 insertions(+), 5 deletions(-)
create mode 100644 src/util/virpcivpd.c
create mode 100644 src/util/virpcivpd.h
create mode 100644 src/util/virpcivpdpriv.h
create mode 100644 tests/nodedevschemadata/pci_0000_42_00_0_vpd.xml
create mode 120000 tests/nodedevxml2xmlout/pci_0000_42_00_0_vpd.xml
create mode 100644 tests/virpcivpdtest.c
--
2.30.2
3 years, 2 months
[PATCH v3 0/8] ch: Add Console support
by William Douglas
This series enables console support in the cloud-hypervisor driver.
Cloud-hypervisor only supports a single console or serial device at a
time, hence the checks to ensure the domain configuration is only
passing one or the other.
Changes since v2:
* Squashed an additional patch.
Changes since v1:
* Added missing patch to add the virChrdev device
* Added handling for multiple curl WRITEFUNCTION call backs
* Added missing free for data.content
* Removed redundant console configuration check
* Improved handling of pty JSON data to make use of g_autoptr
* Squashed two patches
William Douglas (8):
ch_domain: Add virChrdevs for console support
ch_monitor: Make unused function static
ch_monitor: Update virCHMonitorGet to handle accept a response
ch_monitor: Use virCHMonitorGet to access cloud-hypervisor API
ch_monitor: Add pty json builder function
ch_process: Handle enabled console devices
ch_domain: Allow controller and chr devices
ch_driver: Add handler for console API
src/ch/ch_domain.c | 11 ++++-
src/ch/ch_domain.h | 3 ++
src/ch/ch_driver.c | 78 +++++++++++++++++++++++++++++
src/ch/ch_monitor.c | 118 ++++++++++++++++++++++++++++++++++++++++++--
src/ch/ch_monitor.h | 3 ++
src/ch/ch_process.c | 67 +++++++++++++++++++++++++
6 files changed, 274 insertions(+), 6 deletions(-)
--
2.31.1
3 years, 2 months
[PATCH v2 1/2] qemu: process: Split out the statement to handle the qemu is allowed to reboot
by Masayoshi Mizuma
From: Masayoshi Mizuma <m.mizuma(a)jp.fujitsu.com>
Split out the statement to handle whether the qemu is allowed to reboot
or not. So that it gets available for the later patch.
Signed-off-by: Masayoshi Mizuma <m.mizuma(a)jp.fujitsu.com>
---
src/qemu/qemu_process.c | 17 +++++++++++++----
src/qemu/qemu_process.h | 2 ++
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3b4af61bf8..f4e67c70ad 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6360,6 +6360,18 @@ qemuProcessPrepareHostHostdevs(virDomainObj *vm)
return 0;
}
+bool
+qemuProcessRebootAllowed(const virDomainDef *def)
+{
+ if (def->onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY &&
+ def->onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY &&
+ (def->onCrash == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY ||
+ def->onCrash == VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)) {
+ return false;
+ } else {
+ return true;
+ }
+}
static void
qemuProcessPrepareAllowReboot(virDomainObj *vm)
@@ -6375,10 +6387,7 @@ qemuProcessPrepareAllowReboot(virDomainObj *vm)
if (priv->allowReboot != VIR_TRISTATE_BOOL_ABSENT)
return;
- if (def->onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY &&
- def->onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY &&
- (def->onCrash == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY ||
- def->onCrash == VIR_DOMAIN_LIFECYCLE_ACTION_COREDUMP_DESTROY)) {
+ if (!qemuProcessRebootAllowed(def)) {
priv->allowReboot = VIR_TRISTATE_BOOL_NO;
} else {
priv->allowReboot = VIR_TRISTATE_BOOL_YES;
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 93103eb530..f9fa140e6d 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -242,3 +242,5 @@ void qemuProcessQMPFree(qemuProcessQMP *proc);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuProcessQMP, qemuProcessQMPFree);
int qemuProcessQMPStart(qemuProcessQMP *proc);
+
+bool qemuProcessRebootAllowed(const virDomainDef *def);
--
2.27.0
3 years, 2 months