[PATCH] libvirt: add memory failure event

2020-10-09 Thread zhenwei pi
Since QEMU 5.2 (commit-77b285f7f6), QEMU supports 'memory failure'
event, posts event to monitor if hitting a hardware memory error.

Several changes in this patch:
  Add a new event 'memory failure' for libvirt domain.
  Implement memory failure event handling for QEMU from QMP.
  Also implement virsh command callback functions.

Test case:
~# virsh event stretch --event memory-failure
event 'memory-failure' for domain stretch:
recipient: guest
action: inject
flags:
action required: 0
recursive: 0
events received: 1

Signed-off-by: zhenwei pi 
---
 examples/c/misc/event-test.c| 17 
 include/libvirt/libvirt-domain.h| 84 +
 src/conf/domain_event.c | 82 
 src/conf/domain_event.h | 12 ++
 src/libvirt_private.syms|  2 +
 src/qemu/qemu_domain.c  |  1 +
 src/qemu/qemu_domain.h  |  1 +
 src/qemu/qemu_driver.c  | 57 +
 src/qemu/qemu_monitor.c | 21 +-
 src/qemu/qemu_monitor.h | 39 +
 src/qemu/qemu_monitor_json.c| 50 ++
 src/qemu/qemu_process.c | 28 +
 src/remote/remote_daemon_dispatch.c | 33 +++
 src/remote/remote_driver.c  | 35 
 src/remote/remote_protocol.x| 21 +-
 src/remote_protocol-structs | 12 ++
 tools/virsh-domain.c| 37 
 17 files changed, 530 insertions(+), 2 deletions(-)

diff --git a/examples/c/misc/event-test.c b/examples/c/misc/event-test.c
index 52caa8ffa8..b10946d569 100644
--- a/examples/c/misc/event-test.c
+++ b/examples/c/misc/event-test.c
@@ -964,6 +964,22 @@ myDomainEventBlockThresholdCallback(virConnectPtr conn 
G_GNUC_UNUSED,
 
 
 static int
+myDomainEventMemoryFailureCallback(virConnectPtr conn G_GNUC_UNUSED,
+   virDomainPtr dom,
+   virDomainMemoryFailureRecipientType 
recipient,
+   virDomainMemoryFailureActionType action,
+   virDomainMemoryFailureFlagsPtr flags,
+   void *opaque G_GNUC_UNUSED)
+{
+printf("%s EVENT: Domain %s(%d) memory failure: recipient '%d', "
+   "aciont '%d', action_required '%d', recursive '%d'",
+   __func__, virDomainGetName(dom), virDomainGetID(dom), recipient,
+   action, flags->action_required, flags->recursive);
+return 0;
+}
+
+
+static int
 myDomainEventMigrationIterationCallback(virConnectPtr conn G_GNUC_UNUSED,
 virDomainPtr dom,
 int iteration,
@@ -1093,6 +1109,7 @@ struct domainEventData domainEvents[] = {
 DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_DEVICE_REMOVAL_FAILED, 
myDomainEventDeviceRemovalFailedCallback),
 DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_METADATA_CHANGE, 
myDomainEventMetadataChangeCallback),
 DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD, 
myDomainEventBlockThresholdCallback),
+DOMAIN_EVENT(VIR_DOMAIN_EVENT_ID_MEMORY_FAILURE, 
myDomainEventMemoryFailureCallback),
 };
 
 struct storagePoolEventData {
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 77f9116675..a9170d9a7e 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -3196,6 +3196,66 @@ typedef enum {
 } virDomainEventCrashedDetailType;
 
 /**
+ * virDomainMemoryFailureRecipientType:
+ *
+ * Recipient of a memory failure event.
+ */
+typedef enum {
+/* memory failure at hypersivor memory address space */
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_RECIPIENT_HYPERVISOR = 0,
+
+/* memory failure at guest memory address space */
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_RECIPIENT_GUEST = 1,
+
+# ifdef VIR_ENUM_SENTINELS
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_RECIPIENT_LAST
+# endif
+} virDomainMemoryFailureRecipientType;
+
+
+/**
+ * virDomainMemoryFailureActionType:
+ *
+ * Action of a memory failure event.
+ */
+typedef enum {
+/* the memory failure could be ignored. This will only be the case for
+ * action-optional failures. */
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_ACTION_IGNORE = 0,
+
+/* memory failure occurred in guest memory, the guest enabled MCE handling
+ * mechanism, and hypervisor could inject the MCE into the guest
+ * successfully. */
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_ACTION_INJECT = 1,
+
+/* the failure is unrecoverable.  This occurs for action-required failures
+ * if the recipient is the hypervisor; hypervisor will exit. */
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_ACTION_FATAL = 2,
+
+/* the failure is unrecoverable but confined to the guest. This occurs if
+ * the recipient is a guest which is not ready to handle memory failures. 
*/
+VIR_DOMAIN_EVENT_MEMORY_FAILURE_ACTION_RESET = 3,
+
+# ifdef VI

[PATCH 3/3] news: document bhyve virtio-9p support

2020-10-09 Thread Roman Bogorodskiy
Signed-off-by: Roman Bogorodskiy 
---
 NEWS.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/NEWS.rst b/NEWS.rst
index e708f06e9e..bc35458f38 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -25,6 +25,10 @@ v6.9.0 (unreleased)
 ``virConnectGetVersion()``, and ``virDomainGetAutostart()`` APIs have been
 implemented in the Hyper-V driver.
 
+  * bhyve: implement virtio-9p filesystem support
+
+Implement virito-9p shared filesystem using the  element.
+
 * **Improvements**
 
 * **Bug fixes**
-- 
2.28.0



[PATCH 1/3] bhyve: fix virtio-9p src/dst order

2020-10-09 Thread Roman Bogorodskiy
For the virtio-9p bhyve command line argument, the proper order
is mount_tag=/path/to/host/dir, not the opposite.

Signed-off-by: Roman Bogorodskiy 
---
 src/bhyve/bhyve_command.c | 2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args | 2 +-
 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c
index 7606840f45..acf3a5a433 100644
--- a/src/bhyve/bhyve_command.c
+++ b/src/bhyve/bhyve_command.c
@@ -607,8 +607,8 @@ bhyveBuildFSArgStr(const virDomainDef *def G_GNUC_UNUSED,
 virCommandAddArgFormat(cmd, "%d:%d,virtio-9p,%s=%s%s",
fs->info.addr.pci.slot,
fs->info.addr.pci.function,
-   fs->src->path,
fs->dst,
+   fs->src->path,
virBufferCurrentContent(¶ms));
 
 return 0;
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args
index 193895574d..bfcd88e366 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args
@@ -7,4 +7,4 @@
 -s 0:0,hostbridge \
 -s 2:0,ahci,hd:/tmp/freebsd.img \
 -s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
--s 4:0,virtio-9p,/shared/dir=shared_dir,ro bhyve
+-s 4:0,virtio-9p,shared_dir=/shared/dir,ro bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args
index 0d27954432..e890f7400b 100644
--- a/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args
@@ -7,4 +7,4 @@
 -s 0:0,hostbridge \
 -s 2:0,ahci,hd:/tmp/freebsd.img \
 -s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \
--s 4:0,virtio-9p,/shared/dir=shared_dir bhyve
+-s 4:0,virtio-9p,shared_dir=/shared/dir bhyve
-- 
2.28.0



[PATCH 2/3] docs: bhyve: document virtio-9p support

2020-10-09 Thread Roman Bogorodskiy
Signed-off-by: Roman Bogorodskiy 
---
 docs/drvbhyve.html.in | 21 +
 1 file changed, 21 insertions(+)

diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in
index 49d4aa5878..228e8b2bd5 100644
--- a/docs/drvbhyve.html.in
+++ b/docs/drvbhyve.html.in
@@ -482,6 +482,27 @@ to the guest, with ich7 being the only 
supported model now,
 and the audio element specifies how the guest device is mapped
 to the host sound device.
 
+Virtio-9p filesystem
+
+As of https://svnweb.freebsd.org/changeset/base/366413";>FreeBSD 
changeset r366413
+bhyve supports sharing arbitrary directory tree between the guest and the host.
+It's supported in libvirt since 6.9.0.
+
+
+...
+  
+
+
+  
+...
+
+
+This share could be made read only by adding the 
 sub-element.
+
+In the Linux guest, this could be mounted using:
+
+mount -t 9p shared_dir /mnt/shared_dir
+
 Wiring guest memory
 
 Since 4.4.0, it's possible to specify that guest 
memory should
-- 
2.28.0



[PATCH] virsocketaddr: Zero @netmask in virSocketAddrPrefixToNetmask()

2020-10-09 Thread Michal Privoznik
The aim of virSocketAddrPrefixToNetmask() is to initialize passed
virSocketAddr structure based on prefix length and family.
However, it doesn't set all members in the struct which may lead
to reads of uninitialized values:

==15421== Use of uninitialised value of size 8
==15421==at 0x50F297A: _itoa_word (in /lib64/libc-2.31.so)
==15421==by 0x510C8FE: __vfprintf_internal (in /lib64/libc-2.31.so)
==15421==by 0x5120295: __vsnprintf_internal (in /lib64/libc-2.31.so)
==15421==by 0x50F8969: snprintf (in /lib64/libc-2.31.so)
==15421==by 0x51BB602: getnameinfo (in /lib64/libc-2.31.so)
==15421==by 0x496DEE0: virSocketAddrFormatFull (virsocketaddr.c:486)
==15421==by 0x496DD9F: virSocketAddrFormat (virsocketaddr.c:444)
==15421==by 0x11871F: networkDnsmasqConfContents (bridge_driver.c:1404)
==15421==by 0x1118F5: testCompareXMLToConfFiles (networkxml2conftest.c:48)
==15421==by 0x111BAF: testCompareXMLToConfHelper (networkxml2conftest.c:112)
==15421==by 0x112679: virTestRun (testutils.c:142)
==15421==by 0x111D09: mymain (networkxml2conftest.c:144)
==15421==  Uninitialised value was created by a stack allocation
==15421==at 0x1175D2: networkDnsmasqConfContents (bridge_driver.c:1056)

All callers expect the function to initialize the structure
fully.

Signed-off-by: Michal Privoznik 
---
 src/util/virsocketaddr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index e0eb76ded3..65aaa632c7 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -1097,6 +1097,8 @@ virSocketAddrPrefixToNetmask(unsigned int prefix,
  virSocketAddrPtr netmask,
  int family)
 {
+memset(netmask, 0, sizeof(*netmask));
+
 netmask->data.stor.ss_family = AF_UNSPEC; /* assume failure */
 
 if (family == AF_INET) {
@@ -1135,7 +1137,7 @@ virSocketAddrPrefixToNetmask(unsigned int prefix,
 }
 
 return 0;
- }
+}
 
 /**
  * virSocketAddrGetIPPrefix:
-- 
2.26.2



[libvirt PATCH 2/3] qemu: process: sev: Fill missing 'cbitpos' & 'reducedPhysBits' from caps

2020-10-09 Thread Erik Skultety
These XML attributes have been mandatory since the introduction of SEV
support to libvirt. This design decision was based on QEMU's
requirement for these to be mandatory for migration purposes, as
differences in these values across platforms must result in the
pre-migration checks failing (not that migration with SEV works at the
time of this patch).

This patch enables autofill of these attributes right before launching
QEMU and thus updating the live XML.

Signed-off-by: Erik Skultety 
---
 src/conf/domain_conf.h  |  2 ++
 src/qemu/qemu_process.c | 40 
 2 files changed, 42 insertions(+)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 450686dfb5..344bb64081 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2490,7 +2490,9 @@ struct _virDomainSEVDef {
 char *dh_cert;
 char *session;
 unsigned int policy;
+bool haveCbitpos;
 unsigned int cbitpos;
+bool haveReducedPhysBits;
 unsigned int reduced_phys_bits;
 };
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2cc1d58266..35af0d11cd 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6233,6 +6233,40 @@ qemuProcessPrepareAllowReboot(virDomainObjPtr vm)
 }
 
 
+static int
+qemuProcessUpdateSEVInfo(virDomainObjPtr vm)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+virQEMUCapsPtr qemuCaps = priv->qemuCaps;
+virDomainSEVDefPtr sev = vm->def->sev;
+virSEVCapabilityPtr sevCaps = NULL;
+
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+_("Domain %s asked for 'sev' launch but this "
+  "QEMU does not support SEV feature"), vm->def->name);
+return -1;
+}
+
+/* if platform specific info like 'cbitpos' and 'reducedPhysBits' have
+ * not been supplied, we need to autofill them from caps now as both are
+ * mandatory on QEMU cmdline
+ */
+sevCaps = virQEMUCapsGetSEVCapabilities(qemuCaps);
+if (!sev->haveCbitpos) {
+sev->cbitpos = sevCaps->cbitpos;
+sev->haveCbitpos = true;
+}
+
+if (!sev->haveReducedPhysBits) {
+sev->reduced_phys_bits = sevCaps->reduced_phys_bits;
+sev->haveReducedPhysBits = true;
+}
+
+return 0;
+}
+
+
 /**
  * qemuProcessPrepareDomain:
  * @driver: qemu driver
@@ -6361,6 +6395,12 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
 for (i = 0; i < vm->def->nshmems; i++)
 qemuDomainPrepareShmemChardev(vm->def->shmems[i]);
 
+if (vm->def->sev) {
+VIR_DEBUG("Updating SEV platform info");
+if (qemuProcessUpdateSEVInfo(vm) < 0)
+return -1;
+}
+
 return 0;
 }
 
-- 
2.26.2



[libvirt PATCH 3/3] conf: domain: sev: Make 'cbitpos' & 'reducedPhysBits' attrs optional

2020-10-09 Thread Erik Skultety
These XML attributes have been mandatory since the introduction of SEV
support to libvirt. This design decision was based on QEMU's
requirement for these to be mandatory for migration purposes, as
differences in these values across platforms must result in the
pre-migration checks failing (not that migration with SEV works at the
time of this patch).

Expecting the user to specify these is cumbersome and the same XML
cannot be re-used across different revisions of SEV. Since
we have SEV platform information saved in QEMU capabilities, we can
make the attributes optional and should fill them in automatically
in the QEMU driver right before starting it.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/57

Signed-off-by: Erik Skultety 
---
 docs/schemas/domaincommon.rng | 16 ---
 src/conf/domain_conf.c| 46 ---
 ...v-missing-platform-info.x86_64-2.12.0.args | 37 +++
 ...nch-security-sev-missing-platform-info.xml | 35 ++
 tests/qemuxml2argvtest.c  |  1 +
 5 files changed, 113 insertions(+), 22 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.x86_64-2.12.0.args
 create mode 100644 
tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.xml

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 7d4b105981..9963fad4a6 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -467,12 +467,16 @@
 sev
   
   
-
-  
-
-
-  
-
+
+  
+
+  
+
+
+  
+
+  
+
 
   
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 51efeb0e42..648a47ac84 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16756,6 +16756,7 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode,
 virDomainSEVDefPtr def;
 unsigned long policy;
 g_autofree char *type = NULL;
+int rc = -1;
 
 def = g_new0(virDomainSEVDef, 1);
 
@@ -16780,25 +16781,35 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode,
 goto error;
 }
 
-if (virXPathUInt("string(./cbitpos)", ctxt, &def->cbitpos) < 0) {
-virReportError(VIR_ERR_XML_ERROR, "%s",
-   _("failed to get launch security cbitpos"));
-goto error;
-}
-
-if (virXPathUInt("string(./reducedPhysBits)", ctxt,
- &def->reduced_phys_bits) < 0) {
-virReportError(VIR_ERR_XML_ERROR, "%s",
-   _("failed to get launch security reduced-phys-bits"));
-goto error;
-}
-
 if (virXPathULongHex("string(./policy)", ctxt, &policy) < 0) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
_("failed to get launch security policy"));
 goto error;
 }
 
+/* the following attributes are platform dependent and if missing, we can
+ * autofill them from domain capabilities later
+ */
+rc = virXPathUInt("string(./cbitpos)", ctxt, &def->cbitpos);
+if (rc == 0) {
+def->haveCbitpos = VIR_TRISTATE_BOOL_YES;
+} else if (rc == -2) {
+virReportError(VIR_ERR_XML_ERROR, "%s",
+   _("Invalid format for launch security cbitpos"));
+goto error;
+}
+
+rc = virXPathUInt("string(./reducedPhysBits)", ctxt,
+  &def->reduced_phys_bits);
+if (rc == 0) {
+def->haveReducedPhysBits = VIR_TRISTATE_BOOL_YES;
+} else if (rc == -2) {
+virReportError(VIR_ERR_XML_ERROR, "%s",
+   _("Invalid format for launch security "
+ "reduced-phys-bits"));
+goto error;
+}
+
 def->policy = policy;
 def->dh_cert = virXPathString("string(./dhCert)", ctxt);
 def->session = virXPathString("string(./session)", ctxt);
@@ -28937,9 +28948,12 @@ virDomainSEVDefFormat(virBufferPtr buf, 
virDomainSEVDefPtr sev)
   virDomainLaunchSecurityTypeToString(sev->sectype));
 virBufferAdjustIndent(buf, 2);
 
-virBufferAsprintf(buf, "%d\n", sev->cbitpos);
-virBufferAsprintf(buf, "%d\n",
-  sev->reduced_phys_bits);
+if (sev->haveCbitpos)
+virBufferAsprintf(buf, "%d\n", sev->cbitpos);
+
+if (sev->haveReducedPhysBits)
+virBufferAsprintf(buf, "%d\n",
+  sev->reduced_phys_bits);
 virBufferAsprintf(buf, "0x%04x\n", sev->policy);
 if (sev->dh_cert)
 virBufferEscapeString(buf, "%s\n", sev->dh_cert);
diff --git 
a/tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.x86_64-2.12.0.args
 
b/tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.x86_64-2.12.0.args
new file mode 100644
index 00..378c3b681c
--- /dev/null
+++ 
b/tests/qemuxml2argvdata/launch-security-sev-missing-platform-info.x86_64-2.12.0.args
@@ -0,0 +

[libvirt PATCH 0/3] Make SEV 'cbitpos' and 'reducedPhysBits' attributes optional

2020-10-09 Thread Erik Skultety
We designed them as mandatory, but these are platform dependent and can be
filled from QEMU capabilities.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/57

Erik Skultety (3):
  qemu_process: sev: Drop an unused variable
  qemu: process: sev: Fill missing 'cbitpos' & 'reducedPhysBits' from
caps
  conf: domain: sev: Make 'cbitpos' & 'reducedPhysBits' attrs optional

 docs/schemas/domaincommon.rng | 16 ---
 src/conf/domain_conf.c| 46 ---
 src/conf/domain_conf.h|  2 +
 src/qemu/qemu_process.c   | 43 -
 ...v-missing-platform-info.x86_64-2.12.0.args | 37 +++
 ...nch-security-sev-missing-platform-info.xml | 35 ++
 tests/qemuxml2argvtest.c  |  1 +
 7 files changed, 156 insertions(+), 24 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/launch-security-sev-missing-platfo=
rm-info.x86_64-2.12.0.args
 create mode 100644 tests/qemuxml2argvdata/launch-security-sev-missing-platfo=
rm-info.xml

--=20
2.26.2




[libvirt PATCH 1/3] qemu_process: sev: Drop an unused variable

2020-10-09 Thread Erik Skultety
Signed-off-by: Erik Skultety 
---
 src/qemu/qemu_process.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6b5de29fdb..2cc1d58266 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6394,9 +6394,8 @@ static int
 qemuProcessPrepareSEVGuestInput(virDomainObjPtr vm)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
-virDomainDefPtr def = vm->def;
 virQEMUCapsPtr qemuCaps = priv->qemuCaps;
-virDomainSEVDefPtr sev = def->sev;
+virDomainSEVDefPtr sev = vm->def->sev;
 
 if (!sev)
 return 0;
-- 
2.26.2



Re: [PATCH 1/7] hyperv: implement domainSetAutostart

2020-10-09 Thread Matt Coleman
> On Oct 9, 2020, at 4:58 AM, Pino Toscano  wrote:
> 
> On Friday, 9 October 2020 10:31:50 CEST Matt Coleman wrote:
>> +static int
>> +hypervDomainSetAutostart(virDomainPtr domain, int autostart)
>> +{
>> +int result = -1;
>> +char uuid_string[VIR_UUID_STRING_BUFLEN];
>> +hypervPrivate *priv = domain->conn->privateData;
>> +Msvm_VirtualSystemSettingData *vssd = NULL;
>> +hypervInvokeParamsListPtr params = NULL;
>> +g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER;
>> +virHashTablePtr autostartParam = NULL;
>> +hypervWmiClassInfoListPtr embeddedParamClass = NULL;
>> +const char *methodName = NULL, *embeddedParamName = NULL;
>> +g_autofree char *enabledValue = NULL, *disabledValue = NULL;
>> +
>> +if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
>> +methodName = "ModifyVirtualSystem";
>> +embeddedParamName = "SystemSettingData";
>> +embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo;
>> +enabledValue = g_strdup("2");
>> +disabledValue = g_strdup("0");
>> +} else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
>> +methodName = "ModifySystemSettings";
>> +embeddedParamName = "SystemSettings";
>> +embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo;
>> +enabledValue = g_strdup("4");
>> +disabledValue = g_strdup("2");
>> +}
> 
> It looks like 'enabledValue' and 'disabledValue' can be static strings
> (like 'methodName' and 'embeddedParamName').

I removed g_autofree and g_strdup() with the following patch applied on 
top of my initial changes. Can it be squashed into this commit, or do I 
have to submit a [PATCH v2]?

Signed-off-by: Matt Coleman 
---
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index c91bc58488..baaace041b 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1450,20 +1450,18 @@ hypervDomainSetAutostart(virDomainPtr domain, int 
autostart)
 virHashTablePtr autostartParam = NULL;
 hypervWmiClassInfoListPtr embeddedParamClass = NULL;
 const char *methodName = NULL, *embeddedParamName = NULL;
-g_autofree char *enabledValue = NULL, *disabledValue = NULL;
+char enabledValue[] = "2", disabledValue[] = "0";
 
 if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
 methodName = "ModifyVirtualSystem";
 embeddedParamName = "SystemSettingData";
 embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo;
-enabledValue = g_strdup("2");
-disabledValue = g_strdup("0");
 } else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
 methodName = "ModifySystemSettings";
 embeddedParamName = "SystemSettings";
 embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo;
-enabledValue = g_strdup("4");
-disabledValue = g_strdup("2");
+enabledValue[0] = '4';
+disabledValue[0] = '2';
 }
 
 virUUIDFormat(domain->uuid, uuid_string);




Re: [libvirt PATCH 0/4] Some documentation fixes

2020-10-09 Thread Jiri Denemark
On Fri, Oct 09, 2020 at 12:47:16 +0200, Tim Wiederhake wrote:
> I encountered some references to a cpu_map.xml file which was
> moved to a subdirectory in commit 3ecbac95cd and split up in to
> different files in 2c127947ae and e6d7be38b9. This series removes
> all remaining references to this file and fixes an unrelated minor
> issue in the description of the "feature" element in the section
> about "cpu".
> 
> Tim Wiederhake (4):
>   tests: Remove references to "cpu_map.xml" in the code
>   qemu: Remove references to "cpu_map.xml" in the code
>   docs: Remove references to "cpu_map.xml" in the documentation
>   doc: Fix element name in description of "feature"
> 
>  docs/formatdomain.rst| 14 +++---
>  src/qemu/qemu_capabilities.c |  2 +-
>  tests/cputest.c  |  4 ++--
>  3 files changed, 10 insertions(+), 10 deletions(-)
> 
> -- 
> 2.26.2
> 
> 

Reviewed-by: Jiri Denemark 

and pushed, thanks.



[libvirt PATCH] docs: Expand on recommendation in hypervisor-cpu-baseline description

2020-10-09 Thread Tim Wiederhake
On some architectures, e.g. aarch64 and s390x, the output of
`virsh capabilities` is not suitable for use in
`virsh hypervisor-cpu-baseline`. Expand the description of the
man page to make this explicit.

https://bugzilla.redhat.com/show_bug.cgi?id=1850654

Signed-off-by: Tim Wiederhake 
---
 docs/manpages/virsh.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index 8fee4c7afe..d34a1c8684 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -976,8 +976,9 @@ as printed by ``capabilities`` command. The guest CPU 
definition may be created
 from the host CPU model found in domain capabilities XML (printed by
 ``domcapabilities`` command). In addition to the  elements, this command
 accepts full capabilities XMLs, or domain capabilities XMLs containing the CPU
-definitions. For best results, use only the CPU definitions from domain
-capabilities.
+definitions. It is recommended to use only the CPU definitions from domain
+capabilities, as on some architectures using the host CPU definition may either
+fail or provide unexpected results.
 
 When *FILE* contains only a single CPU definition, the command will print the
 same CPU with restrictions imposed by the capabilities of the hypervisor.
-- 
2.26.2



Re: [PATCH 5/7] hyperv: fix domainSuspend and domainResume on Hyper-V V2

2020-10-09 Thread Matt Coleman
> On Oct 9, 2020, at 4:43 AM, Daniel P. Berrangé  wrote:
> 
> On Fri, Oct 09, 2020 at 04:31:54AM -0400, Matt Coleman wrote:
>> Signed-off-by: Matt Coleman 
>> ---
>> src/hyperv/hyperv_driver.c  | 15 +++
>> src/hyperv/hyperv_wmi_classes.h |  1 +
>> 2 files changed, 12 insertions(+), 4 deletions(-)
>> 
>> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
>> index 0b28c1e94b..89840f7ac4 100644
>> --- a/src/hyperv/hyperv_driver.c
>> +++ b/src/hyperv/hyperv_driver.c
>> @@ -867,6 +867,10 @@ hypervDomainSuspend(virDomainPtr domain)
>> int result = -1;
>> hypervPrivate *priv = domain->conn->privateData;
>> Msvm_ComputerSystem *computerSystem = NULL;
>> +int requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED;
>> +
>> +if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
>> +requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
> 
> Is quiesce really what we want here ?
> 
> The libvirt  Suspend/Resume APIs are specifically about pausing
> execution of the guest CPUs.
> 
> IIUC, quiesce usually just refers to suspending I/O processing,
> in order to allow snapshots to be taken, but CPUs stay running.

I agree that it’s an odd name, but that’s how Microsoft chose to 
describe this RequestedState. It’s documented at the following link as...

"Quiesce (9)
Corresponds to CIM_EnabledLogicalElement.EnabledState = Quiesce, 
Enabled but paused."

https://docs.microsoft.com/en-us/windows/win32/hyperv_v2/requeststatechange-msvm-computersystem

I didn’t believe the documentation when I first read it, so I paused a 
VM in Hyper-V Manager and confirmed that its state was indeed Quiesce.

-- 
Matt




[PATCH 6/7] hyperv: fix domainManagedSave on Hyper-V V2

2020-10-09 Thread Matt Coleman
Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c  | 8 ++--
 src/hyperv/hyperv_wmi_classes.h | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 89840f7ac4..c91bc58488 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1645,6 +1645,10 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned 
int flags)
 hypervPrivate *priv = domain->conn->privateData;
 Msvm_ComputerSystem *computerSystem = NULL;
 bool in_transition = false;
+int requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_SUSPENDED;
+
+if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
+requestedState = 
MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED_BUT_OFFLINE;
 
 virCheckFlags(0, -1);
 
@@ -1658,8 +1662,8 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned int 
flags)
 goto cleanup;
 }
 
-result = hypervInvokeMsvmComputerSystemRequestStateChange
-   (domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_SUSPENDED);
+result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
+  requestedState);
 
  cleanup:
 hypervFreeObject(priv, (hypervObject *)computerSystem);
diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
index 0074d8889e..a5213901c8 100644
--- a/src/hyperv/hyperv_wmi_classes.h
+++ b/src/hyperv/hyperv_wmi_classes.h
@@ -73,6 +73,7 @@ enum _Msvm_ComputerSystem_EnabledState {
 enum _Msvm_ComputerSystem_RequestedState {
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED = 2,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED = 3,
+MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED_BUT_OFFLINE = 6,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE = 9,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT = 10,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET = 11,
-- 
2.27.0




[PATCH 5/7] hyperv: fix domainSuspend and domainResume on Hyper-V V2

2020-10-09 Thread Matt Coleman
Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c  | 15 +++
 src/hyperv/hyperv_wmi_classes.h |  1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 0b28c1e94b..89840f7ac4 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -867,6 +867,10 @@ hypervDomainSuspend(virDomainPtr domain)
 int result = -1;
 hypervPrivate *priv = domain->conn->privateData;
 Msvm_ComputerSystem *computerSystem = NULL;
+int requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED;
+
+if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
+requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
 
 if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
 goto cleanup;
@@ -878,8 +882,8 @@ hypervDomainSuspend(virDomainPtr domain)
 goto cleanup;
 }
 
-result = hypervInvokeMsvmComputerSystemRequestStateChange
-   (domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED);
+result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
+  requestedState);
 
  cleanup:
 hypervFreeObject(priv, (hypervObject *)computerSystem);
@@ -895,12 +899,15 @@ hypervDomainResume(virDomainPtr domain)
 int result = -1;
 hypervPrivate *priv = domain->conn->privateData;
 Msvm_ComputerSystem *computerSystem = NULL;
+int expectedState = MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED;
+
+if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
+expectedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
 
 if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
 goto cleanup;
 
-if (computerSystem->data.common->EnabledState !=
-MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) {
+if (computerSystem->data.common->EnabledState != expectedState) {
 virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Domain is not paused"));
 goto cleanup;
diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
index 7f4159dd8e..0074d8889e 100644
--- a/src/hyperv/hyperv_wmi_classes.h
+++ b/src/hyperv/hyperv_wmi_classes.h
@@ -73,6 +73,7 @@ enum _Msvm_ComputerSystem_EnabledState {
 enum _Msvm_ComputerSystem_RequestedState {
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED = 2,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED = 3,
+MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE = 9,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT = 10,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET = 11,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED = 32768,
-- 
2.27.0




[PATCH 7/7] news: more Hyper-V APIs

2020-10-09 Thread Matt Coleman
Signed-off-by: Matt Coleman 
---
 NEWS.rst | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/NEWS.rst b/NEWS.rst
index e708f06e9e..9404ed7809 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -22,8 +22,11 @@ v6.9.0 (unreleased)
   * hyperv: implement new APIs
 
 The ``virConnectGetCapabilities()``, ``virConnectGetMaxVcpus()``,
-``virConnectGetVersion()``, and ``virDomainGetAutostart()`` APIs have been
-implemented in the Hyper-V driver.
+``virConnectGetVersion()``, ``virDomainGetAutostart()``,
+``virDomainSetAutostart()``, ``virNodeGetFreeMemory()``,
+``virDomainReboot()``, ``virDomainReset()``, ``virDomainShutdown()``, and
+``virDomainShutdownFlags()`` APIs have been implemented in the Hyper-V
+driver.
 
 * **Improvements**
 
-- 
2.27.0




[PATCH 4/7] hyperv: implement domainShutdown and domainShutdownFlags

2020-10-09 Thread Matt Coleman
Co-authored-by: Sri Ramanujam 
Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c| 77 ++
 src/hyperv/hyperv_wmi_generator.input | 78 +++
 2 files changed, 155 insertions(+)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index ef0a5249c7..0b28c1e94b 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -917,6 +917,81 @@ hypervDomainResume(virDomainPtr domain)
 
 
 
+static int
+hypervDomainShutdownFlags(virDomainPtr domain, unsigned int flags)
+{
+int result = -1;
+hypervPrivate *priv = domain->conn->privateData;
+Msvm_ComputerSystem *computerSystem = NULL;
+Msvm_ShutdownComponent *shutdown = NULL;
+bool in_transition = false;
+char uuid[VIR_UUID_STRING_BUFLEN];
+g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER;
+hypervInvokeParamsListPtr params = NULL;
+g_autofree char *selector = NULL;
+
+virCheckFlags(0, -1);
+
+virUUIDFormat(domain->uuid, uuid);
+
+if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
+goto cleanup;
+
+if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) ||
+in_transition) {
+virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+   _("Domain is not active or in state transition"));
+goto cleanup;
+}
+
+virBufferEscapeSQL(&query,
+   MSVM_SHUTDOWNCOMPONENT_WQL_SELECT
+   "WHERE SystemName = '%s'", uuid);
+
+if (hypervGetWmiClass(Msvm_ShutdownComponent, &shutdown) < 0 ||
+!shutdown) {
+virReportError(VIR_ERR_OPERATION_FAILED,
+   _("Could not get Msvm_ShutdownComponent for domain with 
UUID '%s'"),
+   uuid);
+goto cleanup;
+}
+
+selector = g_strdup_printf(
+"CreationClassName=\"Msvm_ShutdownComponent\"&DeviceID=\"%s\"&"
+
"SystemCreationClassName=\"Msvm_ComputerSystem\"&SystemName=\"%s\"",
+shutdown->data.common->DeviceID, uuid);
+
+params = hypervCreateInvokeParamsList(priv, "InitiateShutdown", selector,
+  Msvm_ShutdownComponent_WmiInfo);
+
+hypervAddSimpleParam(params, "Force", "False");
+hypervAddSimpleParam(params, "Reason", _("Planned shutdown via libvirt"));
+
+if (hypervInvokeMethod(priv, params, NULL) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Could not shutdown domain with UUID '%s'"), uuid);
+goto cleanup;
+}
+
+result = 0;
+
+ cleanup:
+hypervFreeObject(priv, (hypervObject *) computerSystem);
+hypervFreeObject(priv, (hypervObject *) shutdown);
+
+return result;
+}
+
+
+
+static int
+hypervDomainShutdown(virDomainPtr domain)
+{
+return hypervDomainShutdownFlags(domain, 0);
+}
+
+
+
 static int
 hypervDomainReboot(virDomainPtr domain, unsigned int flags)
 {
@@ -2014,6 +2089,8 @@ static virHypervisorDriver hypervHypervisorDriver = {
 .domainLookupByName = hypervDomainLookupByName, /* 0.9.5 */
 .domainSuspend = hypervDomainSuspend, /* 0.9.5 */
 .domainResume = hypervDomainResume, /* 0.9.5 */
+.domainShutdown = hypervDomainShutdown, /* 6.9.0 */
+.domainShutdownFlags = hypervDomainShutdownFlags, /* 6.9.0 */
 .domainReboot = hypervDomainReboot, /* 6.9.0 */
 .domainReset = hypervDomainReset, /* 6.9.0 */
 .domainDestroy = hypervDomainDestroy, /* 0.9.5 */
diff --git a/src/hyperv/hyperv_wmi_generator.input 
b/src/hyperv/hyperv_wmi_generator.input
index bbca550790..1377138a12 100644
--- a/src/hyperv/hyperv_wmi_generator.input
+++ b/src/hyperv/hyperv_wmi_generator.input
@@ -1072,3 +1072,81 @@ class v2/Msvm_Keyboard
 uint16   Password
 boolean  UnicodeSupported
 end
+
+
+class Msvm_ShutdownComponent
+string   Caption
+string   Description
+string   ElementName
+datetime InstallDate
+string   Name
+uint16   OperationalStatus[]
+string   StatusDescriptions[]
+string   Status
+uint16   HealthState
+uint16   EnabledState
+string   OtherEnabledState
+uint16   RequestedState
+uint16   EnabledDefault
+datetime TimeOfLastStateChange
+string   SystemCreationClassName
+string   SystemName
+string   CreationClassName
+string   DeviceID
+boolean  PowerManagementSupported
+uint16   PowerManagementCapabilities[]
+uint16   Availability
+uint16   StatusInfo
+uint32   LastErrorCode
+string   ErrorDescription
+boolean  ErrorCleared
+string   OtherIdentifyingInfo[]
+uint64   PowerOnHours
+uint64   TotalPowerOnHours
+string   IdentifyingDescriptions[]
+uint16   AdditionalAvailability[]
+uint64   MaxQuiesceTime
+uint16   LocationIndicator
+end
+
+
+class v2/Msvm_ShutdownComponent
+string   InstanceID
+string   Caption
+string   Description
+string   ElementName
+datetime InstallDate
+string   Name
+

[PATCH 2/7] hyperv: implement nodeGetFreeMemory

2020-10-09 Thread Matt Coleman
Co-authored-by: Sri Ramanujam 
Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 6b2acbc405..7e2bc002bd 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1401,6 +1401,33 @@ hypervDomainSetAutostart(virDomainPtr domain, int 
autostart)
 
 
 
+static unsigned long long
+hypervNodeGetFreeMemory(virConnectPtr conn)
+{
+unsigned long long res = 0;
+hypervPrivate *priv = conn->privateData;
+Win32_OperatingSystem *operatingSystem = NULL;
+g_auto(virBuffer) query = { 
g_string_new(WIN32_OPERATINGSYSTEM_WQL_SELECT), 0 };
+
+if (hypervGetWmiClass(Win32_OperatingSystem, &operatingSystem) < 0 ||
+!operatingSystem) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Could not get free memory for host %s"),
+   conn->uri->server);
+goto cleanup;
+}
+
+/* Return free memory in bytes */
+res = operatingSystem->data.common->FreePhysicalMemory * 1024;
+
+cleanup:
+hypervFreeObject(priv, (hypervObject *) operatingSystem);
+
+return res;
+}
+
+
+
 static int
 hypervConnectIsEncrypted(virConnectPtr conn)
 {
@@ -1953,6 +1980,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
 .domainCreateWithFlags = hypervDomainCreateWithFlags, /* 0.9.5 */
 .domainGetAutostart = hypervDomainGetAutostart, /* 6.9.0 */
 .domainSetAutostart = hypervDomainSetAutostart, /* 6.9.0 */
+.nodeGetFreeMemory = hypervNodeGetFreeMemory, /* 6.9.0 */
 .connectIsEncrypted = hypervConnectIsEncrypted, /* 0.9.5 */
 .connectIsSecure = hypervConnectIsSecure, /* 0.9.5 */
 .domainIsActive = hypervDomainIsActive, /* 0.9.5 */
-- 
2.27.0




[PATCH 3/7] hyperv: implement domainReboot and domainReset

2020-10-09 Thread Matt Coleman
Co-authored-by: Sri Ramanujam 
Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c  | 48 +
 src/hyperv/hyperv_wmi_classes.h |  1 +
 2 files changed, 49 insertions(+)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 7e2bc002bd..ef0a5249c7 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -917,6 +917,52 @@ hypervDomainResume(virDomainPtr domain)
 
 
 
+static int
+hypervDomainReboot(virDomainPtr domain, unsigned int flags)
+{
+int result = -1;
+hypervPrivate *priv = domain->conn->privateData;
+Msvm_ComputerSystem *computerSystem = NULL;
+
+virCheckFlags(0, -1);
+
+if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
+goto cleanup;
+
+result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
+MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT);
+
+ cleanup:
+hypervFreeObject(priv, (hypervObject *)computerSystem);
+
+return result;
+}
+
+
+
+static int
+hypervDomainReset(virDomainPtr domain, unsigned int flags)
+{
+int result = -1;
+hypervPrivate *priv = domain->conn->privateData;
+Msvm_ComputerSystem *computerSystem = NULL;
+
+virCheckFlags(0, -1);
+
+if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
+goto cleanup;
+
+result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
+MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET);
+
+ cleanup:
+hypervFreeObject(priv, (hypervObject *)computerSystem);
+
+return result;
+}
+
+
+
 static int
 hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags)
 {
@@ -1968,6 +2014,8 @@ static virHypervisorDriver hypervHypervisorDriver = {
 .domainLookupByName = hypervDomainLookupByName, /* 0.9.5 */
 .domainSuspend = hypervDomainSuspend, /* 0.9.5 */
 .domainResume = hypervDomainResume, /* 0.9.5 */
+.domainReboot = hypervDomainReboot, /* 6.9.0 */
+.domainReset = hypervDomainReset, /* 6.9.0 */
 .domainDestroy = hypervDomainDestroy, /* 0.9.5 */
 .domainDestroyFlags = hypervDomainDestroyFlags, /* 0.9.5 */
 .domainGetOSType = hypervDomainGetOSType, /* 0.9.5 */
diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
index d32711589a..7f4159dd8e 100644
--- a/src/hyperv/hyperv_wmi_classes.h
+++ b/src/hyperv/hyperv_wmi_classes.h
@@ -74,6 +74,7 @@ enum _Msvm_ComputerSystem_RequestedState {
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED = 2,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED = 3,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT = 10,
+MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET = 11,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED = 32768,
 MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_SUSPENDED = 32769,
 };
-- 
2.27.0




[PATCH 0/7] more Hyper-V APIs

2020-10-09 Thread Matt Coleman
This set of patches adds several new APIs and fixes several others.

Matt Coleman (7):
  hyperv: implement domainSetAutostart
  hyperv: implement nodeGetFreeMemory
  hyperv: implement domainReboot and domainReset
  hyperv: implement domainShutdown and domainShutdownFlags
  hyperv: fix domainSuspend and domainResume on Hyper-V V2
  hyperv: fix domainManagedSave on Hyper-V V2
  news: more Hyper-V APIs

 NEWS.rst  |   7 +-
 src/hyperv/hyperv_driver.c| 268 +-
 src/hyperv/hyperv_wmi_classes.h   |   3 +
 src/hyperv/hyperv_wmi_generator.input |  78 
 4 files changed, 348 insertions(+), 8 deletions(-)

-- 
2.27.0




[PATCH 1/7] hyperv: implement domainSetAutostart

2020-10-09 Thread Matt Coleman
Co-authored-by: Sri Ramanujam 
Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c | 92 ++
 1 file changed, 92 insertions(+)

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 2ac30fa4c6..6b2acbc405 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1310,6 +1310,97 @@ hypervDomainGetAutostart(virDomainPtr domain, int 
*autostart)
 
 
 
+static int
+hypervDomainSetAutostart(virDomainPtr domain, int autostart)
+{
+int result = -1;
+char uuid_string[VIR_UUID_STRING_BUFLEN];
+hypervPrivate *priv = domain->conn->privateData;
+Msvm_VirtualSystemSettingData *vssd = NULL;
+hypervInvokeParamsListPtr params = NULL;
+g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER;
+virHashTablePtr autostartParam = NULL;
+hypervWmiClassInfoListPtr embeddedParamClass = NULL;
+const char *methodName = NULL, *embeddedParamName = NULL;
+g_autofree char *enabledValue = NULL, *disabledValue = NULL;
+
+if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
+methodName = "ModifyVirtualSystem";
+embeddedParamName = "SystemSettingData";
+embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo;
+enabledValue = g_strdup("2");
+disabledValue = g_strdup("0");
+} else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
+methodName = "ModifySystemSettings";
+embeddedParamName = "SystemSettings";
+embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo;
+enabledValue = g_strdup("4");
+disabledValue = g_strdup("2");
+}
+
+virUUIDFormat(domain->uuid, uuid_string);
+
+if (hypervGetVSSDFromUUID(priv, uuid_string, &vssd) < 0)
+goto cleanup;
+
+params = hypervCreateInvokeParamsList(priv, methodName,
+MSVM_VIRTUALSYSTEMMANAGEMENTSERVICE_SELECTOR,
+Msvm_VirtualSystemManagementService_WmiInfo);
+
+if (!params) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Could not create 
params"));
+goto cleanup;
+}
+
+if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
+virBufferEscapeSQL(&eprQuery,
+   MSVM_COMPUTERSYSTEM_WQL_SELECT "WHERE Name = '%s'",
+   uuid_string);
+
+if (hypervAddEprParam(params, "ComputerSystem", priv, &eprQuery,
+  Msvm_ComputerSystem_WmiInfo) < 0)
+goto params_cleanup;
+}
+
+autostartParam = hypervCreateEmbeddedParam(priv, embeddedParamClass);
+
+if (hypervSetEmbeddedProperty(autostartParam, "AutomaticStartupAction",
+  autostart ? enabledValue : disabledValue) < 0) {
+hypervFreeEmbeddedParam(autostartParam);
+goto params_cleanup;
+}
+
+if (hypervSetEmbeddedProperty(autostartParam, "InstanceID",
+  vssd->data.common->InstanceID) < 0) {
+hypervFreeEmbeddedParam(autostartParam);
+goto params_cleanup;
+}
+
+if (hypervAddEmbeddedParam(params, priv, embeddedParamName, autostartParam,
+   embeddedParamClass) < 0) {
+hypervFreeEmbeddedParam(autostartParam);
+goto params_cleanup;
+}
+
+if (hypervInvokeMethod(priv, params, NULL) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Could not set autostart"));
+goto cleanup;
+}
+
+result = 0;
+goto cleanup;
+
+ params_cleanup:
+hypervFreeInvokeParams(params);
+ cleanup:
+hypervFreeObject(priv, (hypervObject *) vssd);
+
+return result;
+}
+
+
+
 static int
 hypervConnectIsEncrypted(virConnectPtr conn)
 {
@@ -1861,6 +1952,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
 .domainCreate = hypervDomainCreate, /* 0.9.5 */
 .domainCreateWithFlags = hypervDomainCreateWithFlags, /* 0.9.5 */
 .domainGetAutostart = hypervDomainGetAutostart, /* 6.9.0 */
+.domainSetAutostart = hypervDomainSetAutostart, /* 6.9.0 */
 .connectIsEncrypted = hypervConnectIsEncrypted, /* 0.9.5 */
 .connectIsSecure = hypervConnectIsSecure, /* 0.9.5 */
 .domainIsActive = hypervDomainIsActive, /* 0.9.5 */
-- 
2.27.0




Re: [libvirt PATCH 3/3] ci: Start building RPMs

2020-10-09 Thread Andrea Bolognani
On Fri, 2020-10-09 at 07:11 -0400, Neal Gompa wrote:
> On Fri, Oct 9, 2020 at 4:49 AM Andrea Bolognani  wrote:
> > On Thu, 2020-10-08 at 22:17 -0400, Neal Gompa wrote:
> > > I've got a patch set locally that adds the few knobs needed to make
> > > openSUSE build with the upstream spec file. If you want, I can clean
> > > that up and submit it for upstream inclusion?
> > 
> > Sure thing!
> 
> I'll do it after your spec cleanup patch set lands, because otherwise
> it's going to be a bit hellish to rebase.

I agree, that's definitely the smart way to go about it :)

-- 
Andrea Bolognani / Red Hat / Virtualization



Re: [libvirt PATCH 03/10] util: vircgroup: change virCgroupFree to take only virCgroupPtr

2020-10-09 Thread Pavel Hrdina
On Thu, Oct 08, 2020 at 11:36:56AM -0500, Jonathon Jongsma wrote:
> On Thu,  8 Oct 2020 16:26:56 +0200
> Pavel Hrdina  wrote:
> 
> > As preparation for g_autoptr() we need to change the function to take
> > only virCgroupPtr.
> > 
> > Signed-off-by: Pavel Hrdina 
> > ---
> >  src/libvirt-lxc.c |  4 +-
> >  src/lxc/lxc_cgroup.c  |  4 +-
> >  src/lxc/lxc_container.c   |  2 +-
> >  src/lxc/lxc_controller.c  |  2 +-
> >  src/lxc/lxc_domain.c  |  2 +-
> >  src/lxc/lxc_process.c | 11 +++---
> >  src/qemu/qemu_cgroup.c| 12 +++---
> >  src/qemu/qemu_domain.c|  3 +-
> >  src/qemu/qemu_driver.c| 32 +++
> >  src/qemu/qemu_process.c   |  2 +-
> >  src/util/vircgroup.c  | 65
> > +-- src/util/vircgroup.h  |
> > 2 +- src/util/vircgroupv1.c|  2 +-
> >  tests/vircgrouptest.c | 48 +++
> >  tools/virt-host-validate-common.c |  2 +-
> >  15 files changed, 102 insertions(+), 91 deletions(-)
> > 
> > diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c
> > index 25f1cfc5f7..73daf123f0 100644
> > --- a/src/libvirt-lxc.c
> > +++ b/src/libvirt-lxc.c
> > @@ -307,12 +307,12 @@ int virDomainLxcEnterCGroup(virDomainPtr domain,
> >  if (virCgroupAddProcess(cgroup, getpid()) < 0)
> >  goto error;
> >  
> > -virCgroupFree(&cgroup);
> > +virCgroupFree(cgroup);
> >  
> >  return 0;
> >  
> >   error:
> >  virDispatchError(NULL);
> > -virCgroupFree(&cgroup);
> > +virCgroupFree(cgroup);
> >  return -1;
> >  }
> > diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
> > index d13f2adde5..b80a8911f9 100644
> > --- a/src/lxc/lxc_cgroup.c
> > +++ b/src/lxc/lxc_cgroup.c
> > @@ -168,7 +168,7 @@ int virLXCCgroupGetMeminfo(virLXCMeminfoPtr
> > meminfo) 
> >  ret = 0;
> >   cleanup:
> > -virCgroupFree(&cgroup);
> > +virCgroupFree(cgroup);
> >  return ret;
> >  }
> >  
> > @@ -417,7 +417,7 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr
> > def, def->idmap.uidmap[0].target,
> >def->idmap.gidmap[0].target,
> >(1 << VIR_CGROUP_CONTROLLER_SYSTEMD))
> > < 0) {
> > -virCgroupFree(&cgroup);
> > +virCgroupFree(cgroup);
> >  return NULL;
> >  }
> >  }
> > diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> > index d1aa622be4..913f4de26a 100644
> > --- a/src/lxc/lxc_container.c
> > +++ b/src/lxc/lxc_container.c
> > @@ -1668,7 +1668,7 @@ static int
> > lxcContainerSetupPivotRoot(virDomainDefPtr vmDef, ret = 0;
> >  
> >   cleanup:
> > -virCgroupFree(&cgroup);
> > +virCgroupFree(cgroup);
> >  return ret;
> >  }
> >  
> > diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> > index f70731bc64..e6dee85ec7 100644
> > --- a/src/lxc/lxc_controller.c
> > +++ b/src/lxc/lxc_controller.c
> > @@ -310,7 +310,7 @@ static void
> > virLXCControllerFree(virLXCControllerPtr ctrl) g_free(ctrl->nbdpids);
> >  
> >  g_free(ctrl->nsFDs);
> > -virCgroupFree(&ctrl->cgroup);
> > +virCgroupFree(ctrl->cgroup);
> >  
> >  /* This must always be the last thing to be closed */
> >  VIR_FORCE_CLOSE(ctrl->handshakeFd);
> > diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
> > index d8aebe06d9..df60519fca 100644
> > --- a/src/lxc/lxc_domain.c
> > +++ b/src/lxc/lxc_domain.c
> > @@ -168,7 +168,7 @@ virLXCDomainObjPrivateFree(void *data)
> >  {
> >  virLXCDomainObjPrivatePtr priv = data;
> >  
> > -virCgroupFree(&priv->cgroup);
> > +virCgroupFree(priv->cgroup);
> >  virLXCDomainObjFreeJob(priv);
> >  g_free(priv);
> >  }
> > diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
> > index 16969dbf33..a98a090893 100644
> > --- a/src/lxc/lxc_process.c
> > +++ b/src/lxc/lxc_process.c
> > @@ -236,7 +236,8 @@ static void virLXCProcessCleanup(virLXCDriverPtr
> > driver, 
> >  if (priv->cgroup) {
> >  virCgroupRemove(priv->cgroup);
> > -virCgroupFree(&priv->cgroup);
> > +virCgroupFree(priv->cgroup);
> > +priv->cgroup = NULL;
> >  }
> >  
> >  /* Get machined to terminate the machine as it may not have
> > cleaned it @@ -1202,26 +1203,26 @@ int
> > virLXCProcessStart(virConnectPtr conn, 
> >  if (!virCgroupHasController(selfcgroup,
> >  VIR_CGROUP_CONTROLLER_CPUACCT)) {
> > -virCgroupFree(&selfcgroup);
> > +virCgroupFree(selfcgroup);
> >  virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> > _("Unable to find 'cpuacct' cgroups
> > controller mount")); return -1;
> >  }
> >  if (!virCgroupHasController(selfcgroup,
> >  VIR_CGROUP_CONTROLLER_DEVICES)) {
> > -virCgroupFree(&selfcgroup);
> > +virCgroupFree(selfcgroup);
> >  virReportError(VIR_ERR_INT

[PATCH 1/2] hyperv: bump minimum openwsman version to 2.6.3

2020-10-09 Thread Matt Coleman
Bug fixes and comments specific to older versions have been removed.

Signed-off-by: Matt Coleman 
---
 libvirt.spec.in|  2 +-
 meson.build|  2 +-
 src/hyperv/hyperv_driver.c |  4 +---
 src/hyperv/hyperv_wmi.c|  8 
 src/hyperv/openwsman.h | 21 ++---
 5 files changed, 5 insertions(+), 32 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 29f34f673a..80563ce6ef 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -363,7 +363,7 @@ BuildRequires: netcf-devel >= 0.2.2
 BuildRequires: libcurl-devel
 %endif
 %if %{with_hyperv}
-BuildRequires: libwsman-devel >= 2.2.3
+BuildRequires: libwsman-devel >= 2.6.3
 %endif
 BuildRequires: audit-libs-devel
 # we need /usr/sbin/dtrace
diff --git a/meson.build b/meson.build
index a5ce8e17a8..d0e977f7bd 100644
--- a/meson.build
+++ b/meson.build
@@ -1207,7 +1207,7 @@ if numactl_dep.found()
   conf.set('WITH_NUMACTL', 1)
 endif
 
-openwsman_version = '2.2.3'
+openwsman_version = '2.6.3'
 openwsman_dep = dependency('openwsman', version: '>=' + openwsman_version, 
required: get_option('openwsman'))
 
 parallels_sdk_version = '7.0.22'
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index dcde469442..7db6802a55 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -383,10 +383,8 @@ hypervFreePrivate(hypervPrivate **priv)
 if (priv == NULL || *priv == NULL)
 return;
 
-if ((*priv)->client != NULL) {
-/* FIXME: This leaks memory due to bugs in openwsman <= 2.2.6 */
+if ((*priv)->client != NULL)
 wsmc_release((*priv)->client);
-}
 
 if ((*priv)->caps)
 virObjectUnref((*priv)->caps);
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index b233dab58d..6d0445184a 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -1082,8 +1082,6 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQueryPtr 
wqlQuery,
 
 if (data != NULL) {
 #if WS_SERIALIZER_FREE_MEM_WORKS
-/* FIXME: ws_serializer_free_mem is broken in openwsman <= 2.2.6,
- *see hypervFreeObject for a detailed explanation. */
 if (ws_serializer_free_mem(serializerContext, data,
wmiInfo->serializerInfo) < 0) {
 VIR_ERROR(_("Could not free deserialized data"));
@@ -1118,12 +1116,6 @@ hypervFreeObject(hypervPrivate *priv G_GNUC_UNUSED, 
hypervObject *object)
 next = object->next;
 
 #if WS_SERIALIZER_FREE_MEM_WORKS
-/* FIXME: ws_serializer_free_mem is broken in openwsman <= 2.2.6,
- *but this is not that critical, because openwsman keeps
- *track of all allocations of the deserializer and frees
- *them in wsmc_release. So this doesn't result in a real
- *memory leak, but just in piling up unused memory until
- *the connection is closed. */
 if (ws_serializer_free_mem(serializerContext, object->data.common,
object->info->serializerInfo) < 0) {
 VIR_ERROR(_("Could not free deserialized data"));
diff --git a/src/hyperv/openwsman.h b/src/hyperv/openwsman.h
index cd7660ac2e..c59c450ea6 100644
--- a/src/hyperv/openwsman.h
+++ b/src/hyperv/openwsman.h
@@ -21,27 +21,10 @@
 
 #pragma once
 
-/* Workaround openwsman <= 2.2.6 unconditionally defining optarg. Just pretend
- * that u/os.h was already included. Need to explicitly include time.h because
- * wsman-xml-serializer.h needs it and u/os.h would have included it. */
-#include 
-#define _LIBU_OS_H_
 #include 
 
-/* wsman-xml-serializer.h in openwsman <= 2.2.6 is missing this defines */
-#ifndef SER_NS_INT8
-# define SER_NS_INT8(ns, n, x) SER_NS_INT8_FLAGS(ns, n, x, 0)
-#endif
-#ifndef SER_NS_INT16
-# define SER_NS_INT16(ns, n, x) SER_NS_INT16_FLAGS(ns, n, x, 0)
-#endif
-#ifndef SER_NS_INT32
-# define SER_NS_INT32(ns, n, x) SER_NS_INT32_FLAGS(ns, n, x, 0)
-#endif
-#ifndef SER_NS_INT64
-# define SER_NS_INT64(ns, n, x) SER_NS_INT64_FLAGS(ns, n, x, 0)
-#endif
-
 /* wsman-xml.h */
 WsXmlDocH ws_xml_create_doc(const char *rootNsUri, const char *rootName);
+
+/* wsman-xml-binding.h */
 WsXmlNodeH xml_parser_get_root(WsXmlDocH doc);
-- 
2.27.0




[PATCH 2/2] hyperv: remove openwsman.h

2020-10-09 Thread Matt Coleman
This header's main purpose was to work around bugs in older versions of
openwsman. Most of the files using it only needed wsman-api.h, which
they now include directly.

Signed-off-by: Matt Coleman 
---
 src/hyperv/hyperv_driver.c  |  1 -
 src/hyperv/hyperv_private.h |  3 ++-
 src/hyperv/hyperv_wmi.c |  4 +++-
 src/hyperv/hyperv_wmi.h |  1 -
 src/hyperv/hyperv_wmi_classes.h |  3 ++-
 src/hyperv/openwsman.h  | 30 --
 6 files changed, 7 insertions(+), 35 deletions(-)
 delete mode 100644 src/hyperv/openwsman.h

diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 7db6802a55..2ac30fa4c6 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -34,7 +34,6 @@
 #include "hyperv_private.h"
 #include "hyperv_util.h"
 #include "hyperv_wmi.h"
-#include "openwsman.h"
 #include "virstring.h"
 #include "virkeycode.h"
 #include "domain_conf.h"
diff --git a/src/hyperv/hyperv_private.h b/src/hyperv/hyperv_private.h
index cf08bf542b..b31cb616af 100644
--- a/src/hyperv/hyperv_private.h
+++ b/src/hyperv/hyperv_private.h
@@ -22,10 +22,11 @@
 
 #pragma once
 
+#include 
+
 #include "internal.h"
 #include "virerror.h"
 #include "hyperv_util.h"
-#include "openwsman.h"
 #include "capabilities.h"
 
 typedef enum _hypervWmiVersion hypervWmiVersion;
diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c
index 6d0445184a..2b40e72053 100644
--- a/src/hyperv/hyperv_wmi.c
+++ b/src/hyperv/hyperv_wmi.c
@@ -24,7 +24,10 @@
  */
 
 #include 
+
 #include 
+#include 
+#include 
 
 #include "internal.h"
 #include "virerror.h"
@@ -35,7 +38,6 @@
 #include "hyperv_private.h"
 #include "hyperv_wmi.h"
 #include "virstring.h"
-#include "openwsman.h"
 #include "virlog.h"
 #include "virxml.h"
 
diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h
index 8c9c5ed9c1..ee16657768 100644
--- a/src/hyperv/hyperv_wmi.h
+++ b/src/hyperv/hyperv_wmi.h
@@ -26,7 +26,6 @@
 #include "virbuffer.h"
 #include "hyperv_private.h"
 #include "hyperv_wmi_classes.h"
-#include "openwsman.h"
 #include "virhash.h"
 
 
diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
index 7465684d6e..d32711589a 100644
--- a/src/hyperv/hyperv_wmi_classes.h
+++ b/src/hyperv/hyperv_wmi_classes.h
@@ -23,8 +23,9 @@
 
 #pragma once
 
+#include 
+
 #include "internal.h"
-#include "openwsman.h"
 
 #include "hyperv_wmi_classes.generated.typedef"
 
diff --git a/src/hyperv/openwsman.h b/src/hyperv/openwsman.h
deleted file mode 100644
index c59c450ea6..00
--- a/src/hyperv/openwsman.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * openwsman.h: workarounds for bugs in openwsman
- *
- * Copyright (C) 2011 Matthias Bolte 
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library.  If not, see
- * .
- *
- */
-
-#pragma once
-
-#include 
-
-/* wsman-xml.h */
-WsXmlDocH ws_xml_create_doc(const char *rootNsUri, const char *rootName);
-
-/* wsman-xml-binding.h */
-WsXmlNodeH xml_parser_get_root(WsXmlDocH doc);
-- 
2.27.0




[PATCH 0/2] hyperv: bump minimum openwsman version to 2.6.3

2020-10-09 Thread Matt Coleman
As Daniel mentioned in the thread for my commit "hyperv: make
Msvm_ComputerSystem WQL queries locale agnostic", we can increase the
minimum openwsman version since all the supported distributions have at
least version 2.6.3.

Comments about older versions have been removed throughout the codebase.

Also, openwsman.h has been removed entirely, since its original purpose
was to work around bugs in earlier (now unsupported) openwsman versions.

Matt Coleman (2):
  hyperv: bump minimum openwsman version to 2.6.3
  hyperv: remove openwsman.h

 libvirt.spec.in |  2 +-
 meson.build |  2 +-
 src/hyperv/hyperv_driver.c  |  5 +---
 src/hyperv/hyperv_private.h |  3 ++-
 src/hyperv/hyperv_wmi.c | 12 +++--
 src/hyperv/hyperv_wmi.h |  1 -
 src/hyperv/hyperv_wmi_classes.h |  3 ++-
 src/hyperv/openwsman.h  | 47 -
 8 files changed, 10 insertions(+), 65 deletions(-)
 delete mode 100644 src/hyperv/openwsman.h

-- 
2.27.0




Re: [libvirt PATCH] remote: remove leftover goto

2020-10-09 Thread John Ferlan



On 10/9/20 7:09 AM, Ján Tomko wrote:
> Signed-off-by: Ján Tomko 
> Reported-by: John Ferlan 
> Fixes: 8487595bee0c04e56b0d8e866c5c71318faf1689
> Signed-off-by: Ján Tomko 
> ---
> /me gets the paper bag
> >  src/remote/remote_driver.c | 1 -
>  1 file changed, 1 deletion(-)
> 

Reviewed-by: John Ferlan 

Although you may want to clean up the double signoff

John




Re: [PATCH v2 00/10] hyperv: implement new APIs & more

2020-10-09 Thread Matt Coleman
> On Oct 5, 2020, at 12:20 PM, Matt Coleman  wrote:
> 
> These patches fix a couple bugs, consolidate duplicate code, and 
> implement several APIs.

If one of the primary maintainers has a chance, I think these changes 
are ready. Pino gave me some great feedback on v1, but said on IRC that 
it needed “more experienced eyes”.

I’ve got more changes to follow, so I eagerly await any additional 
feedback on this set.

Thanks!

-- 
Matt




Re: [libvirt PATCH 3/3] ci: Start building RPMs

2020-10-09 Thread Neal Gompa
On Fri, Oct 9, 2020 at 4:49 AM Andrea Bolognani  wrote:
>
> On Thu, 2020-10-08 at 22:17 -0400, Neal Gompa wrote:
> > On Thu, Oct 8, 2020 at 1:43 PM Andrea Bolognani  wrote:
> > > We lost this coverage during the move from CentOS CI to GitLab CI,
> > > and it's high time we brought it back.
> > >
> > > Building RPMs is currently skipped for:
> > >
> > >   * openSUSE, which is not supported by our spec file;
> >
> > I've got a patch set locally that adds the few knobs needed to make
> > openSUSE build with the upstream spec file. If you want, I can clean
> > that up and submit it for upstream inclusion?
>
> Sure thing!
>

I'll do it after your spec cleanup patch set lands, because otherwise
it's going to be a bit hellish to rebase.


-- 
真実はいつも一つ!/ Always, there's only one truth!




Re: [libvirt PATCH v2 0/9] spec: Improve feature and architecture handling

2020-10-09 Thread Neal Gompa
On Fri, Oct 9, 2020 at 5:27 AM Andrea Bolognani  wrote:
>
> Changes from [v1]:
>
>   * address review feedback.
>
> [v1] https://www.redhat.com/archives/libvir-list/2020-October/msg00336.html
>
> Andrea Bolognani (9):
>   spec: Simplify setting features off by default
>   spec: firewalld is always enabled
>   spec: bash completion actually defaults to on
>   spec: Move with_numactl definition
>   spec: Introduce with_dmidecode
>   spec: Move _vpath_builddir definition
>   spec: Drop s390 architecture from conditionals
>   spec: Refactor qemu_kvm_arches definition
>   spec: Introduce arches_*
>
>  libvirt.spec.in | 116 
>  1 file changed, 57 insertions(+), 59 deletions(-)
>
> --
> 2.26.2
>
>

Series LGTM.

Reviewed-by: Neal Gompa 


-- 
真実はいつも一つ!/ Always, there's only one truth!




[libvirt PATCH] remote: remove leftover goto

2020-10-09 Thread Ján Tomko
Signed-off-by: Ján Tomko 
Reported-by: John Ferlan 
Fixes: 8487595bee0c04e56b0d8e866c5c71318faf1689
Signed-off-by: Ján Tomko 
---
/me gets the paper bag

 src/remote/remote_driver.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 49769ac04d..d318224605 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -7636,7 +7636,6 @@ remoteDomainGetFSInfo(virDomainPtr dom,
 }
 
 info_ret = g_new0(virDomainFSInfoPtr, ret.info.info_len);
-goto cleanup;
 
 for (i = 0; i < ret.info.info_len; i++) {
 src = &ret.info.info_val[i];
-- 
2.26.2



[libvirt PATCH 2/4] qemu: Remove references to "cpu_map.xml" in the code

2020-10-09 Thread Tim Wiederhake
"cpu_map.xml" was moved to a directory "cpu_map" and split up into
several files.

Signed-off-by: Tim Wiederhake 
---
 src/qemu/qemu_capabilities.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 38b901a6c4..02136fd3b3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -3072,7 +3072,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
 
 cpu->model = g_strdup(model);
 
-/* Some x86_64 features defined in cpu_map.xml use spelling which differ
+/* Some x86_64 features defined in src/cpu_map/ use spelling which differ
  * from the one preferred by QEMU. Static expansion would give us only the
  * preferred spelling. With new QEMU we always use the QEMU's canonical
  * names of all features and translate between them and our names. But for
-- 
2.26.2



[libvirt PATCH 1/4] tests: Remove references to "cpu_map.xml" in the code

2020-10-09 Thread Tim Wiederhake
"cpu_map.xml" was moved to a directory "cpu_map" and split up into
several files.

Signed-off-by: Tim Wiederhake 
---
 tests/cputest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/cputest.c b/tests/cputest.c
index bf5ce84aa7..87ad5825b8 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -817,8 +817,8 @@ cpuTestUpdateLive(const void *arg)
 if (!(expected = cpuTestLoadXML(data->arch, expectedFile)))
 goto cleanup;
 
-/* In case the host CPU signature does not exactly match any CPU model from
- * cpu_map.xml, the CPU model we detect from CPUID may differ from the one
+/* In case the host CPU signature does not exactly match any CPU model in
+ * src/cpu_map, the CPU model we detect from CPUID may differ from the one
  * we compute by asking QEMU. Since this test expands both CPU models and
  * compares their features, we can try to translate the 'actual' CPU to
  * use the CPU model from 'expected'.
-- 
2.26.2



[libvirt PATCH 3/4] docs: Remove references to "cpu_map.xml" in the documentation

2020-10-09 Thread Tim Wiederhake
"cpu_map.xml" was moved to a directory "cpu_map" and split up into
several files.

Signed-off-by: Tim Wiederhake 
---
 docs/formatdomain.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index cc4f91d4ea..0ffb1b7196 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1361,7 +1361,7 @@ In case no restrictions need to be put on CPU model and 
its features, a simpler
 ``model``
The content of the ``model`` element specifies CPU model requested by the
guest. The list of available CPU models and their definition can be found in
-   ``cpu_map.xml`` file installed in libvirt's data directory. If a hypervisor
+   directory ``cpu_map``, installed in libvirt's data directory. If a 
hypervisor
is not able to use the exact CPU model, libvirt automatically falls back to 
a
closest model supported by the hypervisor while maintaining the list of CPU
features. :since:`Since 0.9.10` , an optional ``fallback`` attribute can be
@@ -1376,7 +1376,7 @@ In case no restrictions need to be put on CPU model and 
its features, a simpler
:since:`Since 0.8.3` the content of the ``vendor`` element specifies CPU
vendor requested by the guest. If this element is missing, the guest can be
run on a CPU matching given features regardless on its vendor. The list of
-   supported vendors can be found in ``cpu_map.xml``.
+   supported vendors can be found in ``cpu_map/*_vendors.xml``.
 ``topology``
The ``topology`` element specifies requested topology of virtual CPU 
provided
to the guest. Four attributes, ``sockets``, ``dies``, ``cores``, and
-- 
2.26.2



[libvirt PATCH 4/4] doc: Fix element name in description of "feature"

2020-10-09 Thread Tim Wiederhake
Actual change is "s/``elements``/``feature`` elements/", rest is
reflow.

Signed-off-by: Tim Wiederhake 
---
 docs/formatdomain.rst | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
index 0ffb1b7196..df5ac28028 100644
--- a/docs/formatdomain.rst
+++ b/docs/formatdomain.rst
@@ -1388,11 +1388,11 @@ In case no restrictions need to be put on CPU model and 
its features, a simpler
of vCPUs specified by the ``cpus`` element equals to the number of vcpus
resulting from the topology.
 ``feature``
-   The ``cpu`` element can contain zero or more ``elements`` used to fine-tune
-   features provided by the selected CPU model. The list of known feature names
-   can be found in the same file as CPU models. The meaning of each ``feature``
-   element depends on its ``policy`` attribute, which has to be set to one of
-   the following values:
+   The ``cpu`` element can contain zero or more ``feature`` elements used to
+   fine-tune features provided by the selected CPU model. The list of known
+   feature names can be found in the same file as CPU models. The meaning of
+   each ``feature`` element depends on its ``policy`` attribute, which has to 
be
+   set to one of the following values:
 
``force``
   The virtual CPU will claim the feature is supported regardless of it 
being
-- 
2.26.2



[libvirt PATCH 0/4] Some documentation fixes

2020-10-09 Thread Tim Wiederhake
I encountered some references to a cpu_map.xml file which was
moved to a subdirectory in commit 3ecbac95cd and split up in to
different files in 2c127947ae and e6d7be38b9. This series removes
all remaining references to this file and fixes an unrelated minor
issue in the description of the "feature" element in the section
about "cpu".

Tim Wiederhake (4):
  tests: Remove references to "cpu_map.xml" in the code
  qemu: Remove references to "cpu_map.xml" in the code
  docs: Remove references to "cpu_map.xml" in the documentation
  doc: Fix element name in description of "feature"

 docs/formatdomain.rst| 14 +++---
 src/qemu/qemu_capabilities.c |  2 +-
 tests/cputest.c  |  4 ++--
 3 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.26.2




Re: [libvirt PATCH 15/15] meson: add tests build option to enable/disable unit tests

2020-10-09 Thread Pavel Hrdina
On Thu, Oct 08, 2020 at 08:17:09PM +0200, Andrea Bolognani wrote:
> On Thu, 2020-10-08 at 15:59 +0200, Pavel Hrdina wrote:
> > +++ b/meson_options.txt
> > @@ -8,6 +8,7 @@ option('test_coverage', type: 'boolean', value: false, 
> > description: 'turn on cod
> >  option('git_werror', type: 'feature', value: 'auto', description: 'use 
> > -Werror if building from GIT')
> >  option('rpath', type: 'feature', value: 'auto', description: 'whether to 
> > include rpath information in installed binaries and libraries')
> >  option('docs', type: 'feature', value: 'auto', description: 'whether to 
> > generate documentation')
> > +option('tests', type: 'feature', value: 'auto', description: 'whether to 
> > build tests')
> 
> Don't we want -Dtests=enabled in libvirt.spec.in at this point?

As described in a reply to different patch there is no need to do it I
think being explicit is better so I'll add it into libvirt.spec file.

Pavel


signature.asc
Description: PGP signature


Re: [libvirt PATCH 11/15] meson: add missing libraries to summary

2020-10-09 Thread Pavel Hrdina
On Thu, Oct 08, 2020 at 08:16:59PM +0200, Andrea Bolognani wrote:
> On Thu, 2020-10-08 at 15:59 +0200, Pavel Hrdina wrote:
> > +  'parallels': parallels_sdk_dep.found(),
> 
> Should this be 'parallels-sdk'?

Sure, I'll change it before pushing.

Pavel


signature.asc
Description: PGP signature


Re: [libvirt PATCH 00/15] various meson fixes and improvements

2020-10-09 Thread Pavel Hrdina
On Thu, Oct 08, 2020 at 08:18:51PM +0200, Andrea Bolognani wrote:
> On Thu, 2020-10-08 at 15:58 +0200, Pavel Hrdina wrote:
> > Pavel Hrdina (15):
> >   meson_options: change VMware default from enabled to auto
> >   meson_options: change VirtualBox default from enabled to auto
> >   meson_options: move firewalld options to build feature options
> >   meson: no need to call meson.get_compiler() again
> >   meson: properly handle libpcap if it's explicitly disabled
> >   meson: properly handle readline if it's explicitly disabled
> >   meson: build nodedev driver only if libvirtd is compiled
> >   meson: add libnl build option
> >   meson: add rbd build option
> >   meson: prefix kvm_dep, m_dep and util_dep with lib
> >   meson: add missing libraries to summary
> >   meson: remove required libraries from summary
> >   meson: move build feature options to miscellaneous summary
> >   meson: add docs option to enable/disable generating documentation
> >   meson: add tests build option to enable/disable unit tests
> > 
> >  libvirt.spec.in   |   2 +
> >  meson.build   | 135 +-
> >  meson_options.txt |  12 ++--
> >  src/bhyve/meson.build |   4 +-
> >  src/util/meson.build  |   4 +-
> >  5 files changed, 96 insertions(+), 61 deletions(-)
> 
> I've added a few minor comments to individual patches, but regardless
> of how you decide to address those the series gets a
> 
>   Reviewed-by: Andrea Bolognani 

Thanks, I'll fix the issues, drop rbd build option patch and push it.

Pavel


signature.asc
Description: PGP signature


Re: [libvirt PATCH 09/15] meson: add rbd build option

2020-10-09 Thread Pavel Hrdina
On Thu, Oct 08, 2020 at 08:16:49PM +0200, Andrea Bolognani wrote:
> On Thu, 2020-10-08 at 15:58 +0200, Pavel Hrdina wrote:
> > +++ b/meson_options.txt
> > @@ -31,6 +31,7 @@ option('numactl', type: 'feature', value: 'auto', 
> > description: 'numactl support'
> >  option('openwsman', type: 'feature', value: 'auto', description: 
> > 'openwsman support')
> >  option('pciaccess', type: 'feature', value: 'auto', description: 
> > 'pciaccess support')
> >  option('polkit', type: 'feature', value: 'auto', description: 'use 
> > PolicyKit for UNIX socket access checks')
> > +option('rbd', type: 'feature', value: 'auto', description: 'rbd support')
> 
> Shouldn't you add -Drbd=enabled to libvirt.spec.in now?

Actually there is no need to do that as %meson macro uses
--auto-features=%{__meson_auto_features} where the default value of
__meson_auto_features is enabled. So by default all auto features are
enabled.

But looking into the situation I'll drop the patch for now as it would
break RPM build in cases where we don't build storage_rbd as we wrap
build dependencies in a condition and we would have to do the same for
-Drbd as we do for -Dstorage_rbd which doesn't make sense.

I'll post a patch where we will reuse the storage_rbd option to figure
out if we need to check for rbd libs or not and the same should be
probably done for glusterfs and possibly some other libraries.

With autotools we had separate options for the library and for the
libvirt feature because we could pass a path to library but with meson
this is not possible. You can use --pkg-config-path meson option or
change env variables.

Pavel


signature.asc
Description: PGP signature


Re: [libvirt PATCH 3/8] remote: use g_new0 instead of VIR_ALLOC

2020-10-09 Thread John Ferlan



On 10/8/20 8:12 AM, Ján Tomko wrote:
> Signed-off-by: Ján Tomko 
> ---
>  src/remote/remote_daemon_config.c   |   3 +-
>  src/remote/remote_daemon_dispatch.c | 225 ++--
>  src/remote/remote_daemon_stream.c   |   6 +-
>  src/remote/remote_driver.c  | 102 -
>  4 files changed, 108 insertions(+), 228 deletions(-)
> 

[...]

> diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
> index 6e0c04f168..49769ac04d 100644
> --- a/src/remote/remote_driver.c
> +++ b/src/remote/remote_driver.c

[...]

> @@ -7676,14 +7635,13 @@ remoteDomainGetFSInfo(virDomainPtr dom,
>  goto cleanup;
>  }
>  
> -if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0)
> +info_ret = g_new0(virDomainFSInfoPtr, ret.info.info_len);
>  goto cleanup;


Coverity notes a simple / trivial cleanup

[...]



[libvirt PATCH v2 6/9] spec: Move _vpath_builddir definition

2020-10-09 Thread Andrea Bolognani
It belongs before package-specific feature flags are defined.

Signed-off-by: Andrea Bolognani 
Reviewed-by: Neal Gompa 
---
 libvirt.spec.in | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index ae6381fe3e..dd2247d712 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -12,6 +12,11 @@
 %define supported_platform 0
 %endif
 
+# On RHEL 7 and older macro _vpath_builddir is not defined.
+%if 0%{?rhel} && 0%{?rhel} <= 7
+%define _vpath_builddir %{_target_platform}
+%endif
+
 # The hypervisor drivers that run in libvirtd
 %define with_qemu  0%{!?_without_qemu:1}
 %define with_lxc   0%{!?_without_lxc:1}
@@ -31,11 +36,6 @@
 %define qemu_kvm_arches x86_64 %{power64} aarch64 s390x
 %endif
 
-# On RHEL 7 and older macro _vpath_builddir is not defined.
-%if 0%{?rhel} && 0%{?rhel} <= 7
-%define _vpath_builddir %{_target_platform}
-%endif
-
 %ifarch %{qemu_kvm_arches}
 %define with_qemu_kvm  %{with_qemu}
 %else
-- 
2.26.2



[libvirt PATCH v2 9/9] spec: Introduce arches_*

2020-10-09 Thread Andrea Bolognani
With this commit, all architecture lists that we base feature
enablement decisions on are defined within a few lines of each
other, increasing maintainability.

Additionally, generic architecture lists that appear in the
conditions for multiple features are defined, so that repetition
is reduced.

Note that a few checks (numactl, zfs, ceph) have been changed
from %ifarch to %ifnarch for consistency: while doing so, the
corresponding list of architectures has also been replaced with
the complement of the original one to ensure the overall behavior
would be preserved.

Signed-off-by: Andrea Bolognani 
---
 libvirt.spec.in | 48 ++--
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index a0cd5ce5af..cbcf7dcc60 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -17,18 +17,30 @@
 %define _vpath_builddir %{_target_platform}
 %endif
 
-%define qemu_kvm_arches %{ix86} x86_64 %{power64} %{arm} aarch64 s390x
+%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x
 %if 0%{?rhel}
-%define qemu_kvm_arches x86_64 %{power64} aarch64 s390x
+%define arches_qemu_kvm x86_64 %{power64} aarch64 s390x
 %endif
 
+%define arches_64bitx86_64 %{power64} aarch64 s390x riscv64
+%define arches_x86  %{ix86} x86_64
+
+%define arches_systemtap_64bit  %{arches_64bit}
+%define arches_dmidecode%{arches_x86}
+%define arches_xen  %{arches_x86} aarch64
+%define arches_vbox %{arches_x86}
+%define arches_ceph %{arches_64bit}
+%define arches_zfs  %{arches_x86} %{power64} %{arm}
+%define arches_numactl  %{arches_x86} %{power64} aarch64
+%define arches_numad%{arches_x86} %{power64} aarch64
+
 # The hypervisor drivers that run in libvirtd
 %define with_qemu  0%{!?_without_qemu:1}
 %define with_lxc   0%{!?_without_lxc:1}
 %define with_libxl 0%{!?_without_libxl:1}
 %define with_vbox  0%{!?_without_vbox:1}
 
-%ifarch %{qemu_kvm_arches}
+%ifarch %{arches_qemu_kvm}
 %define with_qemu_kvm  %{with_qemu}
 %else
 %define with_qemu_kvm  0
@@ -60,7 +72,7 @@
 %endif
 
 %define with_storage_gluster 0%{!?_without_storage_gluster:1}
-%ifnarch %{qemu_kvm_arches}
+%ifnarch %{arches_qemu_kvm}
 # gluster is only built where qemu driver is enabled on RHEL 8
 %if 0%{?rhel} >= 8
 %define with_storage_gluster 0
@@ -97,28 +109,20 @@
 
 # Finally set the OS / architecture specific special cases
 
-# Xen is available only on some architectures
-%ifnarch %{ix86} x86_64 aarch64
+# Architecture-dependent features
+%ifnarch %{arches_xen}
 %define with_libxl 0
 %endif
-
-# vbox is available only on i386 x86_64
-%ifnarch %{ix86} x86_64
+%ifnarch %{arches_vbox}
 %define with_vbox 0
 %endif
-
-# Numactl is not available on many non-x86 archs
-%ifarch s390x %{arm} riscv64
+%ifnarch %{arches_numactl}
 %define with_numactl 0
 %endif
-
-# zfs-fuse is not available on some architectures
-%ifarch s390x aarch64 riscv64
+%ifnarch %{arches_zfs}
 %define with_storage_zfs 0
 %endif
-
-# Ceph dropped support for 32-bit hosts
-%ifarch %{arm} %{ix86}
+%ifnarch %{arches_ceph}
 %define with_storage_rbd 0
 %endif
 
@@ -154,7 +158,7 @@
 %define with_sanlock 0%{!?_without_sanlock:1}
 %endif
 %if 0%{?rhel}
-%ifarch %{qemu_kvm_arches}
+%ifarch %{arches_qemu_kvm}
 %define with_sanlock 0%{!?_without_sanlock:1}
 %endif
 %endif
@@ -178,12 +182,12 @@
 %if %{with_qemu} || %{with_lxc}
 # numad is used to manage the CPU and memory placement dynamically,
 # it's not available on many non-x86 architectures.
-%ifnarch s390x %{arm} riscv64
+%ifnarch %{arches_numad}
 %define with_numad0%{!?_without_numad:1}
 %endif
 %endif
 
-%ifarch %{ix86} x86_64
+%ifarch %{arches_dmidecode}
 %define with_dmidecode 0%{!?_without_dmidecode:1}
 %endif
 
@@ -1256,7 +1260,7 @@ rm -f 
$RPM_BUILD_ROOT%{_datadir}/augeas/lenses/tests/test_libvirtd_libxl.aug
 # Copied into libvirt-docs subpackage eventually
 mv $RPM_BUILD_ROOT%{_datadir}/doc/libvirt libvirt-docs
 
-%ifarch %{power64} s390x x86_64 aarch64 riscv64
+%ifarch %{arches_systemtap_64bit}
 mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_probes.stp \
$RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_probes-64.stp
 
-- 
2.26.2



[libvirt PATCH v2 3/9] spec: bash completion actually defaults to on

2020-10-09 Thread Andrea Bolognani
Remove the red herring.

Signed-off-by: Andrea Bolognani 
---
 libvirt.spec.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 508b4c8dcc..66f0560a5c 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -84,6 +84,9 @@
 %define with_storage_iscsi_direct 0
 %endif
 
+# Other optional features
+%define with_bash_completion  0%{!?_without_bash_completion:1}
+
 # A few optional bits off by default, we enable later
 %define with_fuse 0
 %define with_sanlock  0
@@ -92,7 +95,6 @@
 %define with_libssh2  0
 %define with_wireshark0
 %define with_libssh   0
-%define with_bash_completion  0
 
 # Finally set the OS / architecture specific special cases
 
@@ -174,8 +176,6 @@
 %define with_libssh 0%{!?_without_libssh:1}
 %endif
 
-%define with_bash_completion  0%{!?_without_bash_completion:1}
-
 %if %{with_qemu} || %{with_lxc}
 # numad is used to manage the CPU and memory placement dynamically,
 # it's not available on many non-x86 architectures.
-- 
2.26.2



[libvirt PATCH v2 2/9] spec: firewalld is always enabled

2020-10-09 Thread Andrea Bolognani
Knowing this, we can remove some code.

Signed-off-by: Andrea Bolognani 
Reviewed-by: Neal Gompa 
---
 libvirt.spec.in | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 36a2cac2b2..508b4c8dcc 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -88,7 +88,6 @@
 %define with_fuse 0
 %define with_sanlock  0
 %define with_numad0
-%define with_firewalld0
 %define with_firewalld_zone   0
 %define with_libssh2  0
 %define with_wireshark0
@@ -138,8 +137,6 @@
 %endif
 %endif
 
-%define with_firewalld 1
-
 %if 0%{?fedora} || 0%{?rhel} > 7
 %define with_firewalld_zone 0%{!?_without_firewalld_zone:1}
 %endif
@@ -1089,12 +1086,6 @@ exit 1
 %define arg_sanlock -Dsanlock=disabled
 %endif
 
-%if %{with_firewalld}
-%define arg_firewalld -Dfirewalld=enabled
-%else
-%define arg_firewalld -Dfirewalld=disabled
-%endif
-
 %if %{with_firewalld_zone}
 %define arg_firewalld_zone -Dfirewalld_zone=enabled
 %else
@@ -1170,7 +1161,7 @@ export SOURCE_DATE_EPOCH=$(stat --printf='%Y' 
%{_specdir}/%{name}.spec)
-Dlibpcap=enabled \
-Daudit=enabled \
-Ddtrace=enabled \
-   %{?arg_firewalld} \
+   -Dfirewalld=enabled \
%{?arg_firewalld_zone} \
%{?arg_wireshark} \
-Dpm_utils=disabled \
-- 
2.26.2



[libvirt PATCH v2 4/9] spec: Move with_numactl definition

2020-10-09 Thread Andrea Bolognani
Keep it close to similar ones.

Signed-off-by: Andrea Bolognani 
Reviewed-by: Neal Gompa 
---
 libvirt.spec.in | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 66f0560a5c..d9fa27a5fe 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -68,8 +68,6 @@
 %endif
 %endif
 
-%define with_numactl  0%{!?_without_numactl:1}
-
 # F25+ has zfs-fuse
 %if 0%{?fedora}
 %define with_storage_zfs  0%{!?_without_storage_zfs:1}
@@ -86,6 +84,7 @@
 
 # Other optional features
 %define with_bash_completion  0%{!?_without_bash_completion:1}
+%define with_numactl  0%{!?_without_numactl:1}
 
 # A few optional bits off by default, we enable later
 %define with_fuse 0
-- 
2.26.2



[libvirt PATCH v2 7/9] spec: Drop s390 architecture from conditionals

2020-10-09 Thread Andrea Bolognani
Neither Fedora nor RHEL build packages on this architecture.

Signed-off-by: Andrea Bolognani 
Reviewed-by: Neal Gompa 
Reviewed-by: Thomas Huth 
---
 libvirt.spec.in | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index dd2247d712..7ab62ebd63 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -109,12 +109,12 @@
 %endif
 
 # Numactl is not available on many non-x86 archs
-%ifarch s390 s390x %{arm} riscv64
+%ifarch s390x %{arm} riscv64
 %define with_numactl 0
 %endif
 
 # zfs-fuse is not available on some architectures
-%ifarch s390 s390x aarch64 riscv64
+%ifarch s390x aarch64 riscv64
 %define with_storage_zfs 0
 %endif
 
@@ -179,7 +179,7 @@
 %if %{with_qemu} || %{with_lxc}
 # numad is used to manage the CPU and memory placement dynamically,
 # it's not available on many non-x86 architectures.
-%ifnarch s390 s390x %{arm} riscv64
+%ifnarch s390x %{arm} riscv64
 %define with_numad0%{!?_without_numad:1}
 %endif
 %endif
-- 
2.26.2



[libvirt PATCH v2 5/9] spec: Introduce with_dmidecode

2020-10-09 Thread Andrea Bolognani
To keep things maintainable, we want to have architecture handling
all in one spot instead of sprinkling %ifarch conditionals all over
the place.

Signed-off-by: Andrea Bolognani 
Reviewed-by: Neal Gompa 
---
 libvirt.spec.in | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index d9fa27a5fe..ae6381fe3e 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -94,6 +94,7 @@
 %define with_libssh2  0
 %define with_wireshark0
 %define with_libssh   0
+%define with_dmidecode0
 
 # Finally set the OS / architecture specific special cases
 
@@ -183,6 +184,10 @@
 %endif
 %endif
 
+%ifarch %{ix86} x86_64
+%define with_dmidecode 0%{!?_without_dmidecode:1}
+%endif
+
 # Force QEMU to run as non-root
 %define qemu_user  qemu
 %define qemu_group  qemu
@@ -435,7 +440,7 @@ Requires: iproute-tc
 %endif
 
 Requires: polkit >= 0.112
-%ifarch %{ix86} x86_64
+%if %{with_dmidecode}
 # For virConnectGetSysinfo
 Requires: dmidecode
 %endif
-- 
2.26.2



[libvirt PATCH v2 1/9] spec: Simplify setting features off by default

2020-10-09 Thread Andrea Bolognani
The right-hand side of these expressions will always evaluate to
zero. Stop obfuscating this fact.

Signed-off-by: Andrea Bolognani 
---
 libvirt.spec.in | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 80563ce6ef..36a2cac2b2 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -85,15 +85,15 @@
 %endif
 
 # A few optional bits off by default, we enable later
-%define with_fuse  0%{!?_without_fuse:0}
-%define with_sanlock   0%{!?_without_sanlock:0}
-%define with_numad 0%{!?_without_numad:0}
-%define with_firewalld 0%{!?_without_firewalld:0}
-%define with_firewalld_zone 0%{!?_without_firewalld_zone:0}
-%define with_libssh2   0%{!?_without_libssh2:0}
-%define with_wireshark 0%{!?_without_wireshark:0}
-%define with_libssh0%{!?_without_libssh:0}
-%define with_bash_completion  0%{!?_without_bash_completion:0}
+%define with_fuse 0
+%define with_sanlock  0
+%define with_numad0
+%define with_firewalld0
+%define with_firewalld_zone   0
+%define with_libssh2  0
+%define with_wireshark0
+%define with_libssh   0
+%define with_bash_completion  0
 
 # Finally set the OS / architecture specific special cases
 
-- 
2.26.2



[libvirt PATCH v2 8/9] spec: Refactor qemu_kvm_arches definition

2020-10-09 Thread Andrea Bolognani
There's no need to set a default for it if we're going to override
it immediately afterwards anyway, and setting with_qemu_tcg at the
same time only makes things more confusing.

Signed-off-by: Andrea Bolognani 
---
 libvirt.spec.in | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 7ab62ebd63..a0cd5ce5af 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -17,31 +17,30 @@
 %define _vpath_builddir %{_target_platform}
 %endif
 
+%define qemu_kvm_arches %{ix86} x86_64 %{power64} %{arm} aarch64 s390x
+%if 0%{?rhel}
+%define qemu_kvm_arches x86_64 %{power64} aarch64 s390x
+%endif
+
 # The hypervisor drivers that run in libvirtd
 %define with_qemu  0%{!?_without_qemu:1}
 %define with_lxc   0%{!?_without_lxc:1}
 %define with_libxl 0%{!?_without_libxl:1}
 %define with_vbox  0%{!?_without_vbox:1}
 
-%define with_qemu_tcg  %{with_qemu}
-
-%define qemu_kvm_arches %{ix86} x86_64
-
-%if 0%{?fedora}
-%define qemu_kvm_arches %{ix86} x86_64 %{power64} s390x %{arm} aarch64
-%endif
-
-%if 0%{?rhel}
-%define with_qemu_tcg 0
-%define qemu_kvm_arches x86_64 %{power64} aarch64 s390x
-%endif
-
 %ifarch %{qemu_kvm_arches}
 %define with_qemu_kvm  %{with_qemu}
 %else
 %define with_qemu_kvm  0
 %endif
 
+%define with_qemu_tcg  %{with_qemu}
+
+# RHEL disables TCG on all architectures
+%if 0%{?rhel}
+%define with_qemu_tcg 0
+%endif
+
 %if ! %{with_qemu_tcg} && ! %{with_qemu_kvm}
 %define with_qemu 0
 %endif
-- 
2.26.2



[libvirt PATCH v2 0/9] spec: Improve feature and architecture handling

2020-10-09 Thread Andrea Bolognani
Changes from [v1]:

  * address review feedback.

[v1] https://www.redhat.com/archives/libvir-list/2020-October/msg00336.html

Andrea Bolognani (9):
  spec: Simplify setting features off by default
  spec: firewalld is always enabled
  spec: bash completion actually defaults to on
  spec: Move with_numactl definition
  spec: Introduce with_dmidecode
  spec: Move _vpath_builddir definition
  spec: Drop s390 architecture from conditionals
  spec: Refactor qemu_kvm_arches definition
  spec: Introduce arches_*

 libvirt.spec.in | 116 
 1 file changed, 57 insertions(+), 59 deletions(-)

-- 
2.26.2




Re: [PATCH 5/7] hyperv: fix domainSuspend and domainResume on Hyper-V V2

2020-10-09 Thread Daniel P . Berrangé
On Fri, Oct 09, 2020 at 04:56:09AM -0400, Matt Coleman wrote:
> > On Oct 9, 2020, at 4:43 AM, Daniel P. Berrangé  wrote:
> > 
> > On Fri, Oct 09, 2020 at 04:31:54AM -0400, Matt Coleman wrote:
> >> Signed-off-by: Matt Coleman 
> >> ---
> >> src/hyperv/hyperv_driver.c  | 15 +++
> >> src/hyperv/hyperv_wmi_classes.h |  1 +
> >> 2 files changed, 12 insertions(+), 4 deletions(-)
> >> 
> >> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> >> index 0b28c1e94b..89840f7ac4 100644
> >> --- a/src/hyperv/hyperv_driver.c
> >> +++ b/src/hyperv/hyperv_driver.c
> >> @@ -867,6 +867,10 @@ hypervDomainSuspend(virDomainPtr domain)
> >> int result = -1;
> >> hypervPrivate *priv = domain->conn->privateData;
> >> Msvm_ComputerSystem *computerSystem = NULL;
> >> +int requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED;
> >> +
> >> +if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
> >> +requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
> > 
> > Is quiesce really what we want here ?
> > 
> > The libvirt  Suspend/Resume APIs are specifically about pausing
> > execution of the guest CPUs.
> > 
> > IIUC, quiesce usually just refers to suspending I/O processing,
> > in order to allow snapshots to be taken, but CPUs stay running.
> 
> I agree that it’s an odd name, but that’s how Microsoft chose to 
> describe this RequestedState. It’s documented at the following link as...
> 
> "Quiesce (9)
> Corresponds to CIM_EnabledLogicalElement.EnabledState = Quiesce, 
> Enabled but paused."
> 
> https://docs.microsoft.com/en-us/windows/win32/hyperv_v2/requeststatechange-msvm-computersystem
> 
> I didn’t believe the documentation when I first read it, so I paused a 
> VM in Hyper-V Manager and confirmed that its state was indeed Quiesce.

AH, that's ok then.

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [PATCH 1/7] hyperv: implement domainSetAutostart

2020-10-09 Thread Pino Toscano
On Friday, 9 October 2020 10:31:50 CEST Matt Coleman wrote:
> +static int
> +hypervDomainSetAutostart(virDomainPtr domain, int autostart)
> +{
> +int result = -1;
> +char uuid_string[VIR_UUID_STRING_BUFLEN];
> +hypervPrivate *priv = domain->conn->privateData;
> +Msvm_VirtualSystemSettingData *vssd = NULL;
> +hypervInvokeParamsListPtr params = NULL;
> +g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER;
> +virHashTablePtr autostartParam = NULL;
> +hypervWmiClassInfoListPtr embeddedParamClass = NULL;
> +const char *methodName = NULL, *embeddedParamName = NULL;
> +g_autofree char *enabledValue = NULL, *disabledValue = NULL;
> +
> +if (priv->wmiVersion == HYPERV_WMI_VERSION_V1) {
> +methodName = "ModifyVirtualSystem";
> +embeddedParamName = "SystemSettingData";
> +embeddedParamClass = Msvm_VirtualSystemGlobalSettingData_WmiInfo;
> +enabledValue = g_strdup("2");
> +disabledValue = g_strdup("0");
> +} else if (priv->wmiVersion == HYPERV_WMI_VERSION_V2) {
> +methodName = "ModifySystemSettings";
> +embeddedParamName = "SystemSettings";
> +embeddedParamClass = Msvm_VirtualSystemSettingData_WmiInfo;
> +enabledValue = g_strdup("4");
> +disabledValue = g_strdup("2");
> +}

It looks like 'enabledValue' and 'disabledValue' can be static strings
(like 'methodName' and 'embeddedParamName').

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.


Re: [libvirt PATCH 3/3] ci: Start building RPMs

2020-10-09 Thread Andrea Bolognani
On Thu, 2020-10-08 at 22:17 -0400, Neal Gompa wrote:
> On Thu, Oct 8, 2020 at 1:43 PM Andrea Bolognani  wrote:
> > We lost this coverage during the move from CentOS CI to GitLab CI,
> > and it's high time we brought it back.
> > 
> > Building RPMs is currently skipped for:
> > 
> >   * openSUSE, which is not supported by our spec file;
> 
> I've got a patch set locally that adds the few knobs needed to make
> openSUSE build with the upstream spec file. If you want, I can clean
> that up and submit it for upstream inclusion?

Sure thing!

-- 
Andrea Bolognani / Red Hat / Virtualization



Re: [PATCH 5/7] hyperv: fix domainSuspend and domainResume on Hyper-V V2

2020-10-09 Thread Daniel P . Berrangé
On Fri, Oct 09, 2020 at 04:31:54AM -0400, Matt Coleman wrote:
> Signed-off-by: Matt Coleman 
> ---
>  src/hyperv/hyperv_driver.c  | 15 +++
>  src/hyperv/hyperv_wmi_classes.h |  1 +
>  2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 0b28c1e94b..89840f7ac4 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -867,6 +867,10 @@ hypervDomainSuspend(virDomainPtr domain)
>  int result = -1;
>  hypervPrivate *priv = domain->conn->privateData;
>  Msvm_ComputerSystem *computerSystem = NULL;
> +int requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED;
> +
> +if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
> +requestedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;

Is quiesce really what we want here ?

The libvirt  Suspend/Resume APIs are specifically about pausing
execution of the guest CPUs.

IIUC, quiesce usually just refers to suspending I/O processing,
in order to allow snapshots to be taken, but CPUs stay running.

>  
>  if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
>  goto cleanup;
> @@ -878,8 +882,8 @@ hypervDomainSuspend(virDomainPtr domain)
>  goto cleanup;
>  }
>  
> -result = hypervInvokeMsvmComputerSystemRequestStateChange
> -   (domain, MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED);
> +result = hypervInvokeMsvmComputerSystemRequestStateChange(domain,
> +  
> requestedState);
>  
>   cleanup:
>  hypervFreeObject(priv, (hypervObject *)computerSystem);
> @@ -895,12 +899,15 @@ hypervDomainResume(virDomainPtr domain)
>  int result = -1;
>  hypervPrivate *priv = domain->conn->privateData;
>  Msvm_ComputerSystem *computerSystem = NULL;
> +int expectedState = MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED;
> +
> +if (priv->wmiVersion == HYPERV_WMI_VERSION_V2)
> +expectedState = MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE;
>  
>  if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0)
>  goto cleanup;
>  
> -if (computerSystem->data.common->EnabledState !=
> -MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) {
> +if (computerSystem->data.common->EnabledState != expectedState) {
>  virReportError(VIR_ERR_OPERATION_INVALID, "%s",
> _("Domain is not paused"));
>  goto cleanup;
> diff --git a/src/hyperv/hyperv_wmi_classes.h b/src/hyperv/hyperv_wmi_classes.h
> index 7f4159dd8e..0074d8889e 100644
> --- a/src/hyperv/hyperv_wmi_classes.h
> +++ b/src/hyperv/hyperv_wmi_classes.h
> @@ -73,6 +73,7 @@ enum _Msvm_ComputerSystem_EnabledState {
>  enum _Msvm_ComputerSystem_RequestedState {
>  MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_ENABLED = 2,
>  MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_DISABLED = 3,
> +MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_QUIESCE = 9,
>  MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_REBOOT = 10,
>  MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_RESET = 11,
>  MSVM_COMPUTERSYSTEM_REQUESTEDSTATE_PAUSED = 32768,
> -- 
> 2.27.0
> 
> 

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



Re: [libvirt PATCH 7/9] spec: Drop s390 architecture from conditionals

2020-10-09 Thread Thomas Huth
On 05/10/2020 20.40, Andrea Bolognani wrote:
> Neither Fedora nor RHEL build packages on this architecture.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  libvirt.spec.in | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index d8f689e651..e036307d30 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -109,12 +109,12 @@
>  %endif
>  
>  # Numactl is not available on many non-x86 archs
> -%ifarch s390 s390x %{arm} riscv64
> +%ifarch s390x %{arm} riscv64
>  %define with_numactl 0
>  %endif
>  
>  # zfs-fuse is not available on some architectures
> -%ifarch s390 s390x aarch64 riscv64
> +%ifarch s390x aarch64 riscv64
>  %define with_storage_zfs 0
>  %endif
>  
> @@ -179,7 +179,7 @@
>  %if %{with_qemu} || %{with_lxc}
>  # numad is used to manage the CPU and memory placement dynamically,
>  # it's not available on many non-x86 architectures.
> -%ifnarch s390 s390x %{arm} riscv64
> +%ifnarch s390x %{arm} riscv64
>  %define with_numad0%{!?_without_numad:1}
>  %endif
>  %endif
> 

Reviewed-by: Thomas Huth 



Re: [PATCH] qemu.conf: Re-word the description for *_tls_x509_verify

2020-10-09 Thread Michal Privoznik

On 8/21/20 12:59 PM, Fangge Jin wrote:

The original descirption for *_tls_x509_verify is a little misleading
by saying that "Enabling this option will reject any client who does
not have a ca-cert.pem certificate".

Signed-off-by: Fangge Jin 
---
  src/qemu/qemu.conf | 20 
  1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index a96bedb114..b1bd3cecbd 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -109,9 +109,8 @@
  # issuing an x509 certificate to every client who needs to connect.
  #
  # Enabling this option will reject any client that does not have a
-# ca-cert.pem certificate signed by the CA in the vnc_tls_x509_cert_dir
-# (or default_tls_x509_cert_dir) as well as the corresponding client-*.pem
-# files described in default_tls_x509_cert_dir.
+# certificate(as described in default_tls_x509_verify) signed by the


Here and in the rest: s/certificate(/certificate (/

Fixed and pushed.

Reviewed-by: Michal Privoznik 

Michal



Re: [PATCH 0/2] hyperv: bump minimum openwsman version to 2.6.3

2020-10-09 Thread Michal Privoznik

On 10/9/20 9:46 AM, Matt Coleman wrote:

As Daniel mentioned in the thread for my commit "hyperv: make
Msvm_ComputerSystem WQL queries locale agnostic", we can increase the
minimum openwsman version since all the supported distributions have at
least version 2.6.3.

Comments about older versions have been removed throughout the codebase.

Also, openwsman.h has been removed entirely, since its original purpose
was to work around bugs in earlier (now unsupported) openwsman versions.

Matt Coleman (2):
   hyperv: bump minimum openwsman version to 2.6.3
   hyperv: remove openwsman.h

  libvirt.spec.in |  2 +-
  meson.build |  2 +-
  src/hyperv/hyperv_driver.c  |  5 +---
  src/hyperv/hyperv_private.h |  3 ++-
  src/hyperv/hyperv_wmi.c | 12 +++--
  src/hyperv/hyperv_wmi.h |  1 -
  src/hyperv/hyperv_wmi_classes.h |  3 ++-
  src/hyperv/openwsman.h  | 47 -
  8 files changed, 10 insertions(+), 65 deletions(-)
  delete mode 100644 src/hyperv/openwsman.h



Reviewed-by: Michal Privoznik 

and pushed.

Michal



Re: [PATCH] bhyve: implement virtio-9p support

2020-10-09 Thread Michal Privoznik

On 10/8/20 3:18 PM, Roman Bogorodskiy wrote:

   Roman Bogorodskiy wrote:


Recently virtio-9p support was added to bhyve.

On the host side it looks this way:

   bhyve  -s 25:0,virtio-9p,sharename=/path/to/shared/dir

It could also have ",ro" suffix to make share read-only.

In the Linux guest, this share is mounted with:

   mount -t 9p sharename /mnt/sharename

In the guest user will see the same permissions and ownership
information for this directory as on the host. No uid/gid remapping is
supported, so those could resolve to wrong user or group names.

The same applies to the other side: chowning/chmodding in the guest will
set specified ownership and permissions on the host.

In libvirt domain XML it's modeled using the 'filesystem' element:

   
 
 
   

Optional 'readonly' sub-element enables read-only mode.

Signed-off-by: Roman Bogorodskiy 
---
  src/bhyve/bhyve_capabilities.c| 14 
  src/bhyve/bhyve_capabilities.h|  1 +
  src/bhyve/bhyve_command.c | 72 +++
  src/bhyve/bhyve_device.c  | 10 +++
  src/libvirt_private.syms  |  1 +
  .../bhyvexml2argv-fs-9p-readonly.args | 10 +++
  .../bhyvexml2argv-fs-9p-readonly.ldargs   |  3 +
  .../bhyvexml2argv-fs-9p-readonly.xml  | 28 
  ...exml2argv-fs-9p-unsupported-accessmode.xml | 27 +++
  ...bhyvexml2argv-fs-9p-unsupported-driver.xml | 28 
  .../bhyvexml2argv-fs-9p.args  | 10 +++
  .../bhyvexml2argv-fs-9p.ldargs|  3 +
  .../bhyvexml2argvdata/bhyvexml2argv-fs-9p.xml | 27 +++
  tests/bhyvexml2argvtest.c |  9 ++-
  .../bhyvexml2xmlout-fs-9p.xml | 38 ++
  tests/bhyvexml2xmltest.c  |  1 +
  16 files changed, 281 insertions(+), 1 deletion(-)
  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.args
  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.ldargs
  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-readonly.xml
  create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-unsupported-accessmode.xml
  create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-unsupported-driver.xml
  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.args
  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.ldargs
  create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p.xml
  create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-fs-9p.xml


This is missing
tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-unsupported-type.xml

It doesn't seem to be important enough to justify sending v2 just
because of it, so it's here:

https://gitlab.com/rbogorodskiy/libvirt/-/blob/bhyve-9p/tests/bhyvexml2argvdata/bhyvexml2argv-fs-9p-unsupported-type.xml


Yep, with this squashed in:

Reviewed-by: Michal Privoznik 

Michal



Re: [PATCH v2 00/10] hyperv: implement new APIs & more

2020-10-09 Thread Michal Privoznik

On 10/9/20 9:14 AM, Matt Coleman wrote:

On Oct 5, 2020, at 12:20 PM, Matt Coleman  wrote:

These patches fix a couple bugs, consolidate duplicate code, and
implement several APIs.


If one of the primary maintainers has a chance, I think these changes
are ready. Pino gave me some great feedback on v1, but said on IRC that
it needed “more experienced eyes”.

I’ve got more changes to follow, so I eagerly await any additional
feedback on this set.

Thanks!



Reviewed-by: Michal Privoznik 

And pushed.

Michal



Re: [PATCH] the leading space in volmode check will never match the leading tab output from zfs get

2020-10-09 Thread Michal Privoznik

On 10/2/20 4:42 PM, Daniel Henrique Barboza wrote:

The code is ok but the commit message can be improved. Usually
we want a commit title with a single-line summary of what you're
changing, a blank line, and a description describes in more
the change, and your signed-off tag. This guideline can be
found here:

https://libvirt.org/best-practices.html


For this patch, one possibility would be:

---
storage_backend_zfs.c: remove leading space in volmode check

The leading space in volmode check will never match the leading
tab output from zfs get.


Signed-off-by: Richard Burakowski 
---




Agree with Daniel here. Richard, can you please send v2 with the commit 
message fixed? We can merge it then.


Michal



Re: [PATCH v2] docs/submitting-patches: add reference to DCO

2020-10-09 Thread Michal Privoznik

On 10/5/20 3:34 PM, Mauro Matteo Cascella wrote:

Signed-off-by: Mauro Matteo Cascella 
---
Rephrased sentence.

  docs/submitting-patches.rst | 3 +++
  1 file changed, 3 insertions(+)



  Reviewed-by: Michal Privoznik 

and pushed.

Michal



Re: [libvirt PATCH 0/3] ci: Start building RPMs

2020-10-09 Thread Michal Privoznik

On 10/8/20 7:42 PM, Andrea Bolognani wrote:

See it in action:

   https://gitlab.com/abologna/libvirt/-/pipelines/199936179

Andrea Bolognani (3):
   ci: Refresh Dockerfiles
   ci: Allow skipping dist
   ci: Start building RPMs

  .gitlab-ci.yml| 41 ++-
  ci/containers/libvirt-centos-7.Dockerfile |  1 +
  ci/containers/libvirt-centos-8.Dockerfile |  1 +
  .../libvirt-centos-stream.Dockerfile  |  1 +
  ci/containers/libvirt-fedora-31.Dockerfile|  1 +
  ci/containers/libvirt-fedora-32.Dockerfile|  1 +
  ...rt-fedora-rawhide-cross-mingw32.Dockerfile |  1 +
  ...rt-fedora-rawhide-cross-mingw64.Dockerfile |  1 +
  .../libvirt-fedora-rawhide.Dockerfile |  1 +
  9 files changed, 30 insertions(+), 19 deletions(-)



Reviewed-by: Michal Privoznik 

Michal