[libvirt] [PATCH 11/21] conf: domain: store namespace prefix

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/bhyve/bhyve_domain.c | 1 +
 src/lxc/lxc_domain.c | 1 +
 src/qemu/qemu_domain.c   | 1 +
 src/test/test_driver.c   | 1 +
 src/vmx/vmx.c| 1 +
 5 files changed, 5 insertions(+)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 4924766030..9a21cde452 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -277,5 +277,6 @@ virXMLNamespace virBhyveDriverDomainXMLNamespace = {
 .parse = bhyveDomainDefNamespaceParse,
 .free = bhyveDomainDefNamespaceFree,
 .format = bhyveDomainDefNamespaceFormatXML,
+.prefix = "bhyve",
 .href = bhyveDomainDefNamespaceHref,
 };
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index df847b4fca..b61c172804 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -321,6 +321,7 @@ virXMLNamespace virLXCDriverDomainXMLNamespace = {
 .parse = lxcDomainDefNamespaceParse,
 .free = lxcDomainDefNamespaceFree,
 .format = lxcDomainDefNamespaceFormatXML,
+.prefix = "lxc",
 .href = lxcDomainDefNamespaceHref,
 };
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f92b483bcf..bd124b824c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3732,6 +3732,7 @@ virXMLNamespace virQEMUDriverDomainXMLNamespace = {
 .parse = qemuDomainDefNamespaceParse,
 .free = qemuDomainDefNamespaceFree,
 .format = qemuDomainDefNamespaceFormatXML,
+.prefix = "qemu",
 .href = qemuDomainDefNamespaceHref,
 };
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 6dbd76d449..adda3ac4c0 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -429,6 +429,7 @@ testDriverNew(void)
 virXMLNamespace ns = {
 .parse = testDomainDefNamespaceParse,
 .free = testDomainDefNamespaceFree,
+.prefix = "test",
 };
 virDomainDefParserConfig config = {
 .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 0f7c2d5f20..ac24e765d4 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -607,6 +607,7 @@ static virXMLNamespace virVMXDomainXMLNamespace = {
 .parse = NULL,
 .free = virVMXDomainDefNamespaceFree,
 .format = virVMXDomainDefNamespaceFormatXML,
+.prefix = "vmware",
 .href = virVMXDomainDefNamespaceHref,
 };
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 18/21] util: xml: introduce virXMLNamespaceRegister

2019-08-20 Thread Ján Tomko
A wrapper around xmlXPathRegisterNs that will save us
from having to include xpathInternals.h everywhere
we want to use a custom namespace and open-coding
the strings already contained in virXMLNamespace.

Signed-off-by: Ján Tomko 
---
 src/util/virxml.c | 20 
 src/util/virxml.h |  3 +++
 2 files changed, 23 insertions(+)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index 11b6031b09..84b824f432 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -24,6 +24,8 @@
 #include/* for isnan() */
 #include 
 
+#include 
+
 #include "virerror.h"
 #include "virxml.h"
 #include "virbuffer.h"
@@ -1409,9 +1411,27 @@ virXPathContextNodeRestore(virXPathContextNodeSavePtr 
save)
 save->ctxt->node = save->node;
 }
 
+
 void
 virXMLNamespaceFormatNS(virBufferPtr buf,
 virXMLNamespace const *ns)
 {
 virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->href());
 }
+
+
+int
+virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
+virXMLNamespace const *ns)
+{
+if (xmlXPathRegisterNs(ctxt,
+   BAD_CAST ns->prefix,
+   BAD_CAST ns->href()) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Failed to register xml namespace '%s'"),
+   ns->href());
+return -1;
+}
+
+return 0;
+}
diff --git a/src/util/virxml.h b/src/util/virxml.h
index bcc10647b5..dfa20b3edb 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -265,3 +265,6 @@ typedef virXMLNamespace *virXMLNamespacePtr;
 void
 virXMLNamespaceFormatNS(virBufferPtr buf,
 virXMLNamespace const *ns);
+int
+virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
+virXMLNamespace const *ns);
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 01/21] virDomainDefNamespaceParse: remove unused attributes

2019-08-20 Thread Ján Tomko
Neither the xmlDocPtr nor the root xmlNode (also passed
in the XPathContext) are interesting to the callees.

Signed-off-by: Ján Tomko 
---
 src/bhyve/bhyve_domain.c | 4 +---
 src/conf/capabilities.h  | 3 +--
 src/conf/domain_conf.c   | 4 ++--
 src/lxc/lxc_domain.c | 4 +---
 src/qemu/qemu_domain.c   | 4 +---
 src/test/test_driver.c   | 4 +---
 6 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 67cd6cc039..51366f8e26 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -196,9 +196,7 @@ bhyveDomainDefNamespaceFree(void *nsdata)
 }
 
 static int
-bhyveDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
- xmlNodePtr root ATTRIBUTE_UNUSED,
- xmlXPathContextPtr ctxt,
+bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
  void **data)
 {
 bhyveDomainCmdlineDefPtr cmd = NULL;
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 28b398891a..41c81ceeb1 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -182,8 +182,7 @@ struct _virCapsStoragePool {
 };
 
 
-typedef int (*virDomainDefNamespaceParse)(xmlDocPtr, xmlNodePtr,
-  xmlXPathContextPtr, void **);
+typedef int (*virDomainDefNamespaceParse)(xmlXPathContextPtr, void **);
 typedef void (*virDomainDefNamespaceFree)(void *);
 typedef int (*virDomainDefNamespaceXMLFormat)(virBufferPtr, void *);
 typedef const char *(*virDomainDefNamespaceHref)(void);
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 604e006dab..40b5f9b801 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19643,7 +19643,7 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
 
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
- xmlNodePtr root,
+ xmlNodePtr root ATTRIBUTE_UNUSED,
  xmlXPathContextPtr ctxt,
  virCapsPtr caps,
  virDomainXMLOptionPtr xmlopt,
@@ -21345,7 +21345,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 def->ns = xmlopt->ns;
 
 if (def->ns.parse &&
-(def->ns.parse)(xml, root, ctxt, >namespaceData) < 0)
+(def->ns.parse)(ctxt, >namespaceData) < 0)
 goto error;
 
 return def;
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 51a9fd36eb..87f3c7bd63 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -207,9 +207,7 @@ lxcDomainDefNamespaceFree(void *nsdata)
 }
 
 static int
-lxcDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
-   xmlNodePtr root ATTRIBUTE_UNUSED,
-   xmlXPathContextPtr ctxt,
+lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
void **data)
 {
 lxcDomainDefPtr lxcDef = NULL;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a06672333c..880307f215 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3626,9 +3626,7 @@ qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDefPtr 
nsdef,
 
 
 static int
-qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
-xmlNodePtr root ATTRIBUTE_UNUSED,
-xmlXPathContextPtr ctxt,
+qemuDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
 void **data)
 {
 qemuDomainXmlNsDefPtr nsdata = NULL;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index c39eef2d4b..a59984051d 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -198,9 +198,7 @@ testDomainDefNamespaceFree(void *data)
 }
 
 static int
-testDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
-xmlNodePtr root ATTRIBUTE_UNUSED,
-xmlXPathContextPtr ctxt,
+testDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
 void **data)
 {
 testDomainNamespaceDefPtr nsdata = NULL;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 06/21] conf: network: use generic XML namespace types

2019-08-20 Thread Ján Tomko
There is no need to copy and paste the same types pointing
to void all over the place.

Signed-off-by: Ján Tomko 
---
 src/conf/network_conf.c |  2 +-
 src/conf/network_conf.h | 25 -
 src/network/bridge_driver.c |  2 +-
 src/network/bridge_driver.h |  2 +-
 4 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index f55b9e5409..2c3a11fb10 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -93,7 +93,7 @@ virNetworkXMLOnceInit(void)
 VIR_ONCE_GLOBAL_INIT(virNetworkXML);
 
 virNetworkXMLOptionPtr
-virNetworkXMLOptionNew(virNetworkXMLNamespacePtr xmlns)
+virNetworkXMLOptionNew(virXMLNamespacePtr xmlns)
 {
 virNetworkXMLOptionPtr xmlopt;
 
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index b167b57e85..d5dd8480db 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -23,10 +23,6 @@
 
 #define DNS_RECORD_LENGTH_SRV  (512 - 30)  /* Limit minus overhead as 
mentioned in RFC-2782 */
 
-#include 
-#include 
-#include 
-
 #include "internal.h"
 #include "virthread.h"
 #include "virsocketaddr.h"
@@ -40,25 +36,12 @@
 #include "virobject.h"
 #include "virmacmap.h"
 #include "virenum.h"
-
-typedef int (*virNetworkDefNamespaceParse)(xmlXPathContextPtr, void **);
-typedef void (*virNetworkDefNamespaceFree)(void *);
-typedef int (*virNetworkDefNamespaceXMLFormat)(virBufferPtr, void *);
-typedef const char *(*virNetworkDefNamespaceHref)(void);
-
-typedef struct _virNetworkXMLNamespace virNetworkXMLNamespace;
-typedef virNetworkXMLNamespace *virNetworkXMLNamespacePtr;
-struct _virNetworkXMLNamespace {
-virNetworkDefNamespaceParse parse;
-virNetworkDefNamespaceFree free;
-virNetworkDefNamespaceXMLFormat format;
-virNetworkDefNamespaceHref href;
-};
+#include "virxml.h"
 
 struct _virNetworkXMLOption {
 virObject parent;
 
-virNetworkXMLNamespace ns;
+virXMLNamespace ns;
 };
 typedef struct _virNetworkXMLOption virNetworkXMLOption;
 typedef virNetworkXMLOption *virNetworkXMLOptionPtr;
@@ -295,7 +278,7 @@ struct _virNetworkDef {
 
 /* Network specific XML namespace data */
 void *namespaceData;
-virNetworkXMLNamespace ns;
+virXMLNamespace ns;
 };
 
 typedef enum {
@@ -317,7 +300,7 @@ enum {
 };
 
 virNetworkXMLOptionPtr
-virNetworkXMLOptionNew(virNetworkXMLNamespacePtr xmlns);
+virNetworkXMLOptionNew(virXMLNamespacePtr xmlns);
 
 virNetworkDefPtr
 virNetworkDefCopy(virNetworkDefPtr def,
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 9059296e55..b34b742bfa 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -248,7 +248,7 @@ networkDnsmasqDefNamespaceHref(void)
 }
 
 
-virNetworkXMLNamespace networkDnsmasqXMLNamespace = {
+virXMLNamespace networkDnsmasqXMLNamespace = {
 .parse = networkDnsmasqDefNamespaceParse,
 .free = networkDnsmasqDefNamespaceFree,
 .format = networkDnsmasqDefNamespaceFormatXML,
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index b095388a0b..d35850d293 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -27,7 +27,7 @@
 #include "virdnsmasq.h"
 #include "virnetworkobj.h"
 
-extern virNetworkXMLNamespace networkDnsmasqXMLNamespace;
+extern virXMLNamespace networkDnsmasqXMLNamespace;
 
 typedef struct _networkDnsmasqXmlNsDef networkDnsmasqXmlNsDef;
 typedef networkDnsmasqXmlNsDef *networkDnsmasqXmlNsDefPtr;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 10/21] conf: network: store namespace prefix

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/network/bridge_driver.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b34b742bfa..b0ada0132a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -252,6 +252,7 @@ virXMLNamespace networkDnsmasqXMLNamespace = {
 .parse = networkDnsmasqDefNamespaceParse,
 .free = networkDnsmasqDefNamespaceFree,
 .format = networkDnsmasqDefNamespaceFormatXML,
+.prefix = "dnsmasq",
 .href = networkDnsmasqDefNamespaceHref,
 };
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 03/21] prepare: domain format if format not href

2019-08-20 Thread Ján Tomko
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1f2a91c710..f848483235 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28312,7 +28312,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 virBufferAsprintf(buf, "id);
-if (def->namespaceData && def->ns.href)
+if (def->namespaceData && def->ns.format)
 virBufferAsprintf(buf, " %s", (def->ns.href)());
 virBufferAddLit(buf, ">\n");
 virBufferAdjustIndent(buf, 2);
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 14/21] util: introduce virXMLNamespaceFormatNS

2019-08-20 Thread Ján Tomko
A function to automatically format the xmlns:=''
attribute for per-driver namespaces.

Signed-off-by: Ján Tomko 
---
 src/util/virxml.c | 7 +++
 src/util/virxml.h | 4 
 2 files changed, 11 insertions(+)

diff --git a/src/util/virxml.c b/src/util/virxml.c
index f55b9a362c..11b6031b09 100644
--- a/src/util/virxml.c
+++ b/src/util/virxml.c
@@ -1408,3 +1408,10 @@ virXPathContextNodeRestore(virXPathContextNodeSavePtr 
save)
 
 save->ctxt->node = save->node;
 }
+
+void
+virXMLNamespaceFormatNS(virBufferPtr buf,
+virXMLNamespace const *ns)
+{
+virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->href());
+}
diff --git a/src/util/virxml.h b/src/util/virxml.h
index ea0c3d3ab3..bcc10647b5 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -261,3 +261,7 @@ struct _virXMLNamespace {
 };
 typedef struct _virXMLNamespace virXMLNamespace;
 typedef virXMLNamespace *virXMLNamespacePtr;
+
+void
+virXMLNamespaceFormatNS(virBufferPtr buf,
+virXMLNamespace const *ns);
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 19/21] conf: network: use virXMLNamespaceRegister

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/conf/network_conf.c |  2 ++
 src/network/bridge_driver.c | 10 --
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 7eba9eacbf..8db041bd2c 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2051,6 +2051,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
 if (xmlopt)
 def->ns = xmlopt->ns;
 if (def->ns.parse) {
+if (virXMLNamespaceRegister(ctxt, >ns) < 0)
+goto error;
 if ((def->ns.parse)(ctxt, >namespaceData) < 0)
 goto error;
 }
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a3f7ae337a..dd4f111cc0 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -69,8 +69,6 @@
 #include "virjson.h"
 #include "virnetworkportdef.h"
 
-#include 
-
 #define VIR_FROM_THIS VIR_FROM_NETWORK
 #define MAX_BRIDGE_ID 256
 
@@ -191,14 +189,6 @@ networkDnsmasqDefNamespaceParse(xmlXPathContextPtr ctxt,
 networkDnsmasqXmlNsDefPtr nsdata = NULL;
 int ret = -1;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "dnsmasq",
-   BAD_CAST DNSMASQ_NAMESPACE_HREF) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   DNSMASQ_NAMESPACE_HREF);
-return -1;
-}
-
 if (VIR_ALLOC(nsdata) < 0)
 return -1;
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 21/21] conf: domain: use virXMLNamespaceRegister

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/bhyve/bhyve_domain.c | 9 -
 src/conf/domain_conf.c   | 2 ++
 src/lxc/lxc_domain.c | 8 
 src/qemu/qemu_domain.c   | 8 
 src/test/test_driver.c   | 9 -
 5 files changed, 2 insertions(+), 34 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 631fb50db9..ea4bd54969 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -27,8 +27,6 @@
 #include "viralloc.h"
 #include "virlog.h"
 
-#include 
-
 #define VIR_FROM_THIS VIR_FROM_BHYVE
 
 VIR_LOG_INIT("bhyve.bhyve_domain");
@@ -205,13 +203,6 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
 size_t i;
 int ret = -1;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "bhyve", BAD_CAST 
BHYVE_NAMESPACE_HREF) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   BHYVE_NAMESPACE_HREF);
-return -1;
-}
-
 if (VIR_ALLOC(cmd) < 0)
 return -1;
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a39f5f845d..b7a342bb91 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21344,6 +21344,8 @@ virDomainDefParseXML(xmlDocPtr xml,
 def->ns = xmlopt->ns;
 
 if (def->ns.parse) {
+if (virXMLNamespaceRegister(ctxt, >ns) < 0)
+goto error;
 if ((def->ns.parse)(ctxt, >namespaceData) < 0)
 goto error;
 }
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index 022e3c6f6a..00362e4c7f 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -26,7 +26,6 @@
 #include "viralloc.h"
 #include "virlog.h"
 #include "virerror.h"
-#include 
 #include "virstring.h"
 #include "virutil.h"
 #include "virfile.h"
@@ -219,13 +218,6 @@ lxcDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
 char *tmp = NULL;
 size_t i;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "lxc", BAD_CAST LXC_NAMESPACE_HREF) 
< 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   LXC_NAMESPACE_HREF);
-return -1;
-}
-
 if (VIR_ALLOC(lxcDef) < 0)
 return -1;
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0b2065b52c..6d770d3c13 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -73,7 +73,6 @@
 # include 
 #endif
 
-#include 
 #include "dosname.h"
 
 #define QEMU_QXL_VGAMEM_DEFAULT 16 * 1024
@@ -3632,13 +3631,6 @@ qemuDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
 qemuDomainXmlNsDefPtr nsdata = NULL;
 int ret = -1;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST 
QEMU_NAMESPACE_HREF) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   QEMU_NAMESPACE_HREF);
-return -1;
-}
-
 if (VIR_ALLOC(nsdata) < 0)
 return -1;
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 3bdeb6c00a..57d54c05b3 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 
 
 #include "virerror.h"
@@ -213,14 +212,6 @@ testDomainDefNamespaceParse(xmlXPathContextPtr ctxt,
 unsigned int tmpuint;
 VIR_AUTOFREE(xmlNodePtr *) nodes = NULL;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "test",
-   BAD_CAST TEST_NAMESPACE_HREF) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   TEST_NAMESPACE_HREF);
-return -1;
-}
-
 if (VIR_ALLOC(nsdata) < 0)
 return -1;
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 13/21] conf: test: store namespace href

2019-08-20 Thread Ján Tomko
Unlike all the other occurrences, only store the actual URL
instead of the whole xmlns:='' header.

The rest will be converted before this string is used.

Signed-off-by: Ján Tomko 
---
 src/test/test_driver.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index adda3ac4c0..3bdeb6c00a 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -181,6 +181,12 @@ struct _testDomainNamespaceDef {
 xmlNodePtr *snap_nodes;
 };
 
+static const char*
+testDomainDefNamespaceHref(void)
+{
+return TEST_NAMESPACE_HREF;
+}
+
 static void
 testDomainDefNamespaceFree(void *data)
 {
@@ -430,6 +436,7 @@ testDriverNew(void)
 .parse = testDomainDefNamespaceParse,
 .free = testDomainDefNamespaceFree,
 .prefix = "test",
+.href = testDomainDefNamespaceHref,
 };
 virDomainDefParserConfig config = {
 .features = VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG |
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 12/21] conf: storage: store namespace prefix

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/storage/storage_backend_fs.c  | 1 +
 src/storage/storage_backend_rbd.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index d575b75449..c2d0d7bd1f 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -705,6 +705,7 @@ static virXMLNamespace virStoragePoolFSXMLNamespace = {
 .parse = virStoragePoolDefFSNamespaceParse,
 .free = virStoragePoolDefFSNamespaceFree,
 .format = virStoragePoolDefFSNamespaceFormatXML,
+.prefix = "fs",
 .href = virStoragePoolDefFSNamespaceHref,
 };
 #endif /* WITH_STORAGE_FS */
diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index e490c690f5..f86df9a2fa 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -1546,6 +1546,7 @@ static virXMLNamespace virStoragePoolRBDXMLNamespace = {
 .parse = virStoragePoolDefRBDNamespaceParse,
 .free = virStoragePoolDefRBDNamespaceFree,
 .format = virStoragePoolDefRBDNamespaceFormatXML,
+.prefix = "rbd",
 .href = virStoragePoolDefRBDNamespaceHref,
 };
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 20/21] conf: storage: use virXMLNamespaceRegister

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/conf/storage_conf.c   | 2 ++
 src/storage/storage_backend_fs.c  | 9 -
 src/storage/storage_backend_rbd.c | 9 -
 3 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 6588d5c8ef..b5451e447f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -998,6 +998,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
  * especially during the virStoragePoolSourceClear method */
 def->ns = options->ns;
 if (def->ns.parse) {
+if (virXMLNamespaceRegister(ctxt, >ns) < 0)
+return NULL;
 if ((def->ns.parse)(ctxt, >namespaceData) < 0)
 return NULL;
 }
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 4bed6df0bb..d947beac2c 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -41,7 +41,6 @@ VIR_LOG_INIT("storage.storage_backend_fs");
 
 #if WITH_STORAGE_FS
 
-# include 
 # include 
 
 struct _virNetfsDiscoverState {
@@ -571,14 +570,6 @@ virStoragePoolDefFSNamespaceParse(xmlXPathContextPtr ctxt,
 int ret = -1;
 VIR_AUTOFREE(xmlNodePtr *)nodes = NULL;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "fs",
-   BAD_CAST STORAGE_POOL_FS_NAMESPACE_HREF) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   STORAGE_POOL_FS_NAMESPACE_HREF);
-return -1;
-}
-
 nnodes = virXPathNodeSet("./fs:mount_opts/fs:option", ctxt, );
 if (nnodes < 0)
 return -1;
diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index 2d6c51de35..22caa189d7 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -36,7 +36,6 @@
 #include "rbd/librbd.h"
 #include "secret_util.h"
 #include "storage_util.h"
-#include 
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
@@ -91,14 +90,6 @@ virStoragePoolDefRBDNamespaceParse(xmlXPathContextPtr ctxt,
 int ret = -1;
 VIR_AUTOFREE(xmlNodePtr *)nodes = NULL;
 
-if (xmlXPathRegisterNs(ctxt, BAD_CAST "rbd",
-   BAD_CAST STORAGE_POOL_RBD_NAMESPACE_HREF) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to register xml namespace '%s'"),
-   STORAGE_POOL_RBD_NAMESPACE_HREF);
-return -1;
-}
-
 nnodes = virXPathNodeSet("./rbd:config_opts/rbd:option", ctxt, );
 if (nnodes < 0)
 return -1;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 08/21] conf: domain: use generic XML namespace types

2019-08-20 Thread Ján Tomko
Now that virDomainXMLNamespace matches virXMLNamespace,
we no longer need to keep both around.

Signed-off-by: Ján Tomko 
---
 src/bhyve/bhyve_domain.c |  2 +-
 src/bhyve/bhyve_domain.h |  2 +-
 src/conf/capabilities.h  | 12 
 src/conf/domain_conf.c   |  6 +++---
 src/conf/domain_conf.h   |  6 +++---
 src/conf/virconftypes.h  |  3 ---
 src/lxc/lxc_domain.c |  2 +-
 src/lxc/lxc_domain.h |  2 +-
 src/qemu/qemu_domain.c   |  2 +-
 src/qemu/qemu_domain.h   |  2 +-
 src/test/test_driver.c   |  2 +-
 src/vmx/vmx.c|  2 +-
 12 files changed, 14 insertions(+), 29 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 51366f8e26..4924766030 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -273,7 +273,7 @@ bhyveDomainDefNamespaceHref(void)
 return "xmlns:bhyve='" BHYVE_NAMESPACE_HREF "'";
 }
 
-virDomainXMLNamespace virBhyveDriverDomainXMLNamespace = {
+virXMLNamespace virBhyveDriverDomainXMLNamespace = {
 .parse = bhyveDomainDefNamespaceParse,
 .free = bhyveDomainDefNamespaceFree,
 .format = bhyveDomainDefNamespaceFormatXML,
diff --git a/src/bhyve/bhyve_domain.h b/src/bhyve/bhyve_domain.h
index 17cb283e54..e985278041 100644
--- a/src/bhyve/bhyve_domain.h
+++ b/src/bhyve/bhyve_domain.h
@@ -38,6 +38,6 @@ virDomainXMLOptionPtr 
virBhyveDriverCreateXMLConf(bhyveConnPtr);
 
 extern virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks;
 extern virDomainDefParserConfig virBhyveDriverDomainDefParserConfig;
-extern virDomainXMLNamespace virBhyveDriverDomainXMLNamespace;
+extern virXMLNamespace virBhyveDriverDomainXMLNamespace;
 
 bool bhyveDomainDefNeedsISAController(virDomainDefPtr def);
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 41c81ceeb1..d6a4e79d77 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -182,18 +182,6 @@ struct _virCapsStoragePool {
 };
 
 
-typedef int (*virDomainDefNamespaceParse)(xmlXPathContextPtr, void **);
-typedef void (*virDomainDefNamespaceFree)(void *);
-typedef int (*virDomainDefNamespaceXMLFormat)(virBufferPtr, void *);
-typedef const char *(*virDomainDefNamespaceHref)(void);
-
-struct _virDomainXMLNamespace {
-virDomainDefNamespaceParse parse;
-virDomainDefNamespaceFree free;
-virDomainDefNamespaceXMLFormat format;
-virDomainDefNamespaceHref href;
-};
-
 struct _virCaps {
 virObject parent;
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c8c304d2a2..3a1f7c9709 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -79,7 +79,7 @@ struct _virDomainXMLOption {
 virDomainXMLPrivateDataCallbacks privateData;
 
 /* XML namespace callbacks */
-virDomainXMLNamespace ns;
+virXMLNamespace ns;
 
 /* ABI stability callbacks */
 virDomainABIStability abi;
@@ -1385,7 +1385,7 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, 
xmlXPathContextPtr ctxt)
 virDomainXMLOptionPtr
 virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
   virDomainXMLPrivateDataCallbacksPtr priv,
-  virDomainXMLNamespacePtr xmlns,
+  virXMLNamespacePtr xmlns,
   virDomainABIStabilityPtr abi,
   virSaveCookieCallbacksPtr saveCookie)
 {
@@ -1435,7 +1435,7 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
  * Returns a pointer to the stored namespace structure.
  * The lifetime of the pointer is equal to @xmlopt;
  */
-virDomainXMLNamespacePtr
+virXMLNamespacePtr
 virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
 {
 return >ns;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index cbe7b61170..33cef5b75c 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2491,7 +2491,7 @@ struct _virDomainDef {
 virDomainVsockDefPtr vsock;
 
 void *namespaceData;
-virDomainXMLNamespace ns;
+virXMLNamespace ns;
 
 virDomainKeyWrapDefPtr keywrap;
 
@@ -2731,7 +2731,7 @@ struct _virDomainABIStability {
 
 virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config,
 
virDomainXMLPrivateDataCallbacksPtr priv,
-virDomainXMLNamespacePtr xmlns,
+virXMLNamespacePtr xmlns,
 virDomainABIStabilityPtr abi,
 virSaveCookieCallbacksPtr 
saveCookie);
 
@@ -2747,7 +2747,7 @@ int 
virDomainXMLOptionRunMomentPostParse(virDomainXMLOptionPtr xmlopt,
 
 void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac);
 
-virDomainXMLNamespacePtr
+virXMLNamespacePtr
 virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt)
 ATTRIBUTE_NONNULL(1);
 
diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h
index e8e9b6c314..a15cfb5f9e 100644
--- a/src/conf/virconftypes.h
+++ b/src/conf/virconftypes.h
@@ 

[libvirt] [PATCH 17/21] conf: domain: use virXMLNamespaceFormatNS

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/bhyve/bhyve_domain.c | 2 +-
 src/conf/domain_conf.c   | 2 +-
 src/lxc/lxc_domain.c | 2 +-
 src/qemu/qemu_domain.c   | 2 +-
 src/vmx/vmx.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index 9a21cde452..631fb50db9 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -270,7 +270,7 @@ bhyveDomainDefNamespaceFormatXML(virBufferPtr buf,
 static const char *
 bhyveDomainDefNamespaceHref(void)
 {
-return "xmlns:bhyve='" BHYVE_NAMESPACE_HREF "'";
+return BHYVE_NAMESPACE_HREF;
 }
 
 virXMLNamespace virBhyveDriverDomainXMLNamespace = {
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3a1f7c9709..a39f5f845d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28314,7 +28314,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 if (!(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE))
 virBufferAsprintf(buf, " id='%d'", def->id);
 if (def->namespaceData && def->ns.format)
-virBufferAsprintf(buf, " %s", (def->ns.href)());
+virXMLNamespaceFormatNS(buf, >ns);
 virBufferAddLit(buf, ">\n");
 virBufferAdjustIndent(buf, 2);
 
diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c
index b61c172804..022e3c6f6a 100644
--- a/src/lxc/lxc_domain.c
+++ b/src/lxc/lxc_domain.c
@@ -313,7 +313,7 @@ lxcDomainDefNamespaceFormatXML(virBufferPtr buf,
 static const char *
 lxcDomainDefNamespaceHref(void)
 {
-return "xmlns:lxc='" LXC_NAMESPACE_HREF "'";
+return LXC_NAMESPACE_HREF;
 }
 
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index bd124b824c..0b2065b52c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3724,7 +3724,7 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
 static const char *
 qemuDomainDefNamespaceHref(void)
 {
-return "xmlns:qemu='" QEMU_NAMESPACE_HREF "'";
+return QEMU_NAMESPACE_HREF;
 }
 
 
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index ac24e765d4..c4e90537f8 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -600,7 +600,7 @@ virVMXDomainDefNamespaceFormatXML(virBufferPtr buf, void 
*nsdata)
 static const char *
 virVMXDomainDefNamespaceHref(void)
 {
-return "xmlns:vmware='http://libvirt.org/schemas/domain/vmware/1.0'";
+return "http://libvirt.org/schemas/domain/vmware/1.0;;
 }
 
 static virXMLNamespace virVMXDomainXMLNamespace = {
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 05/21] util: introduce virXMLNamespace

2019-08-20 Thread Ján Tomko
For various XMLs, we allow a custom namespace for passing unsupported
configurations.

Introduce a single structure to hold all the driver-specific functions
to remove duplication.

Signed-off-by: Ján Tomko 
---
 src/util/virxml.h | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/util/virxml.h b/src/util/virxml.h
index 6208977dd1..5b209bb040 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -246,3 +246,17 @@ VIR_DEFINE_AUTOCLEAN_FUNC(virXPathContextNodeSave, 
virXPathContextNodeRestore);
 
 VIR_DEFINE_AUTOPTR_FUNC(xmlDoc, xmlFreeDoc);
 VIR_DEFINE_AUTOPTR_FUNC(xmlXPathContext, xmlXPathFreeContext);
+
+typedef int (*virXMLNamespaceParse)(xmlXPathContextPtr, void **);
+typedef void (*virXMLNamespaceFree)(void *);
+typedef int (*virXMLNamespaceFormat)(virBufferPtr, void *);
+typedef const char *(*virXMLNamespaceHref)(void);
+
+struct _virXMLNamespace {
+virXMLNamespaceParse parse;
+virXMLNamespaceFree free;
+virXMLNamespaceFormat format;
+virXMLNamespaceHref href;
+};
+typedef struct _virXMLNamespace virXMLNamespace;
+typedef virXMLNamespace *virXMLNamespacePtr;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 00/21] conf: namespaces: remove some copy'n'paste

2019-08-20 Thread Ján Tomko
Ján Tomko (21):
  virDomainDefNamespaceParse: remove unused attributes
  virDomainDefParseXML: remove unused parameter
  prepare: domain format if format not href
  conf: ns.parse: decouple call from condition
  util: introduce virXMLNamespace
  conf: network: use generic XML namespace types
  conf: storage: use generic XML namespace types
  conf: domain: use generic XML namespace types
  xml: virXMLNamespace: add prefix
  conf: network: store namespace prefix
  conf: domain: store namespace prefix
  conf: storage: store namespace prefix
  conf: test: store namespace href
  util: introduce virXMLNamespaceFormatNS
  conf: network: use virXMLNamespaceFormatNS
  conf: storage: use virXMLNamespaceFormatNS
  conf: domain: use virXMLNamespaceFormatNS
  util: xml: introduce virXMLNamespaceRegister
  conf: network: use virXMLNamespaceRegister
  conf: storage: use virXMLNamespaceRegister
  conf: domain: use virXMLNamespaceRegister

 src/bhyve/bhyve_domain.c  | 18 --
 src/bhyve/bhyve_domain.h  |  2 +-
 src/conf/capabilities.h   | 13 -
 src/conf/domain_conf.c| 24 +---
 src/conf/domain_conf.h|  6 +++---
 src/conf/network_conf.c   | 13 -
 src/conf/network_conf.h   | 25 -
 src/conf/storage_conf.c   | 15 +--
 src/conf/storage_conf.h   | 23 ---
 src/conf/virconftypes.h   |  3 ---
 src/lxc/lxc_domain.c  | 17 -
 src/lxc/lxc_domain.h  |  2 +-
 src/network/bridge_driver.c   | 15 +++
 src/network/bridge_driver.h   |  2 +-
 src/qemu/qemu_domain.c| 17 -
 src/qemu/qemu_domain.h|  2 +-
 src/storage/storage_backend_fs.c  | 14 +++---
 src/storage/storage_backend_rbd.c | 14 +++---
 src/storage/storage_util.c|  2 +-
 src/storage/storage_util.h|  2 +-
 src/test/test_driver.c| 23 ++-
 src/util/virxml.c | 27 +++
 src/util/virxml.h | 22 ++
 src/vmx/vmx.c |  5 +++--
 24 files changed, 130 insertions(+), 176 deletions(-)

-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 16/21] conf: storage: use virXMLNamespaceFormatNS

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/conf/storage_conf.c   | 2 +-
 src/storage/storage_backend_fs.c  | 2 +-
 src/storage/storage_backend_rbd.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index fb8a16a119..6588d5c8ef 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1172,7 +1172,7 @@ virStoragePoolDefFormatBuf(virBufferPtr buf,
 }
 virBufferAsprintf(buf, "namespaceData && def->ns.href)
-virBufferAsprintf(buf, " %s", (def->ns.href)());
+virXMLNamespaceFormatNS(buf, >ns);
 virBufferAddLit(buf, ">\n");
 virBufferAdjustIndent(buf, 2);
 virBufferEscapeString(buf, "%s\n", def->name);
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index c2d0d7bd1f..4bed6df0bb 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -636,7 +636,7 @@ virStoragePoolDefFSNamespaceFormatXML(virBufferPtr buf,
 static const char *
 virStoragePoolDefFSNamespaceHref(void)
 {
-return "xmlns:fs='" STORAGE_POOL_FS_NAMESPACE_HREF "'";
+return STORAGE_POOL_FS_NAMESPACE_HREF;
 }
 
 #endif /* WITH_STORAGE_FS */
diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index f86df9a2fa..2d6c51de35 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -178,7 +178,7 @@ virStoragePoolDefRBDNamespaceFormatXML(virBufferPtr buf,
 static const char *
 virStoragePoolDefRBDNamespaceHref(void)
 {
-return "xmlns:rbd='" STORAGE_POOL_RBD_NAMESPACE_HREF "'";
+return STORAGE_POOL_RBD_NAMESPACE_HREF;
 }
 
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 04/21] conf: ns.parse: decouple call from condition

2019-08-20 Thread Ján Tomko
In the future we will perform more actions if ns.parse
is present. Decouple the condition from the actual call.

Signed-off-by: Ján Tomko 
---
 src/conf/domain_conf.c  | 7 ---
 src/conf/network_conf.c | 7 ---
 src/conf/storage_conf.c | 7 ---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f848483235..c8c304d2a2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21343,9 +21343,10 @@ virDomainDefParseXML(xmlDocPtr xml,
  */
 def->ns = xmlopt->ns;
 
-if (def->ns.parse &&
-(def->ns.parse)(ctxt, >namespaceData) < 0)
-goto error;
+if (def->ns.parse) {
+if ((def->ns.parse)(ctxt, >namespaceData) < 0)
+goto error;
+}
 
 return def;
 
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c5a243684a..f55b9e5409 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2050,9 +2050,10 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt,
 
 if (xmlopt)
 def->ns = xmlopt->ns;
-if (def->ns.parse &&
-(def->ns.parse)(ctxt, >namespaceData) < 0)
-goto error;
+if (def->ns.parse) {
+if ((def->ns.parse)(ctxt, >namespaceData) < 0)
+goto error;
+}
 
 ctxt->node = save;
 return def;
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 05055cdc29..a2b977989f 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -997,9 +997,10 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt)
 /* Make a copy of all the callback pointers here for easier use,
  * especially during the virStoragePoolSourceClear method */
 def->ns = options->ns;
-if (def->ns.parse &&
-(def->ns.parse)(ctxt, >namespaceData) < 0)
-return NULL;
+if (def->ns.parse) {
+if ((def->ns.parse)(ctxt, >namespaceData) < 0)
+return NULL;
+}
 
 VIR_STEAL_PTR(ret, def);
 return ret;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 15/21] conf: network: use virXMLNamespaceFormatNS

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/conf/network_conf.c | 2 +-
 src/network/bridge_driver.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 2c3a11fb10..7eba9eacbf 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -2435,7 +2435,7 @@ virNetworkDefFormatBuf(virBufferPtr buf,
 
 virBufferAddLit(buf, "namespaceData && def->ns.href)
-virBufferAsprintf(buf, " %s", (def->ns.href)());
+virXMLNamespaceFormatNS(buf, >ns);
 if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0))
 virBufferAsprintf(buf, " connections='%d'", def->connections);
 if (def->ipv6nogw)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index b0ada0132a..a3f7ae337a 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -244,7 +244,7 @@ networkDnsmasqDefNamespaceFormatXML(virBufferPtr buf,
 static const char *
 networkDnsmasqDefNamespaceHref(void)
 {
-return "xmlns:dnsmasq='" DNSMASQ_NAMESPACE_HREF "'";
+return DNSMASQ_NAMESPACE_HREF;
 }
 
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 07/21] conf: storage: use generic XML namespace types

2019-08-20 Thread Ján Tomko
There is no need to copy and paste the same types pointing
to void all over the place.

Signed-off-by: Ján Tomko 
---
 src/conf/storage_conf.c   |  4 ++--
 src/conf/storage_conf.h   | 23 ---
 src/storage/storage_backend_fs.c  |  2 +-
 src/storage/storage_backend_rbd.c |  2 +-
 src/storage/storage_util.c|  2 +-
 src/storage/storage_util.h|  2 +-
 6 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index a2b977989f..fb8a16a119 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -140,7 +140,7 @@ struct _virStoragePoolOptions {
 int defaultFormat;
 int lastFormat;
 
-virStoragePoolXMLNamespace ns;
+virXMLNamespace ns;
 
 virStoragePoolFormatToString formatToString;
 virStoragePoolFormatFromString formatFromString;
@@ -341,7 +341,7 @@ virStoragePoolOptionsForPoolType(int type)
  */
 int
 virStoragePoolOptionsPoolTypeSetXMLNamespace(int type,
- virStoragePoolXMLNamespacePtr ns)
+ virXMLNamespacePtr ns)
 {
 int ret = -1;
 virStoragePoolTypeInfoPtr backend = virStoragePoolTypeInfoLookup(type);
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index f399ac6192..1f62803a9d 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -31,28 +31,13 @@
 #include "storage_adapter_conf.h"
 #include "virautoclean.h"
 #include "virenum.h"
+#include "virxml.h"
+
 
-#include 
-
-/* Various callbacks needed to parse/create Storage Pool XML's using
- * a private namespace */
-typedef int (*virStoragePoolDefNamespaceParse)(xmlXPathContextPtr, void **);
-typedef void (*virStoragePoolDefNamespaceFree)(void *);
-typedef int (*virStoragePoolDefNamespaceXMLFormat)(virBufferPtr, void *);
-typedef const char *(*virStoragePoolDefNamespaceHref)(void);
-
-typedef struct _virStoragePoolXMLNamespace virStoragePoolXMLNamespace;
-typedef virStoragePoolXMLNamespace *virStoragePoolXMLNamespacePtr;
-struct _virStoragePoolXMLNamespace {
-virStoragePoolDefNamespaceParse parse;
-virStoragePoolDefNamespaceFree free;
-virStoragePoolDefNamespaceXMLFormat format;
-virStoragePoolDefNamespaceHref href;
-};
 
 int
 virStoragePoolOptionsPoolTypeSetXMLNamespace(int type,
- virStoragePoolXMLNamespacePtr ns);
+ virXMLNamespacePtr ns);
 
 int
 virStoragePoolOptionsFormatPool(virBufferPtr buf,
@@ -277,7 +262,7 @@ struct _virStoragePoolDef {
 
 /* Pool backend specific XML namespace data */
 void *namespaceData;
-virStoragePoolXMLNamespace ns;
+virXMLNamespace ns;
 };
 
 typedef struct _virStoragePoolSourceList virStoragePoolSourceList;
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index ae4e9a03a3..d575b75449 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -701,7 +701,7 @@ virStorageBackend virStorageBackendNetFileSystem = {
 .wipeVol = virStorageBackendVolWipeLocal,
 };
 
-static virStoragePoolXMLNamespace virStoragePoolFSXMLNamespace = {
+static virXMLNamespace virStoragePoolFSXMLNamespace = {
 .parse = virStoragePoolDefFSNamespaceParse,
 .free = virStoragePoolDefFSNamespaceFree,
 .format = virStoragePoolDefFSNamespaceFormatXML,
diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index f3104ba310..e490c690f5 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -1542,7 +1542,7 @@ virStorageBackend virStorageBackendRBD = {
 };
 
 
-static virStoragePoolXMLNamespace virStoragePoolRBDXMLNamespace = {
+static virXMLNamespace virStoragePoolRBDXMLNamespace = {
 .parse = virStoragePoolDefRBDNamespaceParse,
 .free = virStoragePoolDefRBDNamespaceFree,
 .format = virStoragePoolDefRBDNamespaceFormatXML,
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index 62f857f9ea..3dc5ad2969 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -92,7 +92,7 @@ VIR_LOG_INIT("storage.storage_util");
  */
 int
 virStorageBackendNamespaceInit(int poolType,
-   virStoragePoolXMLNamespacePtr xmlns)
+   virXMLNamespacePtr xmlns)
 {
 return virStoragePoolOptionsPoolTypeSetXMLNamespace(poolType, xmlns);
 }
diff --git a/src/storage/storage_util.h b/src/storage/storage_util.h
index 6df5928d9b..705e23631d 100644
--- a/src/storage/storage_util.h
+++ b/src/storage/storage_util.h
@@ -36,7 +36,7 @@ struct _virStoragePoolFSMountOptionsDef {
 
 int
 virStorageBackendNamespaceInit(int poolType,
-   virStoragePoolXMLNamespacePtr xmlns);
+   virXMLNamespacePtr xmlns);
 
 
 /* File creation/cloning functions used for cloning between backends */
-- 
2.19.2

--
libvir-list mailing list

[libvirt] [PATCH 09/21] xml: virXMLNamespace: add prefix

2019-08-20 Thread Ján Tomko
We have hardcoded the namespace prefix in various places:
1) the xmlns string stored in the 'href' function
2) the xmlXPathRegisterNs call in each parser
3) all the parsing and formatting code actually dealing
   with these elements

While eliminating the third one is probably a job for an
actual XML-aware formatter, let's store the prefix separately
here in the virXMLNamespace structure so that future patches
can get rid of the first two bullets.

Signed-off-by: Ján Tomko 
---
 src/util/virxml.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/util/virxml.h b/src/util/virxml.h
index 5b209bb040..ea0c3d3ab3 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -256,6 +256,7 @@ struct _virXMLNamespace {
 virXMLNamespaceParse parse;
 virXMLNamespaceFree free;
 virXMLNamespaceFormat format;
+const char *prefix;
 virXMLNamespaceHref href;
 };
 typedef struct _virXMLNamespace virXMLNamespace;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 02/21] virDomainDefParseXML: remove unused parameter

2019-08-20 Thread Ján Tomko
We do not need to pass the root node, since it's already
included in the XPathContext.

Signed-off-by: Ján Tomko 
---
 src/conf/domain_conf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 40b5f9b801..1f2a91c710 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19643,7 +19643,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
 
 static virDomainDefPtr
 virDomainDefParseXML(xmlDocPtr xml,
- xmlNodePtr root ATTRIBUTE_UNUSED,
  xmlXPathContextPtr ctxt,
  virCapsPtr caps,
  virDomainXMLOptionPtr xmlopt,
@@ -21386,7 +21385,7 @@ virDomainObjParseXML(xmlDocPtr xml,
 
 oldnode = ctxt->node;
 ctxt->node = config;
-obj->def = virDomainDefParseXML(xml, config, ctxt, caps, xmlopt, flags);
+obj->def = virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags);
 ctxt->node = oldnode;
 if (!obj->def)
 goto error;
@@ -21531,7 +21530,7 @@ virDomainDefParseNode(xmlDocPtr xml,
 
 ctxt->node = root;
 
-if (!(def = virDomainDefParseXML(xml, root, ctxt, caps, xmlopt, flags)))
+if (!(def = virDomainDefParseXML(xml, ctxt, caps, xmlopt, flags)))
 goto cleanup;
 
 /* callback to fill driver specific domain aspects */
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] QEMU bitmap backup usability FAQ

2019-08-20 Thread John Snow
Hi, downstream here at Red Hat I've been fielding some questions about
the usability and feature readiness of Bitmaps (and related features) in
QEMU.

Here are some questions I answered internally that I am copying to the
list for two reasons:

(1) To make sure my answers are actually correct, and
(2) To share this pseudo-reference with the community at large.

This is long, and mostly for reference. There's a summary at the bottom
with some todo items and observations about the usability of the feature
as it exists in QEMU.

Before too long, I intend to send a more summarized "roadmap" mail which
details all of the current and remaining work to be done in and around
the bitmaps feature in QEMU.


Questions:

> "What format(s) is/are required for this functionality?"

>From the QEMU API, any format can be used to create and author
incremental backups. The only known format limitations are:

1. Persistent bitmaps cannot be created on any format except qcow2,
although there are hooks to add support to other formats at a later date
if desired.

DANGER CAVEAT #1: Adding bitmaps to QEMU by default creates transient
bitmaps instead of persistent ones.

Possible TODO: Allow users to 'upgrade' transient bitmaps to persistent
ones in case they made a mistake.


2. When using push backups (blockdev-backup, drive-backup), you may use
any format as a target format.

DANGER CAVEAT #2: without backing file and/or filesystem-less sparse
support, these images will be unusable.

EXAMPLE: Backing up to a raw file loses allocation information, so we
can no longer distinguish between zeroes and unallocated regions. The
cluster size is also lost. This file will not be usable without
additional metadata recorded elsewhere.*

(* This is complicated, but it is in theory possible to do a push backup
to e.g. an NBD target with custom server code that saves allocation
information to a metadata file, which would allow you to reconstruct
backups. For instance, recording in a .json file which extents were
written out would allow you to -- with a custom binary -- write this
information on top of a base file to reconstruct a backup.)


3. Any format can be used for either shared storage or live storage
migrations. There are TWO distinct mechanisms for migrating bitmaps:

A) The bitmap is flushed to storage and re-opened on the destination.
This is only supported for qcow2 and shared-storage migrations.

B) The bitmap is live-migrated to the destination. This is supported for
any format and can be used for either shared storage or live storage
migrations.

DANGER CAVEAT #3: The second bitmap migration technique there is an
optional migration capability that must be enabled explicitly.
Otherwise, some migration combinations may drop bitmaps.

Matrix:

> migrate = migrate_capability or (persistent and shared_storage)

Enumerated:

live storage + raw : transient + no-capability: Dropped
live-storage + raw : transient + bm-capability: Migrated
live-storage + qcow2 : transient + no-capability: Dropped
live-storage + qcow2 : transient + bm-capability: Migrated
live-storage + qcow2 : persistent + no-capability: Dropped (!)
live-storage + qcow2 : persistent + bm-capability: Migrated

shared-storage + raw : transient - no-capability: Dropped
shared-storage + raw : transient + bm-capability: Migrated
shared-storage + qcow2 : transient + no-capability: Migrated
shared-storage + qcow2 : transient + bm-capability: Migrated
shared-storage + qcow2 : persistent + no-capability: Migrated
shared-storage + qcow2 : persistent + bm-capability: Migrated

Enabling the bitmap migration capability will ALWAYS migrate the bitmap.
If it's disabled, we will only migrate the bitmaps for shared storage
migrations where the bitmap is persistent, which is a qcow2-only case.

There is no warning or error if you attempt to migrate in a manner that
loses your bitmaps.

(I might be persuaded to add a case for when you are doing a live
storage migration of qcow2 with persistent bitmaps, which is somewhat a
conflicting case: you've asked for the bitmap to be persistent, but it
seems likely that if this ever happens in practice, it's because you
have neglected to ask for it to be migrated to the new host.)

See iotest 169 for more details on this.

At present, these are the only format limitations I am consciously aware
of. From a management API/GUI perspective, it makes sense to restrict
the feature set to "qcow2 only" to minimize edge cases.


> "Is libvirt aware of these 'gotcha' cases?"

>From talks I've had with Eric Blake and Peter Krempa, they certainly are
now.


> "Is it possible to make persistent the default?"

Not quickly.

In QEMU, not without a deprecation period or some other incompatibility.
Default values are not (yet?) introspectable via the schema. We need
(possibly) up to two QAPI extensions:

I) The ability to return deprecation warnings when issuing a command
that will cease to work in the future.

This has been being discussed somewhat on-list recently. 

[libvirt] [jenkins-ci PATCH 7/7] Switch osinfo-db-tools builds to Meson

2019-08-20 Thread Fabiano Fidêncio
Signed-off-by: Fabiano Fidêncio 
---
 .../playbooks/build/projects/osinfo-db-tools+mingw32.yml  | 4 ++--
 .../playbooks/build/projects/osinfo-db-tools+mingw64.yml  | 4 ++--
 guests/playbooks/build/projects/osinfo-db-tools.yml   | 8 
 jenkins/projects/osinfo-db-tools+mingw32.yaml | 4 ++--
 jenkins/projects/osinfo-db-tools+mingw64.yaml | 4 ++--
 jenkins/projects/osinfo-db-tools.yaml | 8 
 6 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml 
b/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml
index e64bf8a..c083226 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml
@@ -6,7 +6,7 @@
 git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
 
 - include: '{{ playbook_base }}/jobs/prepare.yml'
-- include: '{{ playbook_base }}/jobs/autotools-build-job.yml'
+- include: '{{ playbook_base }}/jobs/meson-build-job.yml'
   vars:
 local_env: '{{ mingw32_local_env }}'
-autogen_args: '{{ mingw32_autogen_args }}'
+meson_args: '{{ mingw32_meson_args }}'
diff --git a/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml 
b/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml
index df07e7e..1671841 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml
@@ -6,7 +6,7 @@
 git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
 
 - include: '{{ playbook_base }}/jobs/prepare.yml'
-- include: '{{ playbook_base }}/jobs/autotools-build-job.yml'
+- include: '{{ playbook_base }}/jobs/meson-build-job.yml'
   vars:
 local_env: '{{ mingw64_local_env }}'
-autogen_args: '{{ mingw64_autogen_args }}'
+meson_args: '{{ mingw64_meson_args }}'
diff --git a/guests/playbooks/build/projects/osinfo-db-tools.yml 
b/guests/playbooks/build/projects/osinfo-db-tools.yml
index 9ef3672..4bb6236 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools.yml
@@ -16,9 +16,9 @@
 git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
 
 - include: '{{ playbook_base }}/jobs/prepare.yml'
-- include: '{{ playbook_base }}/jobs/autotools-build-job.yml'
-- include: '{{ playbook_base }}/jobs/autotools-syntax-check-job.yml'
-- include: '{{ playbook_base }}/jobs/autotools-check-job.yml'
-- include: '{{ playbook_base }}/jobs/autotools-rpm-job.yml'
+- include: '{{ playbook_base }}/jobs/meson-build-job.yml'
+- include: '{{ playbook_base }}/jobs/meson-syntax-check-job.yml'
+- include: '{{ playbook_base }}/jobs/meson-check-job.yml'
+- include: '{{ playbook_base }}/jobs/meson-rpm-job.yml'
   vars:
 machines: '{{ rpm_machines }}'
diff --git a/jenkins/projects/osinfo-db-tools+mingw32.yaml 
b/jenkins/projects/osinfo-db-tools+mingw32.yaml
index d796ca1..fd4a950 100644
--- a/jenkins/projects/osinfo-db-tools+mingw32.yaml
+++ b/jenkins/projects/osinfo-db-tools+mingw32.yaml
@@ -6,7 +6,7 @@
 archive_format: xz
 git_url: '{git_urls[osinfo-db-tools][default]}'
 jobs:
-  - autotools-build-job:
+  - meson-build-job:
   parent_jobs:
   local_env: '{mingw32_local_env}'
-  autogen_args: '{mingw32_autogen_args}'
+  meson_args: '{mingw32_meson_args}'
diff --git a/jenkins/projects/osinfo-db-tools+mingw64.yaml 
b/jenkins/projects/osinfo-db-tools+mingw64.yaml
index 7808fed..959c48c 100644
--- a/jenkins/projects/osinfo-db-tools+mingw64.yaml
+++ b/jenkins/projects/osinfo-db-tools+mingw64.yaml
@@ -6,7 +6,7 @@
 archive_format: xz
 git_url: '{git_urls[osinfo-db-tools][default]}'
 jobs:
-  - autotools-build-job:
+  - meson-build-job:
   parent_jobs:
   local_env: '{mingw64_local_env}'
-  autogen_args: '{mingw64_autogen_args}'
+  meson_args: '{mingw64_meson_args}'
diff --git a/jenkins/projects/osinfo-db-tools.yaml 
b/jenkins/projects/osinfo-db-tools.yaml
index 503533a..15a95d3 100644
--- a/jenkins/projects/osinfo-db-tools.yaml
+++ b/jenkins/projects/osinfo-db-tools.yaml
@@ -14,12 +14,12 @@
 archive_format: xz
 git_url: '{git_urls[osinfo-db-tools][default]}'
 jobs:
-  - autotools-build-job:
+  - meson-build-job:
   parent_jobs:
-  - autotools-syntax-check-job:
+  - meson-syntax-check-job:
   parent_jobs: 'osinfo-db-tools-build'
-  - autotools-check-job:
+  - meson-check-job:
   parent_jobs: 'osinfo-db-tools-syntax-check'
-  - autotools-rpm-job:
+  - meson-rpm-job:
   parent_jobs: 'osinfo-db-tools-check'
   machines: '{rpm_machines}'
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 5/7] Only build osinfo-db-tools on systems with meson >= 0.49.0

2019-08-20 Thread Fabiano Fidêncio
osinfo-db-tools has switched its build system to meson and requires
0.49.0 or newer.

Signed-off-by: Fabiano Fidêncio 
---
 guests/host_vars/libvirt-centos-7/main.yml|  1 -
 guests/host_vars/libvirt-debian-9/main.yml|  1 -
 guests/host_vars/libvirt-ubuntu-16/main.yml   |  1 -
 guests/host_vars/libvirt-ubuntu-18/main.yml   |  1 -
 .../build/projects/osinfo-db-tools.yml| 22 ---
 jenkins/projects/osinfo-db-tools.yaml | 20 -
 6 files changed, 18 insertions(+), 28 deletions(-)

diff --git a/guests/host_vars/libvirt-centos-7/main.yml 
b/guests/host_vars/libvirt-centos-7/main.yml
index 94e29af..72db363 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -9,7 +9,6 @@ projects:
   - libvirt-perl
   - libvirt-python
   - osinfo-db
-  - osinfo-db-tools
   - virt-viewer
 
 package_format: 'rpm'
diff --git a/guests/host_vars/libvirt-debian-9/main.yml 
b/guests/host_vars/libvirt-debian-9/main.yml
index 6b685a4..c45c0fb 100644
--- a/guests/host_vars/libvirt-debian-9/main.yml
+++ b/guests/host_vars/libvirt-debian-9/main.yml
@@ -12,7 +12,6 @@ projects:
   - libvirt-sandbox
   - libvirt-tck
   - osinfo-db
-  - osinfo-db-tools
   - virt-manager
   - virt-viewer
 
diff --git a/guests/host_vars/libvirt-ubuntu-16/main.yml 
b/guests/host_vars/libvirt-ubuntu-16/main.yml
index 179dd03..3e9ae9f 100644
--- a/guests/host_vars/libvirt-ubuntu-16/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-16/main.yml
@@ -12,7 +12,6 @@ projects:
   - libvirt-sandbox
   - libvirt-tck
   - osinfo-db
-  - osinfo-db-tools
   - virt-viewer
 
 package_format: 'deb'
diff --git a/guests/host_vars/libvirt-ubuntu-18/main.yml 
b/guests/host_vars/libvirt-ubuntu-18/main.yml
index 5b5bf0c..4a38ab0 100644
--- a/guests/host_vars/libvirt-ubuntu-18/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-18/main.yml
@@ -12,7 +12,6 @@ projects:
   - libvirt-sandbox
   - libvirt-tck
   - osinfo-db
-  - osinfo-db-tools
   - virt-manager
   - virt-viewer
 
diff --git a/guests/playbooks/build/projects/osinfo-db-tools.yml 
b/guests/playbooks/build/projects/osinfo-db-tools.yml
index c5d0281..1e69e0d 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools.yml
@@ -1,19 +1,9 @@
 ---
 - set_fact:
 name: osinfo-db-tools
-machines: '{{ all_machines }}'
-archive_format: gz
-git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
-
-- include: '{{ playbook_base }}/jobs/prepare.yml'
-- include: '{{ playbook_base }}/jobs/autotools-build-job.yml'
-- include: '{{ playbook_base }}/jobs/autotools-syntax-check-job.yml'
-- include: '{{ playbook_base }}/jobs/autotools-check-job.yml'
-  vars:
-# osinfo-db-tools tests are Python 3 only, so they can't be ran on
-# CentOS 7;
+# osinfo-db-tools depends on meson 0.49.0, which is not available on
+# CentOS 7, Debian 9, Ubuntu 18;
 machines:
-  - libvirt-debian-9
   - libvirt-debian-10
   - libvirt-debian-sid
   - libvirt-fedora-29
@@ -22,7 +12,13 @@
   - libvirt-freebsd-11
   - libvirt-freebsd-12
   - libvirt-freebsd-current
-  - libvirt-ubuntu-18
+archive_format: gz
+git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
+
+- include: '{{ playbook_base }}/jobs/prepare.yml'
+- include: '{{ playbook_base }}/jobs/autotools-build-job.yml'
+- include: '{{ playbook_base }}/jobs/autotools-syntax-check-job.yml'
+- include: '{{ playbook_base }}/jobs/autotools-check-job.yml'
 - include: '{{ playbook_base }}/jobs/autotools-rpm-job.yml'
   vars:
 machines: '{{ rpm_machines }}'
diff --git a/jenkins/projects/osinfo-db-tools.yaml 
b/jenkins/projects/osinfo-db-tools.yaml
index c75d323..d183e75 100644
--- a/jenkins/projects/osinfo-db-tools.yaml
+++ b/jenkins/projects/osinfo-db-tools.yaml
@@ -1,7 +1,15 @@
 ---
 - project:
 name: osinfo-db-tools
-machines: '{all_machines}'
+# osinfo-db-tools requires meson 0.49.0, which is not available on
+# CentOS 7 and Debian 9;
+machines:
+  - libvirt-debian-10
+  - libvirt-fedora-29
+  - libvirt-fedora-30
+  - libvirt-fedora-rawhide
+  - libvirt-freebsd-11
+  - libvirt-freebsd-12
 title: osinfo database tools
 archive_format: gz
 git_url: '{git_urls[osinfo-db-tools][default]}'
@@ -12,16 +20,6 @@
   parent_jobs: 'osinfo-db-tools-build'
   - autotools-check-job:
   parent_jobs: 'osinfo-db-tools-syntax-check'
-  # osinfo-db-tools tests are Python 3 only, so they can't be ran on
-  # CentOS 7;
-  machines:
-- libvirt-debian-9
-- libvirt-debian-10
-- libvirt-fedora-29
-- libvirt-fedora-30
-- libvirt-fedora-rawhide
-- libvirt-freebsd-11
-- libvirt-freebsd-12
   - autotools-rpm-job:
   parent_jobs: 'osinfo-db-tools-check'
   machines: '{rpm_machines}'
-- 
2.21.0

--
libvir-list mailing list

[libvirt] [jenkins-ci PATCH 1/7] jobs: add a template for Meson

2019-08-20 Thread Fabiano Fidêncio
Add a template for projects using the Meson framework.

Signed-off-by: Fabiano Fidêncio 
---
 jenkins/jobs/defaults.yaml |   3 +
 jenkins/jobs/meson.yaml| 174 +
 2 files changed, 177 insertions(+)
 create mode 100644 jenkins/jobs/meson.yaml

diff --git a/jenkins/jobs/defaults.yaml b/jenkins/jobs/defaults.yaml
index 050c7b5..af78714 100644
--- a/jenkins/jobs/defaults.yaml
+++ b/jenkins/jobs/defaults.yaml
@@ -21,6 +21,7 @@
 global_env: ''
 local_env: ''
 autogen_args: ''
+meson_args: ''
 command: ''
 command_pre_build: ''
 strip_buildrequires: |
@@ -33,11 +34,13 @@
   export PKG_CONFIG_PATH="$VIRT_PREFIX/lib/pkgconfig"
   export 
PKG_CONFIG_LIBDIR="/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/i686-w64-mingw32/sys-root/mingw/share/pkgconfig"
 mingw32_autogen_args: --host=i686-w64-mingw32
+mingw32_meson_args: --cross-file="/usr/share/mingw/toolchain-mingw32.meson"
 mingw64_local_env: |
   export VIRT_PREFIX="$VIRT_PREFIX/x86_64-w64-mingw32/sys-root/mingw"
   export PKG_CONFIG_PATH="$VIRT_PREFIX/lib/pkgconfig"
   export 
PKG_CONFIG_LIBDIR="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/x86_64-w64-mingw32/sys-root/mingw/share/pkgconfig"
 mingw64_autogen_args: --host=x86_64-w64-mingw32
+mingw64_meson_args: --cross-file="/usr/share/mingw/toolchain-mingw64.meson"
 git_urls:
   libosinfo:
 default: https://gitlab.com/libosinfo/libosinfo.git
diff --git a/jenkins/jobs/meson.yaml b/jenkins/jobs/meson.yaml
new file mode 100644
index 000..5c0be01
--- /dev/null
+++ b/jenkins/jobs/meson.yaml
@@ -0,0 +1,174 @@
+---
+- job-template:
+id: meson-build-job
+name: '{name}-build'
+project-type: matrix
+description: '{title} Build'
+workspace: '{name}'
+child-workspace: '.'
+block-downstream: true
+block-upstream: true
+wrappers:
+  - timeout:
+  abort: true
+  type: absolute
+  timeout: 90
+  write-description: 'Aborted build after 90 minutes'
+properties:
+  - build-discarder:
+  days-to-keep: 30
+  num-to-keep: 1000
+scm:
+  - git:
+  url: '{git_url}'
+  branches:
+- origin/master
+  clean:
+after: true
+  skip-tag: true
+  wipe-workspace: false
+triggers:
+  - reverse:
+  jobs: '{obj:parent_jobs}'
+  - pollscm:
+  cron: "H/20 * * * *"
+axes:
+  - axis:
+  name: systems
+  type: slave
+  values: '{obj:machines}'
+builders:
+  - shell: |
+  {global_env}
+  {local_env}
+  rm -rf build
+  meson build --prefix=$VIRT_PREFIX {meson_args}
+  ninja -C build
+  ninja -C build install
+publishers:
+  - email:
+  recipients: '{obj:spam}'
+  notify-every-unstable-build: false
+  send-to-individuals: false
+
+- job-template:
+id: meson-syntax-check-job
+name: '{name}-syntax-check'
+project-type: matrix
+description: '{title} Syntax Check'
+workspace: '{name}'
+child-workspace: '.'
+block-downstream: true
+block-upstream: true
+wrappers:
+  - timeout:
+  abort: true
+  type: absolute
+  timeout: 90
+  write-description: 'Aborted build after 90 minutes'
+properties:
+  - build-discarder:
+  days-to-keep: 30
+  num-to-keep: 1000
+triggers:
+  - reverse:
+  jobs: '{obj:parent_jobs}'
+axes:
+  - axis:
+  name: systems
+  type: slave
+  values: '{obj:machines}'
+builders:
+  - shell: |
+  {global_env}
+  {local_env}
+  ninja -C build syntax-check
+publishers:
+  - email:
+  recipients: '{obj:spam}'
+  notify-every-unstable-build: false
+  send-to-individuals: false
+
+- job-template:
+id: meson-test-job
+name: '{name}-check'
+project-type: matrix
+description: '{title} Check'
+workspace: '{name}'
+child-workspace: '.'
+block-downstream: true
+block-upstream: true
+wrappers:
+  - timeout:
+  abort: true
+  type: absolute
+  timeout: 90
+  write-description: 'Aborted build after 90 minutes'
+properties:
+  - build-discarder:
+  days-to-keep: 30
+  num-to-keep: 1000
+triggers:
+  - reverse:
+  jobs: '{obj:parent_jobs}'
+axes:
+  - axis:
+  name: systems
+  type: slave
+  values: '{obj:machines}'
+builders:
+  - shell: |
+  {global_env}
+  {local_env}
+  if ! ninja -C build test
+  then
+  cat build/meson-logs/testlog.txt || true
+  exit 1
+  fi
+publishers:
+  - email:
+  recipients: '{obj:spam}'
+  notify-every-unstable-build: false
+  

[libvirt] [jenkins-ci PATCH 4/7] osinfo-db-tools: Add meson dependency

2019-08-20 Thread Fabiano Fidêncio
It's been introduced as dependency as part of v1.7.0 development cycle.

Signed-off-by: Fabiano Fidêncio 
---
 guests/vars/projects/osinfo-db-tools+mingw32.yml | 1 +
 guests/vars/projects/osinfo-db-tools+mingw64.yml | 1 +
 guests/vars/projects/osinfo-db-tools.yml | 1 +
 3 files changed, 3 insertions(+)

diff --git a/guests/vars/projects/osinfo-db-tools+mingw32.yml 
b/guests/vars/projects/osinfo-db-tools+mingw32.yml
index 0952d09..d10f966 100644
--- a/guests/vars/projects/osinfo-db-tools+mingw32.yml
+++ b/guests/vars/projects/osinfo-db-tools+mingw32.yml
@@ -1,5 +1,6 @@
 ---
 packages:
+  - meson
   - mingw32-glib2
   - mingw32-json-glib
   - mingw32-libarchive
diff --git a/guests/vars/projects/osinfo-db-tools+mingw64.yml 
b/guests/vars/projects/osinfo-db-tools+mingw64.yml
index 5f099f0..42dad20 100644
--- a/guests/vars/projects/osinfo-db-tools+mingw64.yml
+++ b/guests/vars/projects/osinfo-db-tools+mingw64.yml
@@ -1,5 +1,6 @@
 ---
 packages:
+  - meson
   - mingw64-glib2
   - mingw64-json-glib
   - mingw64-libarchive
diff --git a/guests/vars/projects/osinfo-db-tools.yml 
b/guests/vars/projects/osinfo-db-tools.yml
index ad38a1f..388cfb6 100644
--- a/guests/vars/projects/osinfo-db-tools.yml
+++ b/guests/vars/projects/osinfo-db-tools.yml
@@ -1,5 +1,6 @@
 ---
 packages:
+  - meson
   - glib2
   - json-glib
   - libarchive
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 6/7] Update osinfo-db-tools' archive_format

2019-08-20 Thread Fabiano Fidêncio
Since the switch to meson, osinfo-db-tools' archive format is "xz"
instead of "gz".

Signed-off-by: Fabiano Fidêncio 
---
 guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml | 2 +-
 guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml | 2 +-
 guests/playbooks/build/projects/osinfo-db-tools.yml | 2 +-
 jenkins/projects/osinfo-db-tools+mingw32.yaml   | 2 +-
 jenkins/projects/osinfo-db-tools+mingw64.yaml   | 2 +-
 jenkins/projects/osinfo-db-tools.yaml   | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml 
b/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml
index 5bf12ad..e64bf8a 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools+mingw32.yml
@@ -2,7 +2,7 @@
 - set_fact:
 name: osinfo-db-tools+mingw32
 machines: '{{ mingw_machines }}'
-archive_format: gz
+archive_format: xz
 git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
 
 - include: '{{ playbook_base }}/jobs/prepare.yml'
diff --git a/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml 
b/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml
index 9e51bcf..df07e7e 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools+mingw64.yml
@@ -2,7 +2,7 @@
 - set_fact:
 name: osinfo-db-tools+mingw64
 machines: '{{ mingw_machines }}'
-archive_format: gz
+archive_format: xz
 git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
 
 - include: '{{ playbook_base }}/jobs/prepare.yml'
diff --git a/guests/playbooks/build/projects/osinfo-db-tools.yml 
b/guests/playbooks/build/projects/osinfo-db-tools.yml
index 1e69e0d..9ef3672 100644
--- a/guests/playbooks/build/projects/osinfo-db-tools.yml
+++ b/guests/playbooks/build/projects/osinfo-db-tools.yml
@@ -12,7 +12,7 @@
   - libvirt-freebsd-11
   - libvirt-freebsd-12
   - libvirt-freebsd-current
-archive_format: gz
+archive_format: xz
 git_url: '{{ git_urls["osinfo-db-tools"][git_remote] }}'
 
 - include: '{{ playbook_base }}/jobs/prepare.yml'
diff --git a/jenkins/projects/osinfo-db-tools+mingw32.yaml 
b/jenkins/projects/osinfo-db-tools+mingw32.yaml
index a929118..d796ca1 100644
--- a/jenkins/projects/osinfo-db-tools+mingw32.yaml
+++ b/jenkins/projects/osinfo-db-tools+mingw32.yaml
@@ -3,7 +3,7 @@
 name: osinfo-db-tools+mingw32
 machines: '{mingw_machines}'
 title: osinfo database tools MinGW (32-bit)
-archive_format: gz
+archive_format: xz
 git_url: '{git_urls[osinfo-db-tools][default]}'
 jobs:
   - autotools-build-job:
diff --git a/jenkins/projects/osinfo-db-tools+mingw64.yaml 
b/jenkins/projects/osinfo-db-tools+mingw64.yaml
index f2d6d57..7808fed 100644
--- a/jenkins/projects/osinfo-db-tools+mingw64.yaml
+++ b/jenkins/projects/osinfo-db-tools+mingw64.yaml
@@ -3,7 +3,7 @@
 name: osinfo-db-tools+mingw64
 machines: '{mingw_machines}'
 title: osinfo database tools MinGW (64-bit)
-archive_format: gz
+archive_format: xz
 git_url: '{git_urls[osinfo-db-tools][default]}'
 jobs:
   - autotools-build-job:
diff --git a/jenkins/projects/osinfo-db-tools.yaml 
b/jenkins/projects/osinfo-db-tools.yaml
index d183e75..503533a 100644
--- a/jenkins/projects/osinfo-db-tools.yaml
+++ b/jenkins/projects/osinfo-db-tools.yaml
@@ -11,7 +11,7 @@
   - libvirt-freebsd-11
   - libvirt-freebsd-12
 title: osinfo database tools
-archive_format: gz
+archive_format: xz
 git_url: '{git_urls[osinfo-db-tools][default]}'
 jobs:
   - autotools-build-job:
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 2/7] guests: Add Meson jobs

2019-08-20 Thread Fabiano Fidêncio
These tasks mirror the Jenkins's Meson jobs contained in the top-level
jobs/ directory.

Signed-off-by: Fabiano Fidêncio 
---
 guests/playbooks/build/jobs/defaults.yml  |  3 +++
 guests/playbooks/build/jobs/meson-build-job.yml   | 14 ++
 guests/playbooks/build/jobs/meson-check-job.yml   | 15 +++
 guests/playbooks/build/jobs/meson-rpm-job.yml | 15 +++
 .../build/jobs/meson-syntax-check-job.yml | 11 +++
 5 files changed, 58 insertions(+)
 create mode 100644 guests/playbooks/build/jobs/meson-build-job.yml
 create mode 100644 guests/playbooks/build/jobs/meson-check-job.yml
 create mode 100644 guests/playbooks/build/jobs/meson-rpm-job.yml
 create mode 100644 guests/playbooks/build/jobs/meson-syntax-check-job.yml

diff --git a/guests/playbooks/build/jobs/defaults.yml 
b/guests/playbooks/build/jobs/defaults.yml
index 311f980..33dde45 100644
--- a/guests/playbooks/build/jobs/defaults.yml
+++ b/guests/playbooks/build/jobs/defaults.yml
@@ -22,6 +22,7 @@ mingw_machines:
 global_env: ''
 local_env: ''
 autogen_args: ''
+meson_args: ''
 command: ''
 command_pre_build: ''
 strip_buildrequires: |
@@ -34,11 +35,13 @@ mingw32_local_env: |
   export PKG_CONFIG_PATH="$VIRT_PREFIX/lib/pkgconfig"
   export 
PKG_CONFIG_LIBDIR="/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/i686-w64-mingw32/sys-root/mingw/share/pkgconfig"
 mingw32_autogen_args: --host=i686-w64-mingw32
+mingw32_meson_args: --cross-file="/usr/share/mingw/toolchain-mingw32.meson"
 mingw64_local_env: |
   export VIRT_PREFIX="$VIRT_PREFIX/x86_64-w64-mingw32/sys-root/mingw"
   export PKG_CONFIG_PATH="$VIRT_PREFIX/lib/pkgconfig"
   export 
PKG_CONFIG_LIBDIR="/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig:/usr/x86_64-w64-mingw32/sys-root/mingw/share/pkgconfig"
 mingw64_autogen_args: --host=x86_64-w64-mingw32
+mingw64_meson_args: --cross-file="/usr/share/mingw/toolchain-mingw64.meson"
 git_urls:
   libosinfo:
 default: https://gitlab.com/libosinfo/libosinfo.git
diff --git a/guests/playbooks/build/jobs/meson-build-job.yml 
b/guests/playbooks/build/jobs/meson-build-job.yml
new file mode 100644
index 000..aab8256
--- /dev/null
+++ b/guests/playbooks/build/jobs/meson-build-job.yml
@@ -0,0 +1,14 @@
+---
+- name: '{{ name }}-build'
+  shell: |
+set -e
+cd {{ name }}
+
+{{ global_env }}
+{{ local_env }}
+rm -rf build
+meson build --prefix=$VIRT_PREFIX {{ meson_args }}
+ninja -C build
+ninja -C build install
+  when:
+- inventory_hostname in machines
diff --git a/guests/playbooks/build/jobs/meson-check-job.yml 
b/guests/playbooks/build/jobs/meson-check-job.yml
new file mode 100644
index 000..d4a361d
--- /dev/null
+++ b/guests/playbooks/build/jobs/meson-check-job.yml
@@ -0,0 +1,15 @@
+---
+- name: '{{ name }}-check'
+  shell: |
+set -e
+cd {{ name }}
+
+{{ global_env }}
+{{ local_env }}
+if ! ninja -C build test
+then
+cat build/meson-logs/testlog.txt || true
+exit 1
+fi
+  when:
+- inventory_hostname in machines
diff --git a/guests/playbooks/build/jobs/meson-rpm-job.yml 
b/guests/playbooks/build/jobs/meson-rpm-job.yml
new file mode 100644
index 000..f517214
--- /dev/null
+++ b/guests/playbooks/build/jobs/meson-rpm-job.yml
@@ -0,0 +1,15 @@
+---
+- name: '{{ name }}-rpm'
+  shell: |
+set -e
+cd {{ name }}
+
+{{ global_env }}
+{{ local_env }}
+cd build
+{{ strip_buildrequires }}
+rm -f meson-dist/*.tar.{{ archive_format }}
+ninja dist
+rpmbuild --clean --define "_topdir `pwd`/rpmbuild" -ta meson-dist/*.tar.{{ 
archive_format }}
+  when:
+- inventory_hostname in machines
diff --git a/guests/playbooks/build/jobs/meson-syntax-check-job.yml 
b/guests/playbooks/build/jobs/meson-syntax-check-job.yml
new file mode 100644
index 000..5609bb4
--- /dev/null
+++ b/guests/playbooks/build/jobs/meson-syntax-check-job.yml
@@ -0,0 +1,11 @@
+---
+- name: '{{ name }}-syntax-check'
+  shell: |
+set -e
+cd {{ name }}
+
+{{ global_env }}
+{{ local_env }}
+ninja -C build syntax-check
+  when:
+- inventory_hostname in machines
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 0/7] Switch osinfo-db-tools to Meson

2019-08-20 Thread Fabiano Fidêncio
This patch series switches osinfo-db-tools to using meson instead of
autotools.

In order to do so, meson build jobs had to be added as the first step.

I've tried to make the osinfo-db-tools changes as small as possible so
it'd make the review easier.

Fabiano Fidêncio (7):
  jobs: add a template for Meson
  guests: Add Meson jobs
  mappings: Add meson
  osinfo-db-tools: Add meson dependency
  Only build osinfo-db-tools on systems with meson >= 0.49.0
  Update osinfo-db-tools' archive_format
  Switch osinfo-db-tools builds to Meson

 guests/host_vars/libvirt-centos-7/main.yml|   1 -
 guests/host_vars/libvirt-debian-9/main.yml|   1 -
 guests/host_vars/libvirt-ubuntu-16/main.yml   |   1 -
 guests/host_vars/libvirt-ubuntu-18/main.yml   |   1 -
 guests/playbooks/build/jobs/defaults.yml  |   3 +
 .../playbooks/build/jobs/meson-build-job.yml  |  14 ++
 .../playbooks/build/jobs/meson-check-job.yml  |  15 ++
 guests/playbooks/build/jobs/meson-rpm-job.yml |  15 ++
 .../build/jobs/meson-syntax-check-job.yml |  11 ++
 .../projects/osinfo-db-tools+mingw32.yml  |   6 +-
 .../projects/osinfo-db-tools+mingw64.yml  |   6 +-
 .../build/projects/osinfo-db-tools.yml|  24 +--
 guests/vars/mappings.yml  |   3 +
 .../vars/projects/osinfo-db-tools+mingw32.yml |   1 +
 .../vars/projects/osinfo-db-tools+mingw64.yml |   1 +
 guests/vars/projects/osinfo-db-tools.yml  |   1 +
 jenkins/jobs/defaults.yaml|   3 +
 jenkins/jobs/meson.yaml   | 174 ++
 jenkins/projects/osinfo-db-tools+mingw32.yaml |   6 +-
 jenkins/projects/osinfo-db-tools+mingw64.yaml |   6 +-
 jenkins/projects/osinfo-db-tools.yaml |  30 ++-
 21 files changed, 277 insertions(+), 46 deletions(-)
 create mode 100644 guests/playbooks/build/jobs/meson-build-job.yml
 create mode 100644 guests/playbooks/build/jobs/meson-check-job.yml
 create mode 100644 guests/playbooks/build/jobs/meson-rpm-job.yml
 create mode 100644 guests/playbooks/build/jobs/meson-syntax-check-job.yml
 create mode 100644 jenkins/jobs/meson.yaml

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [jenkins-ci PATCH 3/7] mappings: Add meson

2019-08-20 Thread Fabiano Fidêncio
meson is a new dependency, introduced as part of v1.7.0 release, for
(mingw-*)?osinfo-db-tools.

Signed-off-by: Fabiano Fidêncio 
---
 guests/vars/mappings.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/guests/vars/mappings.yml b/guests/vars/mappings.yml
index 5012741..c5a7824 100644
--- a/guests/vars/mappings.yml
+++ b/guests/vars/mappings.yml
@@ -442,6 +442,9 @@ mappings:
 default: make
 FreeBSD: gmake
 
+  meson:
+default: meson
+
   mingw32-curl:
 Fedora: mingw32-curl
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 00/12] Drop KVM assignment

2019-08-20 Thread Daniel Henrique Barboza



On 8/20/19 11:30 AM, Michal Privoznik wrote:

The KVM style of PCI assignment is not used, and it hasn't been for a
while. Any attempt to start a domain with it would result in error as
kernel dropped its support in 4.12.0 (after being deprecated for 1.5
years).


LGTM. Just a comment in patch 01.


After applying the whole series I tried to find the remaining references
of 'pci-assign'. This is what git grep returns:


$ git grep 'pci-assign'
src/qemu/qemu_capabilities.h:    X_QEMU_CAPS_PCI_CONFIGFD, /* 
pci-assign.configfd */
src/qemu/qemu_capabilities.h:    X_QEMU_CAPS_PCI_BOOTINDEX, /* 
pci-assign.bootindex */
tests/qemucapabilitiesdata/caps_1.5.3.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_1.6.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_1.7.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.1.1.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.10.0.x86_64.replies:  "name": 
"kvm-pci-assign",
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.7.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.8.0.x86_64.replies:  "name": 
"kvm-pci-assign"
tests/qemucapabilitiesdata/caps_2.9.0.x86_64.replies:  "name": 
"kvm-pci-assign"



And with 'configfd':

$ git grep 'configfd'
docs/news-2011.html.in:  qemu: simplify PCI configfd handling in 
monitor (Eric Blake),

src/qemu/qemu_capabilities.c:  "pci-configfd",
src/qemu/qemu_capabilities.h:    X_QEMU_CAPS_PCI_CONFIGFD, /* 
pci-assign.configfd */
tests/qemustatusxml2xmldata/migration-in-params-in.xml:    name='pci-configfd'/>
tests/qemustatusxml2xmldata/migration-out-params-in.xml:    name='pci-configfd'/>




Do we still need X_QEMU_CAPS_PCI_CONFIGFD and X_QEMU_CAPS_PCI_BOOTINDEX
after this series?



Thanks,


DHB



Michal Prívozník (12):
   qemu: Drop KVM assignment
   tests: Remove 'kvm' PCI backend from domaincapstest
   virhostdev: Unify virDomainHostdevDef to virPCIDevice translation
   qemu: Drop unused qemuOpenPCIConfig()
   virhostdev: Disable legacy kvm assignment
   virpci: Drop 'pci-stub' driver
   virpci: Remove unused virPCIDeviceWaitForCleanup
   virpci: Drop newid style of PCI device detach
   virpcimock: Don't create "pci-stub" driver
   virpcimock: Don't create new_id or remove_id files
   virpcimock: Drop @driverActions enum
   news: Document KVM assignment removal

  docs/news.xml |  13 +
  src/libvirt_private.syms  |   1 -
  src/qemu/qemu_capabilities.c  |   6 -
  src/qemu/qemu_command.c   |  48 +--
  src/qemu/qemu_command.h   |   3 -
  src/qemu/qemu_driver.c|  14 +-
  src/qemu/qemu_hostdev.c   |  44 +-
  src/qemu/qemu_hostdev.h   |   1 -
  src/qemu/qemu_hotplug.c   |  20 +-
  src/util/virhostdev.c |  97 +++--
  src/util/virpci.c | 403 +-
  src/util/virpci.h |   2 -
  .../qemu_1.7.0.x86_64.xml |   1 -
  .../qemu_2.12.0-virt.aarch64.xml  |   1 -
  .../qemu_2.12.0.ppc64.xml |   1 -
  .../qemu_2.12.0.s390x.xml |   1 -
  .../qemu_2.12.0.x86_64.xml|   1 -
  .../qemu_2.6.0-virt.aarch64.xml   |   1 -
  .../qemu_2.6.0.aarch64.xml|   1 -
  .../domaincapsschemadata/qemu_2.6.0.ppc64.xml |   1 -
  .../qemu_2.6.0.x86_64.xml |   1 -
  .../domaincapsschemadata/qemu_2.7.0.s390x.xml |   1 -
  .../qemu_2.8.0-tcg.x86_64.xml |   1 -
  .../domaincapsschemadata/qemu_2.8.0.s390x.xml |   1 -
  .../qemu_2.8.0.x86_64.xml |   1 -
  .../qemu_2.9.0-q35.x86_64.xml |   1 -
  .../qemu_2.9.0-tcg.x86_64.xml |   1 -
  .../qemu_2.9.0.x86_64.xml |   1 -
  .../domaincapsschemadata/qemu_3.0.0.s390x.xml |   1 -
  .../qemu_3.1.0.x86_64.xml |   1 -
  .../domaincapsschemadata/qemu_4.0.0.s390x.xml |   1 -
  .../qemu_4.0.0.x86_64.xml |   1 -
  .../qemu_4.1.0.x86_64.xml |   1 -
  tests/domaincapstest.c|   4 +-
  tests/virpcimock.c| 137 +-
  35 files changed, 92 insertions(+), 722 deletions(-)



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 01/12] qemu: Drop KVM assignment

2019-08-20 Thread Daniel Henrique Barboza



On 8/20/19 1:52 PM, Daniel Henrique Barboza wrote:



On 8/20/19 11:30 AM, Michal Privoznik wrote:

KVM style of PCI devices assignment was dropped in kernel in
favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since
vfio is around for quite some time now and is far superior
discourage people in using KVM style.

Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns
out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.

Signed-off-by: Michal Privoznik 
---



Tested-by: Daniel Henrique Barboza 


After taking care of that commit message nit I've pointed out below:


Reviewed-by: Daniel Henrique Barboza 



  src/qemu/qemu_capabilities.c |  6 -
  src/qemu/qemu_command.c  | 26 ++---
  src/qemu/qemu_command.h  |  1 -
  src/qemu/qemu_driver.c   | 14 
  src/qemu/qemu_hostdev.c  | 44 +++-
  src/qemu/qemu_hostdev.h  |  1 -
  src/qemu/qemu_hotplug.c  | 20 ++--
  tests/domaincapstest.c   |  3 +--
  8 files changed, 12 insertions(+), 103 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c9677315ab..73300128ea 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5338,7 +5338,6 @@ static int
  virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsDeviceHostdevPtr hostdev)
  {
-    bool supportsPassthroughKVM = 
qemuHostdevHostSupportsPassthroughLegacy();
  bool supportsPassthroughVFIO = 
qemuHostdevHostSupportsPassthroughVFIO();

    hostdev->supported = VIR_TRISTATE_BOOL_YES;
@@ -5374,11 +5373,6 @@ 
virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,

VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
  }
  -    if (supportsPassthroughKVM) {
-    VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
-    }
  return 0;
  }
  diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e3f4ef624b..f7b5430db8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4904,7 +4904,6 @@ char *
  qemuBuildPCIHostdevDevStr(const virDomainDef *def,
    virDomainHostdevDefPtr dev,
    unsigned int bootIndex, /* used iff 
dev->info->bootIndex == 0 */

-  const char *configfd,
    virQEMUCapsPtr qemuCaps)
  {
  virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4913,16 +4912,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef 
*def,

    /* caller has to assign proper passthrough backend type */
  switch ((virDomainHostdevSubsysPCIBackendType)backend) {
-    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
-    virBufferAddLit(, "pci-assign");
-    if (configfd && *configfd)
-    virBufferAsprintf(, ",configfd=%s", configfd);
-    break;
-
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
  virBufferAddLit(, "vfio-pci");
  break;
  +    case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
@@ -5676,7 +5670,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
  }
  }
  -    char *configfd_name = NULL;
  unsigned int bootIndex = hostdev->info->bootIndex;
    /* bootNet will be non-0 if boot order was set and no 
other

@@ -5686,27 +5679,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
  bootIndex = *bootHostdevNet;
  *bootHostdevNet = 0;
  }
-    if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
-    int configfd = qemuOpenPCIConfig(hostdev);
-
-    if (configfd >= 0) {
-    if (virAsprintf(_name, "%d", configfd) 
< 0) {

-    VIR_FORCE_CLOSE(configfd);
-    return -1;
-    }
-
-    virCommandPassFD(cmd, configfd,
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
-    }
-    }
    if (qemuCommandAddExtDevice(cmd, hostdev->info) < 0)
  return -1;
    virCommandAddArg(cmd, "-device");
-    devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex,
-   configfd_name, 
qemuCaps);

-    VIR_FREE(configfd_name);
+    devstr = qemuBuildPCIHostdevDevStr(def, hostdev, 
bootIndex, qemuCaps);

  if (!devstr)
  return -1;
  virCommandAddArg(cmd, devstr);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 7e2dc5a60a..e3983bedb2 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -148,7 +148,6 @@ char 
*qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,

  char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
  

Re: [libvirt] [PATCH 12/12] news: Document KVM assignment removal

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  docs/news.xml | 13 +
  1 file changed, 13 insertions(+)

diff --git a/docs/news.xml b/docs/news.xml
index d63fca3b48..6137ebd943 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -51,6 +51,19 @@
  

  
+
+  
+
+  Remove KVM assignment support
+
+
+  The KVM style of PCI device assignment was removed from
+  kernel in kernel 4.12.0 after being deprecated since 4.2.0.
+  Libvirt defaults to VFIO for a long time. Remove support for
+  KVM device assignment then.
+
+  
+
  
  
  


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 09/12] virpcimock: Don't create "pci-stub" driver

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

Now that nothing supports "pci-stub" driver (aka KVM style of PCI
device assignment) there is no need for virpcimock to create it.

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 


  tests/virpcimock.c | 1 -
  1 file changed, 1 deletion(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index c0dcd377d5..bbec77975a 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -992,7 +992,6 @@ init_env(void)
  
  MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044);

  MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047);
-MAKE_PCI_DRIVER("pci-stub", -1, -1);
  pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1);
  
  # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 10/12] virpcimock: Don't create new_id or remove_id files

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

Now that PCI attach/detach happens solely via driver_override
these two files are no longer needed.

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 


  tests/virpcimock.c | 112 -
  1 file changed, 112 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index bbec77975a..3157037913 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -68,14 +68,6 @@ char *fakerootdir;
   * created by us. There are some actions that we must take if some special
   * files are written to. Here's the list of files we watch:
   *
- * /sys/bus/pci/drivers//new_id:
- *   Learn the driver new vendor and device combination.
- *   Data in format " ".
- *
- * /sys/bus/pci/drivers//remove_id
- *   Make the driver forget about vendor and device.
- *   Data in format " ".
- *
   * /sys/bus/pci/drivers//bind
   *   Check if driver supports the device and bind driver to it (create symlink
   *   called 'driver' pointing to the /sys/but/pci/drivers/).
@@ -168,8 +160,6 @@ static int pci_driver_unbind(struct pciDriver *driver, 
struct pciDevice *dev);
  static int pci_driver_handle_change(int fd, const char *path);
  static int pci_driver_handle_bind(const char *path);
  static int pci_driver_handle_unbind(const char *path);
-static int pci_driver_handle_new_id(const char *path);
-static int pci_driver_handle_remove_id(const char *path);
  
  
  /*

@@ -640,8 +630,6 @@ pci_driver_new(const char *name, int fail, ...)
  
  make_file(driverpath, "bind", NULL, -1);

  make_file(driverpath, "unbind", NULL, -1);
-make_file(driverpath, "new_id", NULL, -1);
-make_file(driverpath, "remove_id", NULL, -1);
  
  if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver) < 0)

  ABORT_OOM();
@@ -801,10 +789,6 @@ pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const 
char *path)
  ret = pci_driver_handle_bind(path);
  else if (STREQ(file, "unbind"))
  ret = pci_driver_handle_unbind(path);
-else if (STREQ(file, "new_id"))
-ret = pci_driver_handle_new_id(path);
-else if (STREQ(file, "remove_id"))
-ret = pci_driver_handle_remove_id(path);
  else if (STREQ(file, "drivers_probe"))
  ret = pci_driver_handle_drivers_probe(path);
  else if (STREQ(file, "driver_override"))
@@ -849,102 +833,6 @@ pci_driver_handle_unbind(const char *path)
  return ret;
  }
  
-static int

-pci_driver_handle_new_id(const char *path)
-{
-int ret = -1;
-struct pciDriver *driver = pci_driver_find_by_path(path);
-size_t i;
-int vendor, device;
-char buf[32];
-
-if (!driver || PCI_ACTION_NEW_ID & driver->fail) {
-errno = ENODEV;
-goto cleanup;
-}
-
-if (pci_read_file(path, buf, sizeof(buf), true) < 0)
-goto cleanup;
-
-if (sscanf(buf, "%x %x", , ) < 2) {
-errno = EINVAL;
-goto cleanup;
-}
-
-for (i = 0; i < driver->len; i++) {
-if (driver->vendor[i] == vendor &&
-driver->device[i] == device)
-break;
-}
-
-if (i == driver->len) {
-if (VIR_REALLOC_N_QUIET(driver->vendor, driver->len + 1) < 0 ||
-VIR_REALLOC_N_QUIET(driver->device, driver->len + 1) < 0) {
-errno = ENOMEM;
-goto cleanup;
-}
-
-driver->vendor[driver->len] = vendor;
-driver->device[driver->len] = device;
-driver->len++;
-}
-
-for (i = 0; i < nPCIDevices; i++) {
-struct pciDevice *dev = pciDevices[i];
-
-if (!dev->driver &&
-dev->vendor == vendor &&
-dev->device == device &&
-pci_driver_bind(driver, dev) < 0)
-goto cleanup;
-}
-
-ret = 0;
- cleanup:
-return ret;
-}
-
-static int
-pci_driver_handle_remove_id(const char *path)
-{
-int ret = -1;
-struct pciDriver *driver = pci_driver_find_by_path(path);
-size_t i;
-int vendor, device;
-char buf[32];
-
-if (!driver || PCI_ACTION_REMOVE_ID & driver->fail) {
-errno = ENODEV;
-goto cleanup;
-}
-
-if (pci_read_file(path, buf, sizeof(buf), true) < 0)
-goto cleanup;
-
-if (sscanf(buf, "%x %x", , ) < 2) {
-errno = EINVAL;
-goto cleanup;
-}
-
-for (i = 0; i < driver->len; i++) {
-if (driver->vendor[i] == vendor &&
-driver->device[i] == device)
-continue;
-}
-
-if (i != driver->len) {
-if (VIR_DELETE_ELEMENT(driver->vendor, i, driver->len) < 0)
-goto cleanup;
-driver->len++;
-if (VIR_DELETE_ELEMENT(driver->device, i, driver->len) < 0)
-goto cleanup;
-}
-
-ret = 0;
- cleanup:
-return ret;
-}
-
  
  /*

   * Functions to load the symbols and init the environment


--
libvir-list mailing list
libvir-list@redhat.com

Re: [libvirt] [PATCH 11/12] virpcimock: Drop @driverActions enum

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

This enum was introduced to model how RHEL-7 kernel behaves - for
some reason going with the old way (via new_id + bind) fails but
using driver_override succeeds. Well, we don't need to care about
that anymore since we don't create new_id file.

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  tests/virpcimock.c | 24 +++-
  1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 3157037913..a5045ed97c 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -98,19 +98,11 @@ char *fakerootdir;
   *
   */
  
-enum driverActions {

-PCI_ACTION_BIND = 1 << 0,
-PCI_ACTION_UNBIND   = 1 << 1,
-PCI_ACTION_NEW_ID   = 1 << 2,
-PCI_ACTION_REMOVE_ID= 1 << 3,
-};
-
  struct pciDriver {
  char *name;
  int *vendor;/* List of vendor:device IDs the driver can handle */
  int *device;
  size_t len;/* @len is used for both @vendor and @device */
-unsigned int fail;  /* Bitwise-OR of driverActions that should fail */
  };
  
  struct pciDeviceAddress {

@@ -151,7 +143,7 @@ static void pci_device_new_from_stub(const struct pciDevice 
*data);
  static struct pciDevice *pci_device_find_by_id(struct pciDeviceAddress const 
*addr);
  static struct pciDevice *pci_device_find_by_content(const char *path);
  
-static void pci_driver_new(const char *name, int fail, ...);

+static void pci_driver_new(const char *name, ...);
  static struct pciDriver *pci_driver_find_by_dev(struct pciDevice *dev);
  static struct pciDriver *pci_driver_find_by_path(const char *path);
  static struct pciDriver *pci_driver_find_by_driver_override(struct pciDevice 
*dev);
@@ -594,7 +586,7 @@ pci_driver_get_path(const struct pciDriver *driver,
  
  
  static void

-pci_driver_new(const char *name, int fail, ...)
+pci_driver_new(const char *name, ...)
  {
  struct pciDriver *driver;
  va_list args;
@@ -606,12 +598,10 @@ pci_driver_new(const char *name, int fail, ...)
  !(driverpath = pci_driver_get_path(driver, NULL, true)))
  ABORT_OOM();
  
-driver->fail = fail;

-
  if (virFileMakePath(driverpath) < 0)
  ABORT("Unable to create: %s", driverpath);
  
-va_start(args, fail);

+va_start(args, name);
  
  while ((vendor = va_arg(args, int)) != -1) {

  if ((device = va_arg(args, int)) == -1)
@@ -805,7 +795,7 @@ pci_driver_handle_bind(const char *path)
  struct pciDevice *dev = pci_device_find_by_content(path);
  struct pciDriver *driver = pci_driver_find_by_path(path);
  
-if (!driver || !dev || PCI_ACTION_BIND & driver->fail) {

+if (!driver || !dev) {
  /* No driver, no device or failing driver requested */
  errno = ENODEV;
  goto cleanup;
@@ -822,7 +812,7 @@ pci_driver_handle_unbind(const char *path)
  int ret = -1;
  struct pciDevice *dev = pci_device_find_by_content(path);
  
-if (!dev || !dev->driver || PCI_ACTION_UNBIND & dev->driver->fail) {

+if (!dev || !dev->driver) {
  /* No device, device not binded or failing driver requested */
  errno = ENODEV;
  goto cleanup;
@@ -876,11 +866,11 @@ init_env(void)
  make_file(tmp, "drivers_probe", NULL, -1);
  
  # define MAKE_PCI_DRIVER(name, ...) \

-pci_driver_new(name, 0, __VA_ARGS__, -1, -1)
+pci_driver_new(name, __VA_ARGS__, -1, -1)
  
  MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044);

  MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047);
-pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1);
+MAKE_PCI_DRIVER("vfio-pci", -1, -1);
  
  # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \

  do { \


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 06/12] virpci: Drop 'pci-stub' driver

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

Now that no one uses KVM style of PCI assignment we can safely
remove 'pci-stub' backend.

Signed-off-by: Michal Privoznik 
---



Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  src/util/virpci.c | 11 ---
  src/util/virpci.h |  1 -
  2 files changed, 12 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 4c7c26f981..9c9ffa55c2 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -54,7 +54,6 @@ VIR_ENUM_IMPL(virPCIStubDriver,
VIR_PCI_STUB_DRIVER_LAST,
"none",
"pciback", /* XEN */
-  "pci-stub", /* KVM */
"vfio-pci", /* VFIO */
  );
  
@@ -1541,16 +1540,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev,

  return -1;
  }
  
-/* Wait for device cleanup if it is qemu/kvm */

-if (virPCIDeviceGetStubDriver(dev) == VIR_PCI_STUB_DRIVER_KVM) {
-int retries = 100;
-while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device")
-   && retries) {
-usleep(100*1000);
-retries--;
-}
-}
-
  if (virPCIDeviceUnbindFromStub(dev) < 0)
  return -1;
  
diff --git a/src/util/virpci.h b/src/util/virpci.h

index 5074851777..4ac0d230a4 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -59,7 +59,6 @@ struct _virPCIDeviceAddress {
  typedef enum {
  VIR_PCI_STUB_DRIVER_NONE = 0,
  VIR_PCI_STUB_DRIVER_XEN,
-VIR_PCI_STUB_DRIVER_KVM,
  VIR_PCI_STUB_DRIVER_VFIO,
  VIR_PCI_STUB_DRIVER_LAST
  } virPCIStubDriver;


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 08/12] virpci: Drop newid style of PCI device detach

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

As stated in 84f9358b18346 all kernels that we are interested in
have 'drivers_override'. Drop the other, older style of
overriding PCI device driver - newid.

Signed-off-by: Michal Privoznik 
---



Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  src/util/virpci.c | 284 +-
  1 file changed, 2 insertions(+), 282 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index ea5be62033..6724a8ad9e 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -218,16 +218,6 @@ virPCIDriverDir(const char *driver)
  }
  
  
-static char *

-virPCIDriverFile(const char *driver, const char *file)
-{
-char *buffer;
-
-ignore_value(virAsprintf(, PCI_SYSFS "drivers/%s/%s", driver, 
file));
-return buffer;
-}
-
-
  static char *
  virPCIFile(const char *device, const char *file)
  {
@@ -1145,104 +1135,6 @@ virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev,
  return 0;
  }
  
-static int

-virPCIDeviceUnbindFromStubWithNewid(virPCIDevicePtr dev)
-{
-int result = -1;
-VIR_AUTOFREE(char *) drvdir = NULL;
-VIR_AUTOFREE(char *) path = NULL;
-VIR_AUTOFREE(char *) driver = NULL;
-
-/* If the device is currently bound to one of the "well known"
- * stub drivers, then unbind it, otherwise ignore it.
- */
-if (virPCIDeviceGetDriverPathAndName(dev, , ) < 0)
-goto cleanup;
-
-if (!driver) {
-/* The device is not bound to any driver and we are almost done. */
-VIR_DEBUG("PCI device %s is not bound to any driver", dev->name);
-goto reprobe;
-}
-
-if (!dev->unbind_from_stub) {
-VIR_DEBUG("Unbind from stub skipped for PCI device %s", dev->name);
-goto remove_slot;
-}
-
-/* If the device isn't bound to a known stub, skip the unbind. */
-if (virPCIStubDriverTypeFromString(driver) < 0 ||
-virPCIStubDriverTypeFromString(driver) == VIR_PCI_STUB_DRIVER_NONE) {
-VIR_DEBUG("Unbind from stub skipped for PCI device %s because of "
-  "unknown stub driver", dev->name);
-goto remove_slot;
-}
-
-VIR_DEBUG("Unbinding PCI device %s from stub driver %s",
-  dev->name, driver);
-
-if (virPCIDeviceUnbind(dev) < 0)
-goto cleanup;
-dev->unbind_from_stub = false;
-
- remove_slot:
-if (!dev->remove_slot) {
-VIR_DEBUG("Slot removal skipped for PCI device %s", dev->name);
-goto reprobe;
-}
-
-VIR_DEBUG("Removing slot for PCI device %s", dev->name);
-
-/* Xen's pciback.ko wants you to use remove_slot on the specific device */
-if (!(path = virPCIDriverFile(driver, "remove_slot")))
-goto cleanup;
-
-if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
-virReportSystemError(errno,
- _("Failed to remove slot for PCI device '%s' from 
%s"),
- dev->name, driver);
-goto cleanup;
-}
-dev->remove_slot = false;
-
- reprobe:
-if (!dev->reprobe) {
-VIR_DEBUG("Reprobe skipped for PCI device %s", dev->name);
-result = 0;
-goto cleanup;
-}
-
-VIR_DEBUG("Reprobing for PCI device %s", dev->name);
-
-/* Trigger a re-probe of the device is not in the stub's dynamic
- * ID table. If the stub is available, but 'remove_id' isn't
- * available, then re-probing would just cause the device to be
- * re-bound to the stub.
- */
-VIR_FREE(path);
-if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
-goto cleanup;
-
-if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
-if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
-virReportSystemError(errno,
- _("Failed to trigger a re-probe for PCI device 
'%s'"),
- dev->name);
-goto cleanup;
-}
-}
-
-result = 0;
-
- cleanup:
-/* do not do it again */
-dev->unbind_from_stub = false;
-dev->remove_slot = false;
-dev->reprobe = false;
-
-return result;
-}
-
  static int
  virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr dev)
  {
@@ -1257,167 +1149,7 @@ virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr 
dev)
  static int
  virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
  {
-VIR_AUTOFREE(char *) path = NULL;
-
-/*
- * Prefer using the device's driver_override interface, falling back
- * to the unpleasant new_id interface.
- */
-if (!(path = virPCIFile(dev->name, "driver_override")))
-return -1;
-
-if (virFileExists(path))
-return virPCIDeviceUnbindFromStubWithOverride(dev);
-
-return virPCIDeviceUnbindFromStubWithNewid(dev);
-}
-
-static int
-virPCIDeviceBindToStubWithNewid(virPCIDevicePtr dev)
-{
-int result = -1;
-bool reprobe = false;
-VIR_AUTOFREE(char *) 

Re: [libvirt] [PATCH 07/12] virpci: Remove unused virPCIDeviceWaitForCleanup

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

This function is no longer used after previous commit.

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  src/libvirt_private.syms |   1 -
  src/util/virpci.c| 108 ---
  src/util/virpci.h|   1 -
  3 files changed, 110 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9db4ac7933..6c57351866 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2696,7 +2696,6 @@ virPCIDeviceSetStubDriver;
  virPCIDeviceSetUnbindFromStub;
  virPCIDeviceSetUsedBy;
  virPCIDeviceUnbind;
-virPCIDeviceWaitForCleanup;
  virPCIEDeviceInfoFree;
  virPCIELinkSpeedTypeFromString;
  virPCIELinkSpeedTypeToString;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 9c9ffa55c2..ea5be62033 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1552,114 +1552,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev,
  return 0;
  }
  
-/* Certain hypervisors (like qemu/kvm) map the PCI bar(s) on

- * the host when doing device passthrough.  This can lead to a race
- * condition where the hypervisor is still cleaning up the device while
- * libvirt is trying to re-attach it to the host device driver.  To avoid
- * this situation, we look through /proc/iomem, and if the hypervisor is
- * still holding on to the bar (denoted by the string in the matcher
- * variable), then we can wait around a bit for that to clear up.
- *
- * A typical /proc/iomem looks like this (snipped for brevity):
- * 0001-0008efff : System RAM
- * 0008f000-0008 : reserved
- * ...
- * 0010-cc9fcfff : System RAM
- *   0020-00483d3b : Kernel code
- *   00483d3c-005c88df : Kernel data
- * cc9fd000-ccc71fff : ACPI Non-volatile Storage
- * ...
- * d020-d02f : PCI Bus #05
- *   d020-d021 : :05:00.0
- * d020-d021 : e1000e
- *   d022-d023 : :05:00.0
- * d022-d023 : e1000e
- * ...
- * f000-f0003fff : :00:1b.0
- *   f000-f0003fff : kvm_assigned_device
- *
- * Returns 0 if we are clear to continue, and 1 if the hypervisor is still
- * holding on to the resource.
- */
-int
-virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher)
-{
-FILE *fp;
-char line[160];
-char *tmp;
-unsigned long long start, end;
-unsigned int domain, bus, slot, function;
-bool in_matching_device;
-int ret;
-size_t match_depth;
-
-fp = fopen("/proc/iomem", "r");
-if (!fp) {
-/* If we failed to open iomem, we just basically ignore the error.  The
- * unbind might succeed anyway, and besides, it's very likely we have
- * no way to report the error
- */
-VIR_DEBUG("Failed to open /proc/iomem, trying to continue anyway");
-return 0;
-}
-
-ret = 0;
-in_matching_device = false;
-match_depth = 0;
-while (fgets(line, sizeof(line), fp) != 0) {
-/* the logic here is a bit confusing.  For each line, we look to
- * see if it matches the domain:bus:slot.function we were given.
- * If this line matches the DBSF, then any subsequent lines indented
- * by 2 spaces are the PCI regions for this device.  It's also
- * possible that none of the PCI regions are currently mapped, in
- * which case we have no indented regions.  This code handles all
- * of these situations
- */
-if (in_matching_device && (strspn(line, " ") == (match_depth + 2))) {
-/* expected format: - :  */
-if (/* start */
-virStrToLong_ull(line, , 16, ) < 0 || *tmp != '-' ||
-/* end */
-virStrToLong_ull(tmp + 1, , 16, ) < 0 ||
-(tmp = STRSKIP(tmp, " : ")) == NULL)
-continue;
-
-if (STRPREFIX(tmp, matcher)) {
-ret = 1;
-break;
-}
-} else {
-in_matching_device = false;
-
-/* expected format: - : 
::. */
-if (/* start */
-virStrToLong_ull(line, , 16, ) < 0 || *tmp != '-' ||
-/* end */
-virStrToLong_ull(tmp + 1, , 16, ) < 0 ||
-(tmp = STRSKIP(tmp, " : ")) == NULL ||
-/* domain */
-virStrToLong_ui(tmp, , 16, ) < 0 || *tmp != ':' ||
-/* bus */
-virStrToLong_ui(tmp + 1, , 16, ) < 0 || *tmp != ':' ||
-/* slot */
-virStrToLong_ui(tmp + 1, , 16, ) < 0 || *tmp != '.' ||
-/* function */
-virStrToLong_ui(tmp + 1, , 16, ) < 0 || *tmp != 
'\n')
-continue;
-
-if (domain != dev->address.domain || bus != dev->address.bus ||
-slot != dev->address.slot || function != dev->address.function)
-continue;
-in_matching_device = true;

Re: [libvirt] [PATCH 05/12] virhostdev: Disable legacy kvm assignment

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

The KVM assignment is going to be removed shortly. Don't let the
hostdev module configure it.

Signed-off-by: Michal Privoznik 
---



Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  src/util/virhostdev.c | 12 
  1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index e3f48a9a2e..29e75ffc84 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -246,12 +246,16 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef 
*hostdev,
  
  virPCIDeviceSetManaged(actual, hostdev->managed);
  
-if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)

+if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
  virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO);
-else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN)
+} else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) {
  virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN);
-else
-virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM);
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("pci backend driver '%s' is not supported"),
+   
virDomainHostdevSubsysPCIBackendTypeToString(pcisrc->backend));
+return -1;
+}
  
  VIR_STEAL_PTR(*pci, actual);

  return 0;


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 03/12] virhostdev: Unify virDomainHostdevDef to virPCIDevice translation

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

There are two places where we need to create virPCIDevice from
given virDomainHostdevDef. In both places the code is duplicated.
Move them into a single function and call it from those two
places.

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 


  src/util/virhostdev.c | 93 +--
  1 file changed, 54 insertions(+), 39 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 6861b8a84e..e3f48a9a2e 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -212,6 +212,51 @@ virHostdevManagerGetDefault(void)
  return virObjectRef(manager);
  }
  
+/**

+ * virHostdevGetPCIHostDevice:
+ * @hostdev: domain hostdev definition
+ * @pci: returned PCI device
+ *
+ * For given @hostdev which represents a PCI device construct its
+ * virPCIDevice representation and returned it in @pci. If
+ * @hostdev does not represent a PCI device then @pci is set to
+ * NULL and 0 is returned.
+ *
+ * Returns: 0 on success (@pci might be NULL though),
+ * -1 otherwise (with error reported).
+ */
+static int
+virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
+   virPCIDevicePtr *pci)
+{
+VIR_AUTOPTR(virPCIDevice) actual = NULL;
+const virDomainHostdevSubsysPCI *pcisrc = >source.subsys.u.pci;
+
+*pci = NULL;
+
+if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+return 0;
+
+actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
+ pcisrc->addr.slot, pcisrc->addr.function);
+
+if (!actual)
+return -1;
+
+virPCIDeviceSetManaged(actual, hostdev->managed);
+
+if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
+virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO);
+else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN)
+virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN);
+else
+virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM);
+
+VIR_STEAL_PTR(*pci, actual);
+return 0;
+}
+
  static virPCIDeviceListPtr
  virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int 
nhostdevs)
  {
@@ -223,27 +268,13 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr 
*hostdevs, int nhostdevs)
  
  for (i = 0; i < nhostdevs; i++) {

  virDomainHostdevDefPtr hostdev = hostdevs[i];
-virDomainHostdevSubsysPCIPtr pcisrc = >source.subsys.u.pci;
  VIR_AUTOPTR(virPCIDevice) pci = NULL;
  
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)

-continue;
-if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
-continue;
+if (virHostdevGetPCIHostDevice(hostdev, ) < 0)
+return NULL;
  
-pci = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,

-  pcisrc->addr.slot, pcisrc->addr.function);
  if (!pci)
-return NULL;
-
-virPCIDeviceSetManaged(pci, hostdev->managed);
-
-if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
-virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO);
-else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN)
-virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
-else
-virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM);
+continue;
  
  if (virPCIDeviceListAdd(pcidevs, pci) < 0)

  return NULL;
@@ -253,7 +284,6 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr 
*hostdevs, int nhostdevs)
  VIR_RETURN_PTR(pcidevs);
  }
  
-

  static int
  virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev,
 char **sysfs_path)
@@ -1067,7 +1097,6 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
   const char *drv_name,
   const char *dom_name)
  {
-virDomainHostdevDefPtr hostdev = NULL;
  size_t i;
  int ret = -1;
  
@@ -1078,32 +1107,18 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,

  virObjectLock(mgr->inactivePCIHostdevs);
  
  for (i = 0; i < nhostdevs; i++) {

+const virDomainHostdevDef *hostdev = hostdevs[i];
  VIR_AUTOPTR(virPCIDevice) actual = NULL;
-virDomainHostdevSubsysPCIPtr pcisrc;
-hostdev = hostdevs[i];
-pcisrc = >source.subsys.u.pci;
  
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)

-continue;
-if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
-continue;
-
-actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
- pcisrc->addr.slot, pcisrc->addr.function);
+if 

Re: [libvirt] [PATCH 04/12] qemu: Drop unused qemuOpenPCIConfig()

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

After previous commits, the function is not used anymore.
Remove it.

Signed-off-by: Michal Privoznik 
---


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



  src/qemu/qemu_command.c | 22 --
  src/qemu/qemu_command.h |  2 --
  2 files changed, 24 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f7b5430db8..500035 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4878,28 +4878,6 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
  }
  
  
-int

-qemuOpenPCIConfig(virDomainHostdevDefPtr dev)
-{
-virDomainHostdevSubsysPCIPtr pcisrc = >source.subsys.u.pci;
-char *path = NULL;
-int configfd = -1;
-
-if (virAsprintf(, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/config",
-pcisrc->addr.domain, pcisrc->addr.bus,
-pcisrc->addr.slot, pcisrc->addr.function) < 0)
-return -1;
-
-configfd = open(path, O_RDWR, 0);
-
-if (configfd < 0)
-virReportSystemError(errno, _("Failed opening %s"), path);
-
-VIR_FREE(path);
-
-return configfd;
-}
-
  char *
  qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev,
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index e3983bedb2..6f97e7bc0c 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -157,8 +157,6 @@ int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
   virQEMUCapsPtr qemuCaps,
   virJSONValuePtr *props);
  
-int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);

-
  /* Current, best practice */
  char *qemuBuildUSBHostdevDevStr(const virDomainDef *def,
  virDomainHostdevDefPtr dev,


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 02/12] tests: Remove 'kvm' PCI backend from domaincapstest

2019-08-20 Thread Daniel Henrique Barboza




On 8/20/19 11:30 AM, Michal Privoznik wrote:

The KVM assignment was removed in qemu driver in previous commit.
Remove it from domaincapstest too which is hard coding it.

Signed-off-by: Michal Privoznik 
---
  tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml | 1 -
  tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.12.0.s390x.xml| 1 -
  tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml   | 1 -
  tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml  | 1 -
  tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml   | 1 -
  tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 -
  tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 -
  tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 -
  tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 -
  tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 -
  tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml| 1 -
  tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml| 1 -
  tests/domaincapstest.c  | 1 -
  22 files changed, 22 deletions(-)


Reviewed-by: Daniel Henrique Barboza 
Tested-by: Daniel Henrique Barboza 



diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml 
b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
index f14f245007..a2df336833 100644
--- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
@@ -112,7 +112,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml 
b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml
index cc65977f03..ed1af3224b 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml
@@ -116,7 +116,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml 
b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
index 8c490fa4d1..99de2b0a8e 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
@@ -80,7 +80,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml 
b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml
index 18171f0db4..8d039f3514 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml
@@ -172,7 +172,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml 
b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml
index 146041a6c1..109162ffd8 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml
@@ -145,7 +145,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml
index 778e27582f..13441b9923 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml
@@ -113,7 +113,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
index a01f5ef72f..974739c38e 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
@@ -111,7 +111,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
index a74cece8b6..9f628a3652 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
@@ -84,7 +84,6 @@


  default
-kvm
  vfio

  
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
index 949c5f8723..bb1f784328 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
@@ -119,7 +119,6 @@


  default
-kvm
  

Re: [libvirt] [PATCH] virt-aa-helper: Actually fix AppArmor profile

2019-08-20 Thread Jamie Strandboge
On Tue, 20 Aug 2019, Andrea Bolognani wrote:

> --- a/src/security/apparmor/usr.lib.libvirt.virt-aa-helper
> +++ b/src/security/apparmor/usr.lib.libvirt.virt-aa-helper
> @@ -18,8 +18,8 @@ profile virt-aa-helper 
> /usr/{lib,lib64}/libvirt/virt-aa-helper {
>@{PROC}/filesystems r,
>  
># Used when internally running another command (namely apparmor_parser)
> -  @{PROC}/self/fd r,
> -  @{PROC}/@{pid}/fd r,
> +  @{PROC}/self/fd/ r,

/proc/self is a 'magic symlink' and apparmor will resolve symlinks
before performing checks. As such, @{PROC}/self/fd/ is redundant with
the next rule.

> +  @{PROC}/@{pid}/fd/ r,

This access LGTM. +1 to apply.

-- 
Jamie Strandboge | http://www.canonical.com


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 01/12] qemu: Drop KVM assignment

2019-08-20 Thread Daniel Henrique Barboza



On 8/20/19 11:30 AM, Michal Privoznik wrote:

KVM style of PCI devices assignment was dropped in kernel in
favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since
vfio is around for quite some time now and is far superior
discourage people in using KVM style.

Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns
out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.

Signed-off-by: Michal Privoznik 
---
  src/qemu/qemu_capabilities.c |  6 -
  src/qemu/qemu_command.c  | 26 ++---
  src/qemu/qemu_command.h  |  1 -
  src/qemu/qemu_driver.c   | 14 
  src/qemu/qemu_hostdev.c  | 44 +++-
  src/qemu/qemu_hostdev.h  |  1 -
  src/qemu/qemu_hotplug.c  | 20 ++--
  tests/domaincapstest.c   |  3 +--
  8 files changed, 12 insertions(+), 103 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c9677315ab..73300128ea 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5338,7 +5338,6 @@ static int
  virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
 virDomainCapsDeviceHostdevPtr hostdev)
  {
-bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
  bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
  
  hostdev->supported = VIR_TRISTATE_BOOL_YES;

@@ -5374,11 +5373,6 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr 
qemuCaps,
   VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
  }
  
-if (supportsPassthroughKVM) {

-VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
-}
  return 0;
  }
  
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c

index e3f4ef624b..f7b5430db8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4904,7 +4904,6 @@ char *
  qemuBuildPCIHostdevDevStr(const virDomainDef *def,
virDomainHostdevDefPtr dev,
unsigned int bootIndex, /* used iff 
dev->info->bootIndex == 0 */
-  const char *configfd,
virQEMUCapsPtr qemuCaps)
  {
  virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4913,16 +4912,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
  
  /* caller has to assign proper passthrough backend type */

  switch ((virDomainHostdevSubsysPCIBackendType)backend) {
-case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
-virBufferAddLit(, "pci-assign");
-if (configfd && *configfd)
-virBufferAsprintf(, ",configfd=%s", configfd);
-break;
-
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
  virBufferAddLit(, "vfio-pci");
  break;
  
+case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:

  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
  case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
@@ -5676,7 +5670,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
  }
  }
  
-char *configfd_name = NULL;

  unsigned int bootIndex = hostdev->info->bootIndex;
  
  /* bootNet will be non-0 if boot order was set and no other

@@ -5686,27 +5679,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
  bootIndex = *bootHostdevNet;
  *bootHostdevNet = 0;
  }
-if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
-int configfd = qemuOpenPCIConfig(hostdev);
-
-if (configfd >= 0) {
-if (virAsprintf(_name, "%d", configfd) < 0) {
-VIR_FORCE_CLOSE(configfd);
-return -1;
-}
-
-virCommandPassFD(cmd, configfd,
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
-}
-}
  
  if (qemuCommandAddExtDevice(cmd, hostdev->info) < 0)

  return -1;
  
  virCommandAddArg(cmd, "-device");

-devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex,
-   configfd_name, qemuCaps);
-VIR_FREE(configfd_name);
+devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex, 
qemuCaps);
  if (!devstr)
  return -1;
  virCommandAddArg(cmd, devstr);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 7e2dc5a60a..e3983bedb2 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -148,7 +148,6 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
  char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
  

Re: [libvirt] [PATCH 0/2] cgroups v2 fixes

2019-08-20 Thread Pavel Hrdina
On Tue, Aug 20, 2019 at 05:04:59PM +0200, Jiri Denemark wrote:
> On Tue, Aug 20, 2019 at 14:51:21 +0200, Pavel Hrdina wrote:
> > *** BLURB HERE ***
> 
> You too?

Just a mistake :).

> 
> > Pavel Hrdina (2):
> >   vircgroupv2: fix parsing multiple values in single file
> >   vircgroupv2: fix virCgroupV2GetCpuCfsQuota for "max" value
> > 
> >  src/util/vircgroupv2.c | 20 +++-
> >  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> Reviewed-by: Jiri Denemark 

Thanks


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/2] cgroups v2 fixes

2019-08-20 Thread Jiri Denemark
On Tue, Aug 20, 2019 at 14:51:21 +0200, Pavel Hrdina wrote:
> *** BLURB HERE ***

You too?

> Pavel Hrdina (2):
>   vircgroupv2: fix parsing multiple values in single file
>   vircgroupv2: fix virCgroupV2GetCpuCfsQuota for "max" value
> 
>  src/util/vircgroupv2.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)

Reviewed-by: Jiri Denemark 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v1 07/11] virStoragePoolObjListAdd: Separate out definition assignment

2019-08-20 Thread Michal Privoznik

On 8/19/19 6:08 PM, John Ferlan wrote:


Was it intentional to swap the order?



That's a good question. Honestly, I don't recall. I'll fix it in my 
local branch. It looks like we should set the new pool definition with 
the pool list locked so that virStoragePoolObjIsDuplicate() and
virStoragePoolObjSourceFindDuplicate() can return expected value if two 
threads were fighting.


Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 8/8] qemu_driver: hook up query-cpu-model-comparison

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:29 -0400, Collin Walling wrote:
> This command is hooked into the virsh hypervisor-cpu-compare command.
> As such, the CPU model XML provided to the command will be compared
> to the hypervisor CPU contained in the QEMU capabilities file for the
> appropriate QEMU binary (for s390x, this CPU definition can be observed
> via virsh domcapabilities).
> 
> s390x can report that the first model (A) is a subset of the second
> (B). If A is the hypervisor CPU and a subset of B (the CPU contained
> in the XML), then B would not be able to run on this machine and thus
> we will report that CPU model B is incompatible.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_capabilities.c | 48 
> 
>  src/qemu/qemu_capabilities.h |  9 +
>  src/qemu/qemu_driver.c   | 11 ++
>  3 files changed, 68 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index a99ebcb..20cb82b 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -5660,3 +5660,51 @@ virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
>  virCPUDefFree(cpu);
>  return baseline;
>  }
> +
> +virCPUCompareResult
> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
> +  const char *libDir,
> +  uid_t runUid,
> +  gid_t runGid,
> +  virCPUDefPtr cpu_a,
> +  virCPUDefPtr cpu_b,
> +  bool failIncompatible)

This function should go into qemu_driver.c and its name should change
accordingly.

> +{
> +qemuProcessQMPPtr proc = NULL;
> +qemuMonitorCPUModelInfoPtr result = NULL;
> +int ret = -1;
> +
> +if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
> +   runUid, runGid, false)))
> +goto cleanup;
> +
> +if (qemuProcessQMPStart(proc) < 0)
> +goto cleanup;
> +
> +if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model,
> + cpu_a->nfeatures, cpu_a->features,
> + cpu_b->model, cpu_b->nfeatures,
> + cpu_b->features, ) < 0)
> +goto cleanup;
> +
> +if (STREQ(result->name, "incompatible") ||
> +STREQ(result->name, "subset"))
> +ret = VIR_CPU_COMPARE_INCOMPATIBLE;
> +else if (STREQ(result->name, "identical"))
> +ret = VIR_CPU_COMPARE_IDENTICAL;
> +else if (STREQ(result->name, "superset"))
> +ret = VIR_CPU_COMPARE_SUPERSET;
> +
> +if (failIncompatible && ret == VIR_CPU_COMPARE_INCOMPATIBLE) {
> +ret = VIR_CPU_COMPARE_ERROR;
> +virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL);
> +}
> +
> + cleanup:
> +if (ret < 0)
> +virQEMUCapsLogProbeFailure(qemuCaps->binary);

Again, no logging here, please. The reported error is already going to
be logged anyway. And mainly since this is called from inside an API
invoked by a client, the client will get the error. Probing is different
as there's no API involved, QEMU binaries are probed when libvirtd
starts.

> +
> +qemuMonitorCPUModelInfoFree(result);
> +qemuProcessQMPFree(proc);
> +return ret;
> +}
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 8afa05c..a62499f 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -673,3 +673,12 @@ virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr 
> qemuCaps,
>  gid_t runGid,
>  int ncpus,
>  virCPUDefPtr *cpus);
> +
> +virCPUCompareResult
> +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps,
> +  const char *libDir,
> +  uid_t runUid,
> +  gid_t runGid,
> +  virCPUDefPtr cpu_a,
> +  virCPUDefPtr cpu_b,
> +  bool failIncompatible);
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 37b9c75..3e49c04 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -13446,9 +13446,11 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>  {
>  int ret = VIR_CPU_COMPARE_ERROR;
>  virQEMUDriverPtr driver = conn->privateData;
> +virQEMUDriverConfigPtr config = driver->config;

VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);

>  virQEMUCapsPtr qemuCaps = NULL;
>  bool failIncompatible;
>  virCPUDefPtr hvCPU;
> +virCPUDefPtr cpu;
>  virArch arch;
>  virDomainVirtType virttype;
>  
> @@ -13483,6 +13485,14 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn,
>  
>  if 

[libvirt] [PATCH 12/12] news: Document KVM assignment removal

2019-08-20 Thread Michal Privoznik
Signed-off-by: Michal Privoznik 
---
 docs/news.xml | 13 +
 1 file changed, 13 insertions(+)

diff --git a/docs/news.xml b/docs/news.xml
index d63fca3b48..6137ebd943 100644
--- a/docs/news.xml
+++ b/docs/news.xml
@@ -51,6 +51,19 @@
 
   
 
+
+  
+
+  Remove KVM assignment support
+
+
+  The KVM style of PCI device assignment was removed from
+  kernel in kernel 4.12.0 after being deprecated since 4.2.0.
+  Libvirt defaults to VFIO for a long time. Remove support for
+  KVM device assignment then.
+
+  
+
 
 
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 06/12] virpci: Drop 'pci-stub' driver

2019-08-20 Thread Michal Privoznik
Now that no one uses KVM style of PCI assignment we can safely
remove 'pci-stub' backend.

Signed-off-by: Michal Privoznik 
---
 src/util/virpci.c | 11 ---
 src/util/virpci.h |  1 -
 2 files changed, 12 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index 4c7c26f981..9c9ffa55c2 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -54,7 +54,6 @@ VIR_ENUM_IMPL(virPCIStubDriver,
   VIR_PCI_STUB_DRIVER_LAST,
   "none",
   "pciback", /* XEN */
-  "pci-stub", /* KVM */
   "vfio-pci", /* VFIO */
 );
 
@@ -1541,16 +1540,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev,
 return -1;
 }
 
-/* Wait for device cleanup if it is qemu/kvm */
-if (virPCIDeviceGetStubDriver(dev) == VIR_PCI_STUB_DRIVER_KVM) {
-int retries = 100;
-while (virPCIDeviceWaitForCleanup(dev, "kvm_assigned_device")
-   && retries) {
-usleep(100*1000);
-retries--;
-}
-}
-
 if (virPCIDeviceUnbindFromStub(dev) < 0)
 return -1;
 
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 5074851777..4ac0d230a4 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -59,7 +59,6 @@ struct _virPCIDeviceAddress {
 typedef enum {
 VIR_PCI_STUB_DRIVER_NONE = 0,
 VIR_PCI_STUB_DRIVER_XEN,
-VIR_PCI_STUB_DRIVER_KVM,
 VIR_PCI_STUB_DRIVER_VFIO,
 VIR_PCI_STUB_DRIVER_LAST
 } virPCIStubDriver;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 10/12] virpcimock: Don't create new_id or remove_id files

2019-08-20 Thread Michal Privoznik
Now that PCI attach/detach happens solely via driver_override
these two files are no longer needed.

Signed-off-by: Michal Privoznik 
---
 tests/virpcimock.c | 112 -
 1 file changed, 112 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index bbec77975a..3157037913 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -68,14 +68,6 @@ char *fakerootdir;
  * created by us. There are some actions that we must take if some special
  * files are written to. Here's the list of files we watch:
  *
- * /sys/bus/pci/drivers//new_id:
- *   Learn the driver new vendor and device combination.
- *   Data in format " ".
- *
- * /sys/bus/pci/drivers//remove_id
- *   Make the driver forget about vendor and device.
- *   Data in format " ".
- *
  * /sys/bus/pci/drivers//bind
  *   Check if driver supports the device and bind driver to it (create symlink
  *   called 'driver' pointing to the /sys/but/pci/drivers/).
@@ -168,8 +160,6 @@ static int pci_driver_unbind(struct pciDriver *driver, 
struct pciDevice *dev);
 static int pci_driver_handle_change(int fd, const char *path);
 static int pci_driver_handle_bind(const char *path);
 static int pci_driver_handle_unbind(const char *path);
-static int pci_driver_handle_new_id(const char *path);
-static int pci_driver_handle_remove_id(const char *path);
 
 
 /*
@@ -640,8 +630,6 @@ pci_driver_new(const char *name, int fail, ...)
 
 make_file(driverpath, "bind", NULL, -1);
 make_file(driverpath, "unbind", NULL, -1);
-make_file(driverpath, "new_id", NULL, -1);
-make_file(driverpath, "remove_id", NULL, -1);
 
 if (VIR_APPEND_ELEMENT_QUIET(pciDrivers, nPCIDrivers, driver) < 0)
 ABORT_OOM();
@@ -801,10 +789,6 @@ pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const 
char *path)
 ret = pci_driver_handle_bind(path);
 else if (STREQ(file, "unbind"))
 ret = pci_driver_handle_unbind(path);
-else if (STREQ(file, "new_id"))
-ret = pci_driver_handle_new_id(path);
-else if (STREQ(file, "remove_id"))
-ret = pci_driver_handle_remove_id(path);
 else if (STREQ(file, "drivers_probe"))
 ret = pci_driver_handle_drivers_probe(path);
 else if (STREQ(file, "driver_override"))
@@ -849,102 +833,6 @@ pci_driver_handle_unbind(const char *path)
 return ret;
 }
 
-static int
-pci_driver_handle_new_id(const char *path)
-{
-int ret = -1;
-struct pciDriver *driver = pci_driver_find_by_path(path);
-size_t i;
-int vendor, device;
-char buf[32];
-
-if (!driver || PCI_ACTION_NEW_ID & driver->fail) {
-errno = ENODEV;
-goto cleanup;
-}
-
-if (pci_read_file(path, buf, sizeof(buf), true) < 0)
-goto cleanup;
-
-if (sscanf(buf, "%x %x", , ) < 2) {
-errno = EINVAL;
-goto cleanup;
-}
-
-for (i = 0; i < driver->len; i++) {
-if (driver->vendor[i] == vendor &&
-driver->device[i] == device)
-break;
-}
-
-if (i == driver->len) {
-if (VIR_REALLOC_N_QUIET(driver->vendor, driver->len + 1) < 0 ||
-VIR_REALLOC_N_QUIET(driver->device, driver->len + 1) < 0) {
-errno = ENOMEM;
-goto cleanup;
-}
-
-driver->vendor[driver->len] = vendor;
-driver->device[driver->len] = device;
-driver->len++;
-}
-
-for (i = 0; i < nPCIDevices; i++) {
-struct pciDevice *dev = pciDevices[i];
-
-if (!dev->driver &&
-dev->vendor == vendor &&
-dev->device == device &&
-pci_driver_bind(driver, dev) < 0)
-goto cleanup;
-}
-
-ret = 0;
- cleanup:
-return ret;
-}
-
-static int
-pci_driver_handle_remove_id(const char *path)
-{
-int ret = -1;
-struct pciDriver *driver = pci_driver_find_by_path(path);
-size_t i;
-int vendor, device;
-char buf[32];
-
-if (!driver || PCI_ACTION_REMOVE_ID & driver->fail) {
-errno = ENODEV;
-goto cleanup;
-}
-
-if (pci_read_file(path, buf, sizeof(buf), true) < 0)
-goto cleanup;
-
-if (sscanf(buf, "%x %x", , ) < 2) {
-errno = EINVAL;
-goto cleanup;
-}
-
-for (i = 0; i < driver->len; i++) {
-if (driver->vendor[i] == vendor &&
-driver->device[i] == device)
-continue;
-}
-
-if (i != driver->len) {
-if (VIR_DELETE_ELEMENT(driver->vendor, i, driver->len) < 0)
-goto cleanup;
-driver->len++;
-if (VIR_DELETE_ELEMENT(driver->device, i, driver->len) < 0)
-goto cleanup;
-}
-
-ret = 0;
- cleanup:
-return ret;
-}
-
 
 /*
  * Functions to load the symbols and init the environment
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 08/12] virpci: Drop newid style of PCI device detach

2019-08-20 Thread Michal Privoznik
As stated in 84f9358b18346 all kernels that we are interested in
have 'drivers_override'. Drop the other, older style of
overriding PCI device driver - newid.

Signed-off-by: Michal Privoznik 
---
 src/util/virpci.c | 284 +-
 1 file changed, 2 insertions(+), 282 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index ea5be62033..6724a8ad9e 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -218,16 +218,6 @@ virPCIDriverDir(const char *driver)
 }
 
 
-static char *
-virPCIDriverFile(const char *driver, const char *file)
-{
-char *buffer;
-
-ignore_value(virAsprintf(, PCI_SYSFS "drivers/%s/%s", driver, 
file));
-return buffer;
-}
-
-
 static char *
 virPCIFile(const char *device, const char *file)
 {
@@ -1145,104 +1135,6 @@ virPCIDeviceBindWithDriverOverride(virPCIDevicePtr dev,
 return 0;
 }
 
-static int
-virPCIDeviceUnbindFromStubWithNewid(virPCIDevicePtr dev)
-{
-int result = -1;
-VIR_AUTOFREE(char *) drvdir = NULL;
-VIR_AUTOFREE(char *) path = NULL;
-VIR_AUTOFREE(char *) driver = NULL;
-
-/* If the device is currently bound to one of the "well known"
- * stub drivers, then unbind it, otherwise ignore it.
- */
-if (virPCIDeviceGetDriverPathAndName(dev, , ) < 0)
-goto cleanup;
-
-if (!driver) {
-/* The device is not bound to any driver and we are almost done. */
-VIR_DEBUG("PCI device %s is not bound to any driver", dev->name);
-goto reprobe;
-}
-
-if (!dev->unbind_from_stub) {
-VIR_DEBUG("Unbind from stub skipped for PCI device %s", dev->name);
-goto remove_slot;
-}
-
-/* If the device isn't bound to a known stub, skip the unbind. */
-if (virPCIStubDriverTypeFromString(driver) < 0 ||
-virPCIStubDriverTypeFromString(driver) == VIR_PCI_STUB_DRIVER_NONE) {
-VIR_DEBUG("Unbind from stub skipped for PCI device %s because of "
-  "unknown stub driver", dev->name);
-goto remove_slot;
-}
-
-VIR_DEBUG("Unbinding PCI device %s from stub driver %s",
-  dev->name, driver);
-
-if (virPCIDeviceUnbind(dev) < 0)
-goto cleanup;
-dev->unbind_from_stub = false;
-
- remove_slot:
-if (!dev->remove_slot) {
-VIR_DEBUG("Slot removal skipped for PCI device %s", dev->name);
-goto reprobe;
-}
-
-VIR_DEBUG("Removing slot for PCI device %s", dev->name);
-
-/* Xen's pciback.ko wants you to use remove_slot on the specific device */
-if (!(path = virPCIDriverFile(driver, "remove_slot")))
-goto cleanup;
-
-if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
-virReportSystemError(errno,
- _("Failed to remove slot for PCI device '%s' from 
%s"),
- dev->name, driver);
-goto cleanup;
-}
-dev->remove_slot = false;
-
- reprobe:
-if (!dev->reprobe) {
-VIR_DEBUG("Reprobe skipped for PCI device %s", dev->name);
-result = 0;
-goto cleanup;
-}
-
-VIR_DEBUG("Reprobing for PCI device %s", dev->name);
-
-/* Trigger a re-probe of the device is not in the stub's dynamic
- * ID table. If the stub is available, but 'remove_id' isn't
- * available, then re-probing would just cause the device to be
- * re-bound to the stub.
- */
-VIR_FREE(path);
-if (driver && !(path = virPCIDriverFile(driver, "remove_id")))
-goto cleanup;
-
-if (!driver || !virFileExists(drvdir) || virFileExists(path)) {
-if (virFileWriteStr(PCI_SYSFS "drivers_probe", dev->name, 0) < 0) {
-virReportSystemError(errno,
- _("Failed to trigger a re-probe for PCI 
device '%s'"),
- dev->name);
-goto cleanup;
-}
-}
-
-result = 0;
-
- cleanup:
-/* do not do it again */
-dev->unbind_from_stub = false;
-dev->remove_slot = false;
-dev->reprobe = false;
-
-return result;
-}
-
 static int
 virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr dev)
 {
@@ -1257,167 +1149,7 @@ virPCIDeviceUnbindFromStubWithOverride(virPCIDevicePtr 
dev)
 static int
 virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
 {
-VIR_AUTOFREE(char *) path = NULL;
-
-/*
- * Prefer using the device's driver_override interface, falling back
- * to the unpleasant new_id interface.
- */
-if (!(path = virPCIFile(dev->name, "driver_override")))
-return -1;
-
-if (virFileExists(path))
-return virPCIDeviceUnbindFromStubWithOverride(dev);
-
-return virPCIDeviceUnbindFromStubWithNewid(dev);
-}
-
-static int
-virPCIDeviceBindToStubWithNewid(virPCIDevicePtr dev)
-{
-int result = -1;
-bool reprobe = false;
-VIR_AUTOFREE(char *) stubDriverPath = NULL;
-VIR_AUTOFREE(char *) driverLink = NULL;
-VIR_AUTOFREE(char *) path = NULL; /* reused for different purposes */
-

[libvirt] [PATCH 04/12] qemu: Drop unused qemuOpenPCIConfig()

2019-08-20 Thread Michal Privoznik
After previous commits, the function is not used anymore.
Remove it.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_command.c | 22 --
 src/qemu/qemu_command.h |  2 --
 2 files changed, 24 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f7b5430db8..500035 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4878,28 +4878,6 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
 }
 
 
-int
-qemuOpenPCIConfig(virDomainHostdevDefPtr dev)
-{
-virDomainHostdevSubsysPCIPtr pcisrc = >source.subsys.u.pci;
-char *path = NULL;
-int configfd = -1;
-
-if (virAsprintf(, "/sys/bus/pci/devices/%04x:%02x:%02x.%01x/config",
-pcisrc->addr.domain, pcisrc->addr.bus,
-pcisrc->addr.slot, pcisrc->addr.function) < 0)
-return -1;
-
-configfd = open(path, O_RDWR, 0);
-
-if (configfd < 0)
-virReportSystemError(errno, _("Failed opening %s"), path);
-
-VIR_FREE(path);
-
-return configfd;
-}
-
 char *
 qemuBuildPCIHostdevDevStr(const virDomainDef *def,
   virDomainHostdevDefPtr dev,
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index e3983bedb2..6f97e7bc0c 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -157,8 +157,6 @@ int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
  virQEMUCapsPtr qemuCaps,
  virJSONValuePtr *props);
 
-int qemuOpenPCIConfig(virDomainHostdevDefPtr dev);
-
 /* Current, best practice */
 char *qemuBuildUSBHostdevDevStr(const virDomainDef *def,
 virDomainHostdevDefPtr dev,
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 09/12] virpcimock: Don't create "pci-stub" driver

2019-08-20 Thread Michal Privoznik
Now that nothing supports "pci-stub" driver (aka KVM style of PCI
device assignment) there is no need for virpcimock to create it.

Signed-off-by: Michal Privoznik 
---
 tests/virpcimock.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index c0dcd377d5..bbec77975a 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -992,7 +992,6 @@ init_env(void)
 
 MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044);
 MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047);
-MAKE_PCI_DRIVER("pci-stub", -1, -1);
 pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1);
 
 # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 11/12] virpcimock: Drop @driverActions enum

2019-08-20 Thread Michal Privoznik
This enum was introduced to model how RHEL-7 kernel behaves - for
some reason going with the old way (via new_id + bind) fails but
using driver_override succeeds. Well, we don't need to care about
that anymore since we don't create new_id file.

Signed-off-by: Michal Privoznik 
---
 tests/virpcimock.c | 24 +++-
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 3157037913..a5045ed97c 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -98,19 +98,11 @@ char *fakerootdir;
  *
  */
 
-enum driverActions {
-PCI_ACTION_BIND = 1 << 0,
-PCI_ACTION_UNBIND   = 1 << 1,
-PCI_ACTION_NEW_ID   = 1 << 2,
-PCI_ACTION_REMOVE_ID= 1 << 3,
-};
-
 struct pciDriver {
 char *name;
 int *vendor;/* List of vendor:device IDs the driver can handle */
 int *device;
 size_t len;/* @len is used for both @vendor and @device */
-unsigned int fail;  /* Bitwise-OR of driverActions that should fail */
 };
 
 struct pciDeviceAddress {
@@ -151,7 +143,7 @@ static void pci_device_new_from_stub(const struct pciDevice 
*data);
 static struct pciDevice *pci_device_find_by_id(struct pciDeviceAddress const 
*addr);
 static struct pciDevice *pci_device_find_by_content(const char *path);
 
-static void pci_driver_new(const char *name, int fail, ...);
+static void pci_driver_new(const char *name, ...);
 static struct pciDriver *pci_driver_find_by_dev(struct pciDevice *dev);
 static struct pciDriver *pci_driver_find_by_path(const char *path);
 static struct pciDriver *pci_driver_find_by_driver_override(struct pciDevice 
*dev);
@@ -594,7 +586,7 @@ pci_driver_get_path(const struct pciDriver *driver,
 
 
 static void
-pci_driver_new(const char *name, int fail, ...)
+pci_driver_new(const char *name, ...)
 {
 struct pciDriver *driver;
 va_list args;
@@ -606,12 +598,10 @@ pci_driver_new(const char *name, int fail, ...)
 !(driverpath = pci_driver_get_path(driver, NULL, true)))
 ABORT_OOM();
 
-driver->fail = fail;
-
 if (virFileMakePath(driverpath) < 0)
 ABORT("Unable to create: %s", driverpath);
 
-va_start(args, fail);
+va_start(args, name);
 
 while ((vendor = va_arg(args, int)) != -1) {
 if ((device = va_arg(args, int)) == -1)
@@ -805,7 +795,7 @@ pci_driver_handle_bind(const char *path)
 struct pciDevice *dev = pci_device_find_by_content(path);
 struct pciDriver *driver = pci_driver_find_by_path(path);
 
-if (!driver || !dev || PCI_ACTION_BIND & driver->fail) {
+if (!driver || !dev) {
 /* No driver, no device or failing driver requested */
 errno = ENODEV;
 goto cleanup;
@@ -822,7 +812,7 @@ pci_driver_handle_unbind(const char *path)
 int ret = -1;
 struct pciDevice *dev = pci_device_find_by_content(path);
 
-if (!dev || !dev->driver || PCI_ACTION_UNBIND & dev->driver->fail) {
+if (!dev || !dev->driver) {
 /* No device, device not binded or failing driver requested */
 errno = ENODEV;
 goto cleanup;
@@ -876,11 +866,11 @@ init_env(void)
 make_file(tmp, "drivers_probe", NULL, -1);
 
 # define MAKE_PCI_DRIVER(name, ...) \
-pci_driver_new(name, 0, __VA_ARGS__, -1, -1)
+pci_driver_new(name, __VA_ARGS__, -1, -1)
 
 MAKE_PCI_DRIVER("iwlwifi", 0x8086, 0x0044);
 MAKE_PCI_DRIVER("i915", 0x8086, 0x0046, 0x8086, 0x0047);
-pci_driver_new("vfio-pci", PCI_ACTION_BIND, -1, -1);
+MAKE_PCI_DRIVER("vfio-pci", -1, -1);
 
 # define MAKE_PCI_DEVICE(Id, Vendor, Device, ...) \
 do { \
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 07/12] virpci: Remove unused virPCIDeviceWaitForCleanup

2019-08-20 Thread Michal Privoznik
This function is no longer used after previous commit.

Signed-off-by: Michal Privoznik 
---
 src/libvirt_private.syms |   1 -
 src/util/virpci.c| 108 ---
 src/util/virpci.h|   1 -
 3 files changed, 110 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9db4ac7933..6c57351866 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2696,7 +2696,6 @@ virPCIDeviceSetStubDriver;
 virPCIDeviceSetUnbindFromStub;
 virPCIDeviceSetUsedBy;
 virPCIDeviceUnbind;
-virPCIDeviceWaitForCleanup;
 virPCIEDeviceInfoFree;
 virPCIELinkSpeedTypeFromString;
 virPCIELinkSpeedTypeToString;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 9c9ffa55c2..ea5be62033 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1552,114 +1552,6 @@ virPCIDeviceReattach(virPCIDevicePtr dev,
 return 0;
 }
 
-/* Certain hypervisors (like qemu/kvm) map the PCI bar(s) on
- * the host when doing device passthrough.  This can lead to a race
- * condition where the hypervisor is still cleaning up the device while
- * libvirt is trying to re-attach it to the host device driver.  To avoid
- * this situation, we look through /proc/iomem, and if the hypervisor is
- * still holding on to the bar (denoted by the string in the matcher
- * variable), then we can wait around a bit for that to clear up.
- *
- * A typical /proc/iomem looks like this (snipped for brevity):
- * 0001-0008efff : System RAM
- * 0008f000-0008 : reserved
- * ...
- * 0010-cc9fcfff : System RAM
- *   0020-00483d3b : Kernel code
- *   00483d3c-005c88df : Kernel data
- * cc9fd000-ccc71fff : ACPI Non-volatile Storage
- * ...
- * d020-d02f : PCI Bus #05
- *   d020-d021 : :05:00.0
- * d020-d021 : e1000e
- *   d022-d023 : :05:00.0
- * d022-d023 : e1000e
- * ...
- * f000-f0003fff : :00:1b.0
- *   f000-f0003fff : kvm_assigned_device
- *
- * Returns 0 if we are clear to continue, and 1 if the hypervisor is still
- * holding on to the resource.
- */
-int
-virPCIDeviceWaitForCleanup(virPCIDevicePtr dev, const char *matcher)
-{
-FILE *fp;
-char line[160];
-char *tmp;
-unsigned long long start, end;
-unsigned int domain, bus, slot, function;
-bool in_matching_device;
-int ret;
-size_t match_depth;
-
-fp = fopen("/proc/iomem", "r");
-if (!fp) {
-/* If we failed to open iomem, we just basically ignore the error.  The
- * unbind might succeed anyway, and besides, it's very likely we have
- * no way to report the error
- */
-VIR_DEBUG("Failed to open /proc/iomem, trying to continue anyway");
-return 0;
-}
-
-ret = 0;
-in_matching_device = false;
-match_depth = 0;
-while (fgets(line, sizeof(line), fp) != 0) {
-/* the logic here is a bit confusing.  For each line, we look to
- * see if it matches the domain:bus:slot.function we were given.
- * If this line matches the DBSF, then any subsequent lines indented
- * by 2 spaces are the PCI regions for this device.  It's also
- * possible that none of the PCI regions are currently mapped, in
- * which case we have no indented regions.  This code handles all
- * of these situations
- */
-if (in_matching_device && (strspn(line, " ") == (match_depth + 2))) {
-/* expected format: - :  */
-if (/* start */
-virStrToLong_ull(line, , 16, ) < 0 || *tmp != '-' ||
-/* end */
-virStrToLong_ull(tmp + 1, , 16, ) < 0 ||
-(tmp = STRSKIP(tmp, " : ")) == NULL)
-continue;
-
-if (STRPREFIX(tmp, matcher)) {
-ret = 1;
-break;
-}
-} else {
-in_matching_device = false;
-
-/* expected format: - : 
::. */
-if (/* start */
-virStrToLong_ull(line, , 16, ) < 0 || *tmp != '-' ||
-/* end */
-virStrToLong_ull(tmp + 1, , 16, ) < 0 ||
-(tmp = STRSKIP(tmp, " : ")) == NULL ||
-/* domain */
-virStrToLong_ui(tmp, , 16, ) < 0 || *tmp != ':' ||
-/* bus */
-virStrToLong_ui(tmp + 1, , 16, ) < 0 || *tmp != ':' ||
-/* slot */
-virStrToLong_ui(tmp + 1, , 16, ) < 0 || *tmp != '.' ||
-/* function */
-virStrToLong_ui(tmp + 1, , 16, ) < 0 || *tmp != 
'\n')
-continue;
-
-if (domain != dev->address.domain || bus != dev->address.bus ||
-slot != dev->address.slot || function != dev->address.function)
-continue;
-in_matching_device = true;
-match_depth = strspn(line, " ");
-}
-}
-
-VIR_FORCE_FCLOSE(fp);
-
-return ret;
-}
-
 static char *
 

[libvirt] [PATCH 02/12] tests: Remove 'kvm' PCI backend from domaincapstest

2019-08-20 Thread Michal Privoznik
The KVM assignment was removed in qemu driver in previous commit.
Remove it from domaincapstest too which is hard coding it.

Signed-off-by: Michal Privoznik 
---
 tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml | 1 -
 tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.12.0.s390x.xml| 1 -
 tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml   | 1 -
 tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml  | 1 -
 tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml   | 1 -
 tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml | 1 -
 tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.7.0.s390x.xml | 1 -
 tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.8.0.s390x.xml | 1 -
 tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_3.0.0.s390x.xml | 1 -
 tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_4.0.0.s390x.xml | 1 -
 tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml| 1 -
 tests/domaincapsschemadata/qemu_4.1.0.x86_64.xml| 1 -
 tests/domaincapstest.c  | 1 -
 22 files changed, 22 deletions(-)

diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml 
b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
index f14f245007..a2df336833 100644
--- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml
@@ -112,7 +112,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml 
b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml
index cc65977f03..ed1af3224b 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml
@@ -116,7 +116,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml 
b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
index 8c490fa4d1..99de2b0a8e 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml
@@ -80,7 +80,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml 
b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml
index 18171f0db4..8d039f3514 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml
@@ -172,7 +172,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml 
b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml
index 146041a6c1..109162ffd8 100644
--- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml
@@ -145,7 +145,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml
index 778e27582f..13441b9923 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml
@@ -113,7 +113,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
index a01f5ef72f..974739c38e 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml
@@ -111,7 +111,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
index a74cece8b6..9f628a3652 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml
@@ -84,7 +84,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml 
b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
index 949c5f8723..bb1f784328 100644
--- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
+++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml
@@ -119,7 +119,6 @@
   
   
 default
-kvm
 vfio
   
 
diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml 
b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml
index 8c66d6582a..322d12c719 100644
--- 

[libvirt] [PATCH 01/12] qemu: Drop KVM assignment

2019-08-20 Thread Michal Privoznik
KVM style of PCI devices assignment was dropped in kernel in
favor of vfio pci (see kernel commit v4.12-rc1~68^2~65). Since
vfio is around for quite some time now and is far superior
discourage people in using KVM style.

Ideally, I'd make QEMU_CAPS_VFIO_PCI implicitly assumed but turns
out qemu-3.0.0 doesn't support vfio-pci device for RISC-V.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_capabilities.c |  6 -
 src/qemu/qemu_command.c  | 26 ++---
 src/qemu/qemu_command.h  |  1 -
 src/qemu/qemu_driver.c   | 14 
 src/qemu/qemu_hostdev.c  | 44 +++-
 src/qemu/qemu_hostdev.h  |  1 -
 src/qemu/qemu_hotplug.c  | 20 ++--
 tests/domaincapstest.c   |  3 +--
 8 files changed, 12 insertions(+), 103 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c9677315ab..73300128ea 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5338,7 +5338,6 @@ static int
 virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsDeviceHostdevPtr hostdev)
 {
-bool supportsPassthroughKVM = qemuHostdevHostSupportsPassthroughLegacy();
 bool supportsPassthroughVFIO = qemuHostdevHostSupportsPassthroughVFIO();
 
 hostdev->supported = VIR_TRISTATE_BOOL_YES;
@@ -5374,11 +5373,6 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr 
qemuCaps,
  VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO);
 }
 
-if (supportsPassthroughKVM) {
-VIR_DOMAIN_CAPS_ENUM_SET(hostdev->pciBackend,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT,
- VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM);
-}
 return 0;
 }
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e3f4ef624b..f7b5430db8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4904,7 +4904,6 @@ char *
 qemuBuildPCIHostdevDevStr(const virDomainDef *def,
   virDomainHostdevDefPtr dev,
   unsigned int bootIndex, /* used iff 
dev->info->bootIndex == 0 */
-  const char *configfd,
   virQEMUCapsPtr qemuCaps)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -4913,16 +4912,11 @@ qemuBuildPCIHostdevDevStr(const virDomainDef *def,
 
 /* caller has to assign proper passthrough backend type */
 switch ((virDomainHostdevSubsysPCIBackendType)backend) {
-case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
-virBufferAddLit(, "pci-assign");
-if (configfd && *configfd)
-virBufferAsprintf(, ",configfd=%s", configfd);
-break;
-
 case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO:
 virBufferAddLit(, "vfio-pci");
 break;
 
+case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM:
 case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT:
 case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN:
 case VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST:
@@ -5676,7 +5670,6 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
 }
 }
 
-char *configfd_name = NULL;
 unsigned int bootIndex = hostdev->info->bootIndex;
 
 /* bootNet will be non-0 if boot order was set and no other
@@ -5686,27 +5679,12 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
 bootIndex = *bootHostdevNet;
 *bootHostdevNet = 0;
 }
-if (backend != VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
-int configfd = qemuOpenPCIConfig(hostdev);
-
-if (configfd >= 0) {
-if (virAsprintf(_name, "%d", configfd) < 0) {
-VIR_FORCE_CLOSE(configfd);
-return -1;
-}
-
-virCommandPassFD(cmd, configfd,
- VIR_COMMAND_PASS_FD_CLOSE_PARENT);
-}
-}
 
 if (qemuCommandAddExtDevice(cmd, hostdev->info) < 0)
 return -1;
 
 virCommandAddArg(cmd, "-device");
-devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex,
-   configfd_name, qemuCaps);
-VIR_FREE(configfd_name);
+devstr = qemuBuildPCIHostdevDevStr(def, hostdev, bootIndex, 
qemuCaps);
 if (!devstr)
 return -1;
 virCommandAddArg(cmd, devstr);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 7e2dc5a60a..e3983bedb2 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -148,7 +148,6 @@ char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
 char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
 virDomainHostdevDefPtr dev,
 unsigned int bootIndex,
-const char 

[libvirt] [PATCH 05/12] virhostdev: Disable legacy kvm assignment

2019-08-20 Thread Michal Privoznik
The KVM assignment is going to be removed shortly. Don't let the
hostdev module configure it.

Signed-off-by: Michal Privoznik 
---
 src/util/virhostdev.c | 12 
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index e3f48a9a2e..29e75ffc84 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -246,12 +246,16 @@ virHostdevGetPCIHostDevice(const virDomainHostdevDef 
*hostdev,
 
 virPCIDeviceSetManaged(actual, hostdev->managed);
 
-if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
+if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
 virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO);
-else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN)
+} else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN) {
 virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN);
-else
-virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM);
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("pci backend driver '%s' is not supported"),
+   
virDomainHostdevSubsysPCIBackendTypeToString(pcisrc->backend));
+return -1;
+}
 
 VIR_STEAL_PTR(*pci, actual);
 return 0;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 00/12] Drop KVM assignment

2019-08-20 Thread Michal Privoznik
The KVM style of PCI assignment is not used, and it hasn't been for a
while. Any attempt to start a domain with it would result in error as
kernel dropped its support in 4.12.0 (after being deprecated for 1.5
years).

Michal Prívozník (12):
  qemu: Drop KVM assignment
  tests: Remove 'kvm' PCI backend from domaincapstest
  virhostdev: Unify virDomainHostdevDef to virPCIDevice translation
  qemu: Drop unused qemuOpenPCIConfig()
  virhostdev: Disable legacy kvm assignment
  virpci: Drop 'pci-stub' driver
  virpci: Remove unused virPCIDeviceWaitForCleanup
  virpci: Drop newid style of PCI device detach
  virpcimock: Don't create "pci-stub" driver
  virpcimock: Don't create new_id or remove_id files
  virpcimock: Drop @driverActions enum
  news: Document KVM assignment removal

 docs/news.xml |  13 +
 src/libvirt_private.syms  |   1 -
 src/qemu/qemu_capabilities.c  |   6 -
 src/qemu/qemu_command.c   |  48 +--
 src/qemu/qemu_command.h   |   3 -
 src/qemu/qemu_driver.c|  14 +-
 src/qemu/qemu_hostdev.c   |  44 +-
 src/qemu/qemu_hostdev.h   |   1 -
 src/qemu/qemu_hotplug.c   |  20 +-
 src/util/virhostdev.c |  97 +++--
 src/util/virpci.c | 403 +-
 src/util/virpci.h |   2 -
 .../qemu_1.7.0.x86_64.xml |   1 -
 .../qemu_2.12.0-virt.aarch64.xml  |   1 -
 .../qemu_2.12.0.ppc64.xml |   1 -
 .../qemu_2.12.0.s390x.xml |   1 -
 .../qemu_2.12.0.x86_64.xml|   1 -
 .../qemu_2.6.0-virt.aarch64.xml   |   1 -
 .../qemu_2.6.0.aarch64.xml|   1 -
 .../domaincapsschemadata/qemu_2.6.0.ppc64.xml |   1 -
 .../qemu_2.6.0.x86_64.xml |   1 -
 .../domaincapsschemadata/qemu_2.7.0.s390x.xml |   1 -
 .../qemu_2.8.0-tcg.x86_64.xml |   1 -
 .../domaincapsschemadata/qemu_2.8.0.s390x.xml |   1 -
 .../qemu_2.8.0.x86_64.xml |   1 -
 .../qemu_2.9.0-q35.x86_64.xml |   1 -
 .../qemu_2.9.0-tcg.x86_64.xml |   1 -
 .../qemu_2.9.0.x86_64.xml |   1 -
 .../domaincapsschemadata/qemu_3.0.0.s390x.xml |   1 -
 .../qemu_3.1.0.x86_64.xml |   1 -
 .../domaincapsschemadata/qemu_4.0.0.s390x.xml |   1 -
 .../qemu_4.0.0.x86_64.xml |   1 -
 .../qemu_4.1.0.x86_64.xml |   1 -
 tests/domaincapstest.c|   4 +-
 tests/virpcimock.c| 137 +-
 35 files changed, 92 insertions(+), 722 deletions(-)

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 03/12] virhostdev: Unify virDomainHostdevDef to virPCIDevice translation

2019-08-20 Thread Michal Privoznik
There are two places where we need to create virPCIDevice from
given virDomainHostdevDef. In both places the code is duplicated.
Move them into a single function and call it from those two
places.

Signed-off-by: Michal Privoznik 
---
 src/util/virhostdev.c | 93 +--
 1 file changed, 54 insertions(+), 39 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 6861b8a84e..e3f48a9a2e 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -212,6 +212,51 @@ virHostdevManagerGetDefault(void)
 return virObjectRef(manager);
 }
 
+/**
+ * virHostdevGetPCIHostDevice:
+ * @hostdev: domain hostdev definition
+ * @pci: returned PCI device
+ *
+ * For given @hostdev which represents a PCI device construct its
+ * virPCIDevice representation and returned it in @pci. If
+ * @hostdev does not represent a PCI device then @pci is set to
+ * NULL and 0 is returned.
+ *
+ * Returns: 0 on success (@pci might be NULL though),
+ * -1 otherwise (with error reported).
+ */
+static int
+virHostdevGetPCIHostDevice(const virDomainHostdevDef *hostdev,
+   virPCIDevicePtr *pci)
+{
+VIR_AUTOPTR(virPCIDevice) actual = NULL;
+const virDomainHostdevSubsysPCI *pcisrc = >source.subsys.u.pci;
+
+*pci = NULL;
+
+if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
+return 0;
+
+actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
+ pcisrc->addr.slot, pcisrc->addr.function);
+
+if (!actual)
+return -1;
+
+virPCIDeviceSetManaged(actual, hostdev->managed);
+
+if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
+virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_VFIO);
+else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN)
+virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_XEN);
+else
+virPCIDeviceSetStubDriver(actual, VIR_PCI_STUB_DRIVER_KVM);
+
+VIR_STEAL_PTR(*pci, actual);
+return 0;
+}
+
 static virPCIDeviceListPtr
 virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
 {
@@ -223,27 +268,13 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr 
*hostdevs, int nhostdevs)
 
 for (i = 0; i < nhostdevs; i++) {
 virDomainHostdevDefPtr hostdev = hostdevs[i];
-virDomainHostdevSubsysPCIPtr pcisrc = >source.subsys.u.pci;
 VIR_AUTOPTR(virPCIDevice) pci = NULL;
 
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
-continue;
-if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
-continue;
+if (virHostdevGetPCIHostDevice(hostdev, ) < 0)
+return NULL;
 
-pci = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
-  pcisrc->addr.slot, pcisrc->addr.function);
 if (!pci)
-return NULL;
-
-virPCIDeviceSetManaged(pci, hostdev->managed);
-
-if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO)
-virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_VFIO);
-else if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN)
-virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_XEN);
-else
-virPCIDeviceSetStubDriver(pci, VIR_PCI_STUB_DRIVER_KVM);
+continue;
 
 if (virPCIDeviceListAdd(pcidevs, pci) < 0)
 return NULL;
@@ -253,7 +284,6 @@ virHostdevGetPCIHostDeviceList(virDomainHostdevDefPtr 
*hostdevs, int nhostdevs)
 VIR_RETURN_PTR(pcidevs);
 }
 
-
 static int
 virHostdevPCISysfsPath(virDomainHostdevDefPtr hostdev,
char **sysfs_path)
@@ -1067,7 +1097,6 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
  const char *drv_name,
  const char *dom_name)
 {
-virDomainHostdevDefPtr hostdev = NULL;
 size_t i;
 int ret = -1;
 
@@ -1078,32 +1107,18 @@ virHostdevUpdateActivePCIDevices(virHostdevManagerPtr 
mgr,
 virObjectLock(mgr->inactivePCIHostdevs);
 
 for (i = 0; i < nhostdevs; i++) {
+const virDomainHostdevDef *hostdev = hostdevs[i];
 VIR_AUTOPTR(virPCIDevice) actual = NULL;
-virDomainHostdevSubsysPCIPtr pcisrc;
-hostdev = hostdevs[i];
-pcisrc = >source.subsys.u.pci;
 
-if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
-continue;
-if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
-continue;
-
-actual = virPCIDeviceNew(pcisrc->addr.domain, pcisrc->addr.bus,
- pcisrc->addr.slot, pcisrc->addr.function);
+if (virHostdevGetPCIHostDevice(hostdev, ) < 0)
+goto cleanup;
 
 if (!actual)
+continue;
+
+if (virPCIDeviceSetUsedBy(actual, drv_name, 

Re: [libvirt] [PATCH v4 7/8] cpu_conf: xml to cpu definition parse helper

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:28 -0400, Collin Walling wrote:
> Implement an XML to virCPUDefPtr helper that handles
> the ctxt prerequisite for virCPUDefParseXML.
> 
> This does not alter any functionality.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Bjoern Walk 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/conf/cpu_conf.c  | 30 ++
>  src/conf/cpu_conf.h  |  6 ++
>  src/cpu/cpu.c| 14 +-
>  src/libvirt_private.syms |  1 +
>  4 files changed, 38 insertions(+), 13 deletions(-)
> 
> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> index 7d16a05..c587aff 100644
> --- a/src/conf/cpu_conf.c
> +++ b/src/conf/cpu_conf.c
> @@ -268,6 +268,36 @@ virCPUDefCopy(const virCPUDef *cpu)
>  }
>  
>  
> +int
> +virCPUDefParseXMLHelper(const char *xml,

I would call this virCPUDefParseXMLString for consistency with other
parsing functions. If there are several variants of the parsing function
with different input types, the String suffix is used for the variant
that parses an XML string.

> +const char *xpath,

And the callers of this function should not ever need the xpath
parameter. It should go away.

> +virCPUType type,
> +virCPUDefPtr *cpu)
> +{
> +xmlDocPtr doc = NULL;
> +xmlXPathContextPtr ctxt = NULL;
> +int ret = -1;
> +
> +if (!xml) {
> +virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU 
> definition"));
> +goto cleanup;
> +}
> +
> +if (!(doc = virXMLParseStringCtxt(xml, _("(CPU_definition)"), )))
> +goto cleanup;
> +
> +if (virCPUDefParseXML(ctxt, xpath, type, cpu) < 0)
> +goto cleanup;
> +
> +ret = 0;
> +
> + cleanup:
> +xmlFreeDoc(doc);
> +xmlXPathFreeContext(ctxt);
> +return ret;
> +}
> +
> +
>  /*
>   * Parses CPU definition XML from a node pointed to by @xpath. If @xpath is
>   * NULL, the current node of @ctxt is used (i.e., it is a shortcut to ".").
...

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 6/8] qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:27 -0400, Collin Walling wrote:
> This capability enables CPU model comparison between two CPU
> definitions via QMP.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_capabilities.c | 2 ++
>  src/qemu/qemu_capabilities.h | 1 +
>  tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 +
>  tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 +
>  tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 +
>  tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml  | 1 +
>  tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml  | 1 +
>  tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml  | 1 +
>  tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml  | 1 +
>  9 files changed, 10 insertions(+)

Reviewed-by: Jiri Denemark 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [ocaml PATCH 3/3] Fix shebang in perl scripts

2019-08-20 Thread Richard W.M. Jones
On Tue, Aug 20, 2019 at 03:44:56PM +0200, Pino Toscano wrote:
> Instead of hardcoding the location of perl (assuming it is installed in
> /usr), use /usr/bin/env to run it, and thus picking it from $PATH.
> This makes it possible to run these scripts also on installations with
> perl in a different prefix than /usr.
> 
> Also, given that we want enable warnings on scripts, turn the -w
> previously in shebang to explicit "use warnings;" in scripts which
> didn't have it before.
> 
> Signed-off-by: Pino Toscano 
> ---
>  libvirt/generator.pl | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libvirt/generator.pl b/libvirt/generator.pl
> index 490ef9a..e850500 100755
> --- a/libvirt/generator.pl
> +++ b/libvirt/generator.pl
> @@ -1,4 +1,4 @@
> -#!/usr/bin/perl -w
> +#!/usr/bin/env perl
>  #
>  # OCaml bindings for libvirt.
>  # (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc.
> @@ -26,6 +26,7 @@
>  # Please read libvirt/README.
>  
>  use strict;
> +use warnings;

All seems very straightforward, ACK series.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 5/8] qemu_monitor: implement query-cpu-model-comparison

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:26 -0400, Collin Walling wrote:
> Interfaces with QEMU to compare CPU models. The command takes two
> CPU models, A and B, that are given a model name and an optional list
> of CPU features. Through the query-cpu-model-comparison command issued
> via QMP, a result is produced that contains the comparison evaluation
> string (identical, superset, subset, incompatible) as well as a list
> of properties (aka CPU features) responsible for the subset or
> superset result.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_monitor.c  | 22 ++
>  src/qemu/qemu_monitor.h  |  9 +
>  src/qemu/qemu_monitor_json.c | 95 
> 
>  src/qemu/qemu_monitor_json.h | 10 +
>  4 files changed, 136 insertions(+)

Most of the comments from 2/8 are applicable here as well.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 0/8] CPU Model Baseline and Comparison for s390x

2019-08-20 Thread Jiri Denemark
First, let me apologize for such a late review. I'll try my best to
review your series earlier next time.

On Wed, Jul 17, 2019 at 10:03:21 -0400, Collin Walling wrote:
> When baselining CPU models and the user appends the --features argument 
> to the command, s390x will only report back features that supersede the 
> base model definition.
> 
> *NOTE* if the --features flag is intended to expand /ALL/ features
> available to a CPU model (such as the huge list of features reported
> by a full CPU model expansion), please let me know and I can resolve 
> this.

I'm not sure how well this fits s390 world, but the semantics of
VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES flag is to report all CPU
features which are hidden behind the CPU model. That is, all feature
which you'd get when starting QEMU with just the CPU model name and no
additional features. The extra features should not be touched at all.
Specifically, removing them when the flag is not used is wrong.

To me this looks like the flag should really result in running
query-cpu-model-expansion (but likely the "static" one rather then
"full" expansion) on the baseline CPU model and reporting the enabled
features along with those already included in the baseline feature set.

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 4/8] qemu_driver: hook up query-cpu-model-baseline

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:25 -0400, Collin Walling wrote:
> This command is hooked into the virsh hypervisor-cpu-baseline command.
> As such, the CPU models provided in the XML sent to the command will be
> baselined with the CPU contained in the QEMU capabilities file for the
> appropriate QEMU binary (for s390x, this CPU definition can be observed
> via virsh domcapabilities).

This is not how the baseline API works. If a user wants the current host
CPU model to be taken in the baseline computation, they need to provide
it in the array of input CPUs by themselves.

> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_capabilities.c | 84 
> 
>  src/qemu/qemu_capabilities.h |  7 
>  src/qemu/qemu_driver.c   | 27 ++
>  3 files changed, 118 insertions(+)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index b898113..ab337fa 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -5574,3 +5574,87 @@ virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps)
>  for (i = 0; i < qemuCaps->nmachineTypes; i++)
>  VIR_FREE(qemuCaps->machineTypes[i].alias);
>  }
> +
> +
> +static int
> +virQEMUCapsStealCPUModelFromInfo(virCPUDefPtr dst,
> + qemuMonitorCPUModelInfoPtr *src)
> +{
> +qemuMonitorCPUModelInfoPtr info = *src;
> +size_t i;
> +
> +virCPUDefFreeModel(dst);
> +
> +VIR_STEAL_PTR(dst->model, info->name);
> +
> +for (i = 0; i < info->nprops; i++) {
> +char *name = info->props[i].name;
> +int policy = VIR_CPU_FEATURE_REQUIRE;
> +
> +if (info->props[i].type == QEMU_MONITOR_CPU_PROPERTY_BOOLEAN &&
> +!info->props[i].value.boolean)
> +policy = VIR_CPU_FEATURE_DISABLE;
> +
> +if (virCPUDefAddFeature(dst, name, policy) < 0)
> +goto error;
> +}
> +
> +qemuMonitorCPUModelInfoFree(info);
> +*src = NULL;
> +return 0;
> +
> + error:
> +virCPUDefFree(dst);
> +return -1;
> +}
> +
> +
> +virCPUDefPtr
> +virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
> +const char *libDir,
> +uid_t runUid,
> +gid_t runGid,
> +int ncpus,
> +virCPUDefPtr *cpus)

This function does not belong to qemu_capabilities.c, it should be in
qemu_driver.c and with a different prefix, of course. And this applies
to the helper above too.

> +{
> +qemuMonitorCPUModelInfoPtr result = NULL;
> +qemuProcessQMPPtr proc = NULL;
> +virCPUDefPtr cpu = NULL;
> +virCPUDefPtr baseline = NULL;
> +size_t i;
> +
> +if (VIR_ALLOC(cpu) < 0)
> +goto cleanup;
> +
> +if (virCPUDefCopyModel(cpu, cpus[0], false))
> +goto cleanup;
> +
> +if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
> +   runUid, runGid, false)))
> +goto cleanup;
> +
> +if (qemuProcessQMPStart(proc) < 0)
> +goto cleanup;
> +
> +for (i = 1; i < ncpus; i++) {
> +if (qemuMonitorGetCPUModelBaseline(proc->mon, cpu->model,
> +   cpu->nfeatures, cpu->features,
> +   cpus[i]->model, 
> cpus[i]->nfeatures,
> +   cpus[i]->features, ) < 0)

See my comment to 2/8. Wouldn't this be much better as

if (qemuMonitorGetCPUModelBaseline(proc->mon, cpu, cpus[i],
   ) < 0)

> +goto cleanup;
> +
> +if (virQEMUCapsStealCPUModelFromInfo(cpu, ) < 0)
> +goto cleanup;
> +}
> +
> +VIR_STEAL_PTR(baseline, cpu);
> +
> + cleanup:
> +if (!baseline)
> +virQEMUCapsLogProbeFailure(qemuCaps->binary);

There's no probing here. It's just an implementation of the API invoked
by libvirt client. No need to log anything here.

> +
> +qemuMonitorCPUModelInfoFree(result);

As Boris already noticed, result cannot be non-NULL here. In fact, you
could even make the result variable local to the for loop.

> +qemuProcessQMPFree(proc);
> +virCPUDefFree(cpu);
> +return baseline;
> +}
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index 8dde759..b49c0b9 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -665,3 +665,10 @@ virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps);
>  
>  virArch virQEMUCapsArchFromString(const char *arch);
>  const char *virQEMUCapsArchToString(virArch arch);
> +
> +virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps,
> +const char *libDir,
> +uid_t runUid,
> +gid_t runGid,
> +   

Re: [libvirt] [PATCH v4 3/8] qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_BASELINE

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:24 -0400, Collin Walling wrote:
> This capability enables CPU model baselining  between two CPU
> definitions via QMP.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_capabilities.c | 2 ++
>  src/qemu/qemu_capabilities.h | 1 +
>  tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 +
>  tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 +
>  tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 +
>  tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml  | 1 +
>  tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml  | 1 +
>  tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml  | 1 +
>  tests/qemucapabilitiesdata/caps_4.0.0.s390x.xml  | 1 +
>  9 files changed, 10 insertions(+)

Reviewed-by: Jiri Denemark 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 2/8] qemu_monitor: implement query-cpu-model-baseline

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:23 -0400, Collin Walling wrote:
> Interfaces with QEMU to baseline CPU models. The command takes two
> CPU models, A and B, that are given a model name and an optional list
> of CPU features. Through the query-cpu-model-baseline command issued
> via QMP, a result is produced that contains a new baselined CPU model
> that is guaranteed to run on both A and B.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_monitor.c  | 22 
>  src/qemu/qemu_monitor.h  |  9 +++
>  src/qemu/qemu_monitor_json.c | 61 
> 
>  src/qemu/qemu_monitor_json.h | 10 
>  4 files changed, 102 insertions(+)
> 
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 731be2e..136d3e2 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -3648,6 +3648,28 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
>  }
>  
>  
> +int
> +qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
> +   const char *model_a_name,
> +   int model_a_nprops,
> +   virCPUFeatureDefPtr model_a_props,
> +   const char *model_b_name,
> +   int model_b_nprops,
> +   virCPUFeatureDefPtr model_b_props,

This is a mess. Model name, number of features, and the array of
features are all included in a virCPUDef structure. Are you going to
call this function from places where you don't actually have virCPUDef?
Passing just two virCPUDefPtr cpu1, and virCPUDefPtr cpu2 parameters
would be much nicer.

> +   qemuMonitorCPUModelInfoPtr *model_result)
> +{
> +VIR_DEBUG("model_a_name=%s model_a_nprops=%d model_b_name=%s 
> model_b_nprops=%d",
> +   model_a_name, model_a_nprops, model_b_name, model_b_nprops);
> +
> +QEMU_CHECK_MONITOR(mon);
> +
> +return qemuMonitorJSONGetCPUModelBaseline(mon, model_a_name, 
> model_a_nprops,
> +  model_a_props, model_b_name,
> +  model_b_nprops, model_b_props,
> +  model_result);
> +}
> +
> +
>  void
>  qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info)
>  {
> diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
> index c41428b..4ec74f1 100644
> --- a/src/qemu/qemu_monitor.h
> +++ b/src/qemu/qemu_monitor.h
> @@ -1084,6 +1084,15 @@ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
>  
>  void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info);
>  
> +int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
> +   const char *model_a_name,
> +   int model_a_nprops,
> +   virCPUFeatureDefPtr model_a_props,
> +   const char *model_b_name,
> +   int model_b_nprops,
> +   virCPUFeatureDefPtr model_b_props,
> +   qemuMonitorCPUModelInfoPtr *model_result);
> +
>  qemuMonitorCPUModelInfoPtr
>  qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);
>  
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index f6bf7f2..b599ee6 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -5814,6 +5814,67 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
>  }
>  
>  
> +int
> +qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
> +   const char *model_a_name,
> +   int model_a_nprops,
> +   virCPUFeatureDefPtr model_a_props,
> +   const char *model_b_name,
> +   int model_b_nprops,
> +   virCPUFeatureDefPtr model_b_props,
> +   qemuMonitorCPUModelInfoPtr *model_result)
> +{
> +int ret = -1;
> +virJSONValuePtr model_a;
> +virJSONValuePtr model_b = NULL;
> +virJSONValuePtr cmd = NULL;
> +virJSONValuePtr reply = NULL;
> +virJSONValuePtr data;
> +virJSONValuePtr cpu_model;
> +virJSONValuePtr cpu_props = NULL;
> +const char *cpu_name = "";
> +qemuMonitorCPUModelInfoPtr baseline = NULL;
> +
> +if (!(model_a = qemuMonitorJSONMakeCPUModel(model_a_name, model_a_nprops,
> +model_a_props, true)) ||
> +!(model_b = qemuMonitorJSONMakeCPUModel(model_b_name, model_b_nprops,
> +model_b_props, true)))
> +goto cleanup;
> +
> +if (!(cmd = qemuMonitorJSONMakeCommand("query-cpu-model-baseline",
> +   

Re: [libvirt] [PATCH v4 1/8] qemu_monitor: helper functions for CPU models

2019-08-20 Thread Jiri Denemark
On Wed, Jul 17, 2019 at 10:03:22 -0400, Collin Walling wrote:
> Refactor some code in qemuMonitorJSONGetCPUModelExpansion to be
> later used for the comparison and baseline functions.

You're mixing refactoring with adding new functionality. Splitting such
changes into separate patches is better. Moving some parts of existing
functions into new standalone functions is easier to review if the new
code matches the old one. It's not a big deal in this case, but since
you'll need to respin the series for other issues, you can also split
this patch.

> 
> This does not alter any functionality.
> 
> Signed-off-by: Collin Walling 
> Reviewed-by: Bjoern Walk 
> Reviewed-by: Daniel Henrique Barboza 
> ---
>  src/qemu/qemu_monitor_json.c | 173 
> ++-
>  1 file changed, 121 insertions(+), 52 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> index 8723ff4..f6bf7f2 100644
> --- a/src/qemu/qemu_monitor_json.c
> +++ b/src/qemu/qemu_monitor_json.c
> @@ -5616,6 +5616,120 @@ qemuMonitorJSONParseCPUModelProperty(const char *key,
>  return 0;
>  }
>  
> +
> +static virJSONValuePtr
> +qemuMonitorJSONMakeCPUModel(const char *model_name,
> +size_t nprops,
> +virCPUFeatureDefPtr props,

Adding virCPUFeatureDefPtr parameter to this function should go into a
separate patch. And for consistency, I believe we tend to pass the
pointer first followed by number of items.

> +bool migratable)
> +{
> +virJSONValuePtr value;
> +virJSONValuePtr feats = NULL;
> +size_t i;
> +
> +if (!(value = virJSONValueNewObject()))
> +goto cleanup;
> +
> +if (virJSONValueObjectAppendString(value, "name", model_name) < 0)
> +goto cleanup;
> +
> +if (nprops || !migratable) {
> +if (!(feats = virJSONValueNewObject()))
> +goto cleanup;
> +
> +for (i = 0; i < nprops; i++) {
> +char *name = props[i].name;
> +bool enabled = false;
> +
> +/* policy may be reported as -1 if the CPU def is a host model */
> +if (props[i].policy == VIR_CPU_FEATURE_REQUIRE ||
> +props[i].policy == VIR_CPU_FEATURE_FORCE ||
> +props[i].policy == -1)
> +enabled = true;

The naming is quite confusing. The virCPUDef structure contains an array
of features and you call it "props" while QEMU calls them "props" in the
QMP protocol and your variable containing them is called "feats".

> +
> +if (virJSONValueObjectAppendBoolean(feats, name, enabled) < 0)
> +goto cleanup;
> +}
> +
> +if (!migratable &&
> +virJSONValueObjectAppendBoolean(feats, "migratable", false) < 0) 
> {
> +goto cleanup;
> +}
> +
> +if (virJSONValueObjectAppend(value, "props", feats) < 0)
> +goto cleanup;
> +}
> +
> +return value;
> +
> + cleanup:

"cleanup" label is used if the code following it is shared between both
success and failure paths. Since it's not the case here, you should call
it "error".

> +virJSONValueFree(value);
> +virJSONValueFree(feats);
> +return NULL;
> +}
> +
> +
> +static int
> +qemuMonitorJSONParseCPUModelData(virJSONValuePtr data,
> + virJSONValuePtr *cpu_model,

cpu_model is not used anywhere outside this function, it's just a
temporary variable to store the container object for "model" and
"props".

> + virJSONValuePtr *cpu_props,
> + const char **cpu_name,
> + const char *cmd_name)

I'd move the cmd_name parameter to the second place after data so the
input parameters go first, followed by output parameters.

> +{
> +if (!(*cpu_model = virJSONValueObjectGetObject(data, "model"))) {
> +virReportError(VIR_ERR_INTERNAL_ERROR,
> +   _("%s reply data was missing 'model'"), cmd_name);
> +return -1;
> +}
> +
> +if (!(*cpu_name = virJSONValueObjectGetString(*cpu_model, "name"))) {
> +virReportError(VIR_ERR_INTERNAL_ERROR,
> +   _("%s reply data was missing 'name'"), cmd_name);
> +return -1;
> +}
> +
> +/* Some older CPU models do not report properties */
> +*cpu_props = virJSONValueObjectGetObject(*cpu_model, "props");

This change should go into a separate patch with an explanation. Also,
it only applies to s390. Missing "props" should still result in an error
on x86. I think the callers should decide whether this is fatal or not.

> +
> +return 0;
> +}
> +
> +
> +static int
> +qemuMonitorJSONParseCPUModel(const char *cpu_name,
> + virJSONValuePtr cpu_props,
> + qemuMonitorCPUModelInfoPtr *model_info)
> +{
> +qemuMonitorCPUModelInfoPtr machine_model = NULL;
> +int ret = 

Re: [libvirt] 5.6.0 regression: "Some activation file descriptors are unclaimed"

2019-08-20 Thread Daniel P . Berrangé
On Mon, Aug 19, 2019 at 12:35:15PM +, Allen, John wrote:
> On Mon, Aug 19, 2019 at 01:30:06PM +0100, Daniel P. Berrangé wrote:
> > On Mon, Aug 19, 2019 at 12:15:48PM +, Allen, John wrote:
> > > On Mon, Aug 19, 2019 at 12:24:43PM +0100, Daniel P. Berrangé wrote:
> > > > On Wed, Aug 14, 2019 at 01:30:26PM +, Allen, John wrote:
> > > > > After upgrading to v5.6.0, starting libvirtd fails with the following 
> > > > > message
> > > > > in journalctl -xe:
> > > > > 
> > > > > libvirtd[186338]: internal error: Some activation file descriptors 
> > > > > are unclaimed
> > > > > 
> > > > > 5b8569dd6e284b9159c701e8bffafb196983fc4a introduces the message. The 
> > > > > commit
> > > > > message indicates that systemd version 227 is required, but my system 
> > > > > seems to
> > > > > be running version 237.
> > > > > 
> > > > > Is this a known issue? Is there any other configuration for systemd 
> > > > > needed to
> > > > > avoid the problem?
> > > > 
> > > > Can you tell me what operating system you are seeing this on ?
> > > 
> > > This is on Ubuntu 18.04.2
> > > 
> > > > 
> > > > Also, can you confirm that you're using the stock unit files that 
> > > > libvirt
> > > > distributes, with no local customizations ?
> > > 
> > > As far as I'm aware there are no modifications to the unit file. I 
> > > produced
> > > the problem by just pulling libvirt 5.6.0 and running:
> > > 
> > >   ./autogen.sh --system
> > >   make
> > >   make install
> > >   service libvirtd start
> > 
> > Ok, I'll try to reproduce myself.
> > 
> > One other question - did you have the official Ubuntu libvirt packages
> > installed at the time you did "make install", or did you uninstall them
> > first ?
> 
> Initially, I had installed over the ubuntu libvirt packages. However, I
> suspected that something may have "lingered" from the distro packages causing
> the issue, but I was able to produce the issue on a fresh install with no
> ubuntu libvirt packages installed as well.

I think I understand what's happening now.

Libvirt creates the libvirtd.socket unit file using a path of

  /var/run/libvirt/libvirt-sock

But /var/run is a symlink to /run, and IIUC, systemd will (helpfully?)
change the socket path we specify to be /run/libvirt/libvirt-sock

When libvirtd receives the activation FDs it calls getsockname() to
find out the path associated with the socket and so sees
/run/libvirt/libvirt-sock, but libvirt was expecting to instead
see the path it had requested /var/run/libvirt/libvirt-sock

If this theory is correct, then you should be able to workaround the
problem by editting /etc/libvirt/libvirtd.conf and setting

  unix_sock_dir = "/run/libvirt"

Can you confirm it that works for you ?

I'll assume it will, and thus work on a real long term fix for the it.

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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 2/2] libxl: send lifecycle event on PMSuspend

2019-08-20 Thread Daniel Henrique Barboza




On 8/13/19 6:06 PM, Jim Fehlig wrote:

After a successful call to libxl_domain_suspend_only(), set domain
state to VIR_DOMAIN_PMSUSPENDED and send lifecycle event.

Signed-off-by: Jim Fehlig 
---


(pure code review, sadly I don't have access to a XEN env to test it)

Reviewed-by: Daniel Henrique Barboza 




  src/libxl/libxl_driver.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 2a9db026bb..d0396e4781 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1434,6 +1434,7 @@ libxlDomainPMSuspendForDuration(virDomainPtr dom,
  int ret = -1;
  libxlDriverPrivatePtr driver = dom->conn->privateData;
  libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+virObjectEventPtr event = NULL;
  
  virCheckFlags(0, -1);

  if (target != VIR_NODE_SUSPEND_TARGET_MEM) {
@@ -1474,6 +1475,10 @@ libxlDomainPMSuspendForDuration(virDomainPtr dom,
  goto endjob;
  }
  
+virDomainObjSetState(vm, VIR_DOMAIN_PMSUSPENDED, VIR_DOMAIN_PMSUSPENDED_UNKNOWN);

+event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_PMSUSPENDED,
+  
VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY);
+
  ret = 0;
  
   endjob:

@@ -1481,6 +1486,7 @@ libxlDomainPMSuspendForDuration(virDomainPtr dom,
  
   cleanup:

  virDomainObjEndAPI();
+virObjectEventStateQueue(driver->domainEventState, event);
  return ret;
  }
  #endif


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 1/2] Revert "libxl: send lifecycle event on suspend"

2019-08-20 Thread Daniel Henrique Barboza




On 8/13/19 6:06 PM, Jim Fehlig wrote:

A libxl event with shutdown reason LIBXL_SHUTDOWN_REASON_SUSPEND
is sent after a domain is successfully suspended, which could result
from suspending the domain to file (virDomainSave), suspending it to
socket (virDomainMigrate), or suspending it to memory
(virDomainPMSuspendForDuration). Commit d00c77ae changed the event
handler to always set domain state to VIR_DOMAIN_PMSUSPENDED when
LIBXL_SHUTDOWN_REASON_SUSPEND is received. The causes a persistent
domain to show state "pmsuspended" after a successful migrate or save
operation. Revert the commit and ignore the suspend event as before.

This reverts commit d00c77ae45c7d9fd90384f01cd8b04c54f501e96.

Signed-off-by: Jim Fehlig 
---


(pure code review, sadly I don't have access to a XEN env to test it)

Reviewed-by: Daniel Henrique Barboza 


  src/libxl/libxl_domain.c | 19 ---
  1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index b60511a266..4073bf8d46 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -559,17 +559,6 @@ libxlDomainShutdownThread(void *opaque)
  case VIR_DOMAIN_LIFECYCLE_ACTION_LAST:
  goto endjob;
  }
-} else if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND) {
-virDomainObjSetState(vm, VIR_DOMAIN_PMSUSPENDED,
- VIR_DOMAIN_PMSUSPENDED_UNKNOWN);
-
-dom_event = virDomainEventLifecycleNewFromObj(vm,
-   VIR_DOMAIN_EVENT_PMSUSPENDED,
-   
VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY);
-/*
- * Similar to the xl implementation, ignore SUSPEND.  Any actions 
needed
- * after calling libxl_domain_suspend() are handled by it's callers.
- */
  #ifdef LIBXL_HAVE_SOFT_RESET
  } else if (xl_reason == LIBXL_SHUTDOWN_REASON_SOFT_RESET) {
  libxlDomainObjPrivatePtr priv = vm->privateData;
@@ -669,6 +658,7 @@ void
  libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
  {
  libxlDriverPrivatePtr driver = data;
+libxl_shutdown_reason xl_reason = event->u.domain_shutdown.shutdown_reason;
  struct libxlShutdownThreadInfo *shutdown_info = NULL;
  virThread thread;
  libxlDriverConfigPtr cfg;
@@ -680,6 +670,13 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST 
libxl_event *event)
  goto error;
  }
  
+/*

+ * Similar to the xl implementation, ignore SUSPEND.  Any actions needed
+ * after calling libxl_domain_suspend() are handled by its callers.
+ */
+if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
+goto error;
+
  /*
   * Start a thread to handle shutdown.  We don't want to be tying up
   * libxl's event machinery by doing a potentially lengthy shutdown.


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [ocaml PATCH 1/3] Synchronize Virterror with libvirt 5.6.0

2019-08-20 Thread Pino Toscano
Signed-off-by: Pino Toscano 
---
 libvirt/libvirt.ml   | 8 
 libvirt/libvirt.mli  | 4 
 libvirt/libvirt_c_epilogue.c | 4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml
index d935bfc..03a5af8 100644
--- a/libvirt/libvirt.ml
+++ b/libvirt/libvirt.ml
@@ -251,6 +251,9 @@ struct
 | VIR_ERR_INVALID_DOMAIN_CHECKPOINT
 | VIR_ERR_NO_DOMAIN_CHECKPOINT
 | VIR_ERR_NO_DOMAIN_BACKUP
+| VIR_ERR_INVALID_NETWORK_PORT
+| VIR_ERR_NETWORK_PORT_EXIST
+| VIR_ERR_NO_NETWORK_PORT
 | VIR_ERR_UNKNOWN of int
 
   let string_of_code = function
@@ -359,6 +362,9 @@ struct
 | VIR_ERR_INVALID_DOMAIN_CHECKPOINT -> "VIR_ERR_INVALID_DOMAIN_CHECKPOINT"
 | VIR_ERR_NO_DOMAIN_CHECKPOINT -> "VIR_ERR_NO_DOMAIN_CHECKPOINT"
 | VIR_ERR_NO_DOMAIN_BACKUP -> "VIR_ERR_NO_DOMAIN_BACKUP"
+| VIR_ERR_INVALID_NETWORK_PORT -> "VIR_ERR_INVALID_NETWORK_PORT"
+| VIR_ERR_NETWORK_PORT_EXIST -> "VIR_ERR_NETWORK_PORT_EXIST"
+| VIR_ERR_NO_NETWORK_PORT -> "VIR_ERR_NO_NETWORK_PORT"
 | VIR_ERR_UNKNOWN i -> "VIR_ERR_" ^ string_of_int i
 
   type domain =
@@ -432,6 +438,7 @@ struct
 | VIR_FROM_RESCTRL
 | VIR_FROM_FIREWALLD
 | VIR_FROM_DOMAIN_CHECKPOINT
+| VIR_FROM_TPM
 | VIR_FROM_UNKNOWN of int
 
   let string_of_domain = function
@@ -505,6 +512,7 @@ struct
 | VIR_FROM_RESCTRL -> "VIR_FROM_RESCTRL"
 | VIR_FROM_FIREWALLD -> "VIR_FROM_FIREWALLD"
 | VIR_FROM_DOMAIN_CHECKPOINT -> "VIR_FROM_DOMAIN_CHECKPOINT"
+| VIR_FROM_TPM -> "VIR_FROM_TPM"
 | VIR_FROM_UNKNOWN i -> "VIR_FROM_" ^ string_of_int i
 
   type level =
diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli
index fc5a1fc..72e83f9 100644
--- a/libvirt/libvirt.mli
+++ b/libvirt/libvirt.mli
@@ -1481,6 +1481,9 @@ sig
 | VIR_ERR_INVALID_DOMAIN_CHECKPOINT
 | VIR_ERR_NO_DOMAIN_CHECKPOINT
 | VIR_ERR_NO_DOMAIN_BACKUP
+| VIR_ERR_INVALID_NETWORK_PORT
+| VIR_ERR_NETWORK_PORT_EXIST
+| VIR_ERR_NO_NETWORK_PORT
(* ^^ NB: If you add a variant you MUST edit
   libvirt_c_epilogue.c:MAX_VIR_* *)
 | VIR_ERR_UNKNOWN of int (** Other error, not handled with existing 
values. *)
@@ -1559,6 +1562,7 @@ sig
 | VIR_FROM_RESCTRL
 | VIR_FROM_FIREWALLD
 | VIR_FROM_DOMAIN_CHECKPOINT
+| VIR_FROM_TPM
(* ^^ NB: If you add a variant you MUST edit
   libvirt_c_epilogue.c: MAX_VIR_* *)
 | VIR_FROM_UNKNOWN of int (** Other domain, not handled with existing 
values. *)
diff --git a/libvirt/libvirt_c_epilogue.c b/libvirt/libvirt_c_epilogue.c
index 4d45629..37efc43 100644
--- a/libvirt/libvirt_c_epilogue.c
+++ b/libvirt/libvirt_c_epilogue.c
@@ -143,8 +143,8 @@ Val_virconnectcredential (const virConnectCredentialPtr 
cred)
  * to convert it into VIR_*_UNKNOWN (code).
  */
 
-#define MAX_VIR_CODE 104 /* VIR_ERR_NO_DOMAIN_BACKUP */
-#define MAX_VIR_DOMAIN 69 /* VIR_FROM_DOMAIN_CHECKPOINT */
+#define MAX_VIR_CODE 107 /* VIR_ERR_NO_NETWORK_PORT */
+#define MAX_VIR_DOMAIN 70 /* VIR_FROM_TPM */
 #define MAX_VIR_LEVEL VIR_ERR_ERROR
 
 static inline value
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [ocaml PATCH 0/3] Misc improvements

2019-08-20 Thread Pino Toscano
*** IMAGINE A BLURB HERE ***

Pino Toscano (3):
  Synchronize Virterror with libvirt 5.6.0
  Update config.guess and config.sub
  Fix shebang in perl scripts

 config.guess | 284 ---
 config.sub   |  69 +
 libvirt/generator.pl |   3 +-
 libvirt/libvirt.ml   |   8 +
 libvirt/libvirt.mli  |   4 +
 libvirt/libvirt_c_epilogue.c |   4 +-
 6 files changed, 282 insertions(+), 90 deletions(-)

-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [ocaml PATCH 2/3] Update config.guess and config.sub

2019-08-20 Thread Pino Toscano
Signed-off-by: Pino Toscano 
---
 config.guess | 284 +--
 config.sub   |  69 +++--
 2 files changed, 266 insertions(+), 87 deletions(-)

diff --git a/config.guess b/config.guess
index b33c9e8..97ad073 100755
--- a/config.guess
+++ b/config.guess
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2018 Free Software Foundation, Inc.
+#   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2018-08-29'
+timestamp='2019-07-24'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2018 Free Software Foundation, Inc.
+Copyright 1992-2019 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -96,8 +96,7 @@ fi
 
 tmp=
 # shellcheck disable=SC2172
-trap 'test -z "$tmp" || rm -fr "$tmp"' 1 2 13 15
-trap 'exitcode=$?; test -z "$tmp" || rm -fr "$tmp"; exit $exitcode' 0
+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
 
 set_cc_for_build() {
 : "${TMPDIR=/tmp}"
@@ -263,6 +262,9 @@ case 
"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
 *:SolidBSD:*:*)
echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
exit ;;
+*:OS108:*:*)
+   echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
+   exit ;;
 macppc:MirBSD:*:*)
echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
exit ;;
@@ -276,8 +278,8 @@ case 
"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo "$UNAME_MACHINE"-unknown-redox
exit ;;
 mips:OSF1:*.*)
-echo mips-dec-osf1
-exit ;;
+   echo mips-dec-osf1
+   exit ;;
 alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
@@ -392,15 +394,20 @@ case 
"$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;;
 i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-   UNAME_REL="`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
-   case `isainfo -b` in
-   32)
-   echo i386-pc-solaris2"$UNAME_REL"
-   ;;
-   64)
-   echo x86_64-pc-solaris2"$UNAME_REL"
-   ;;
-   esac
+   set_cc_for_build
+   SUN_ARCH=i386
+   # If there is a compiler, see if it is configured for 64-bit objects.
+   # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+   # This test works for both compilers.
+   if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+   if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+   grep IS_64BIT_ARCH >/dev/null
+   then
+   SUN_ARCH=x86_64
+   fi
+   fi
+   echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
exit ;;
 sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
@@ -890,7 +897,7 @@ EOF
echo "$UNAME_MACHINE"-pc-uwin
exit ;;
 amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
-   echo x86_64-unknown-cygwin
+   echo x86_64-pc-cygwin
exit ;;
 prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 
's/[^.]*//'`"
@@ -981,22 +988,50 @@ EOF
exit ;;
 mips:Linux:*:* | mips64:Linux:*:*)
set_cc_for_build
+   IS_GLIBC=0
+   test x"${LIBC}" = xgnu && IS_GLIBC=1
sed 's/^//' << EOF > "$dummy.c"
#undef CPU
-   #undef ${UNAME_MACHINE}
-   #undef ${UNAME_MACHINE}el
+   #undef mips
+   #undef mipsel
+   #undef mips64
+   #undef mips64el
+   #if ${IS_GLIBC} && defined(_ABI64)
+   LIBCABI=gnuabi64
+   #else
+   #if ${IS_GLIBC} && defined(_ABIN32)
+   LIBCABI=gnuabin32
+   #else
+   LIBCABI=${LIBC}
+   #endif
+   #endif
+
+   #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && 
__mips_isa_rev>=6
+   CPU=mipsisa64r6
+   #else
+   #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && 
__mips_isa_rev>=6
+   CPU=mipsisa32r6
+   #else
+   #if defined(__mips64)
+   CPU=mips64
+   #else
+   CPU=mips
+   #endif
+   #endif
+   #endif
+
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || 
defined(MIPSEL)
-   CPU=${UNAME_MACHINE}el
+   MIPS_ENDIAN=el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || 
defined(MIPSEB)
-   CPU=${UNAME_MACHINE}
+   MIPS_ENDIAN=
#else
-   CPU=
+   MIPS_ENDIAN=
#endif
#endif
 EOF
-   eval "`$CC_FOR_BUILD -E 

[libvirt] [ocaml PATCH 3/3] Fix shebang in perl scripts

2019-08-20 Thread Pino Toscano
Instead of hardcoding the location of perl (assuming it is installed in
/usr), use /usr/bin/env to run it, and thus picking it from $PATH.
This makes it possible to run these scripts also on installations with
perl in a different prefix than /usr.

Also, given that we want enable warnings on scripts, turn the -w
previously in shebang to explicit "use warnings;" in scripts which
didn't have it before.

Signed-off-by: Pino Toscano 
---
 libvirt/generator.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libvirt/generator.pl b/libvirt/generator.pl
index 490ef9a..e850500 100755
--- a/libvirt/generator.pl
+++ b/libvirt/generator.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # OCaml bindings for libvirt.
 # (C) Copyright 2007-2015 Richard W.M. Jones, Red Hat Inc.
@@ -26,6 +26,7 @@
 # Please read libvirt/README.
 
 use strict;
+use warnings;
 
 #--
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH v4 5/8] qemu_monitor: implement query-cpu-model-comparison

2019-08-20 Thread Jiri Denemark
On Wed, Jul 24, 2019 at 18:18:27 +0200, Boris Fiuczynski wrote:
> On 7/17/19 4:03 PM, Collin Walling wrote:
> > Interfaces with QEMU to compare CPU models. The command takes two
> > CPU models, A and B, that are given a model name and an optional list
> > of CPU features. Through the query-cpu-model-comparison command issued
> > via QMP, a result is produced that contains the comparison evaluation
> > string (identical, superset, subset, incompatible) as well as a list
> > of properties (aka CPU features) responsible for the subset or
> > superset result.
> > 
> > Signed-off-by: Collin Walling 
> > Reviewed-by: Daniel Henrique Barboza 
> > ---
> >   src/qemu/qemu_monitor.c  | 22 ++
> >   src/qemu/qemu_monitor.h  |  9 +
> >   src/qemu/qemu_monitor_json.c | 95 
> > 
> >   src/qemu/qemu_monitor_json.h | 10 +
> >   4 files changed, 136 insertions(+)
> > 
> > diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> > index 136d3e2..b16e149 100644
> > --- a/src/qemu/qemu_monitor.c
> > +++ b/src/qemu/qemu_monitor.c
> > @@ -3670,6 +3670,28 @@ qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
> >   }
> >   
> >   
> > +int
> > +qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
> > + const char *model_a_name,
> > + int model_a_nprops,
> > + virCPUFeatureDefPtr model_a_props,
> > + const char *model_b_name,
> > + int model_b_nprops,
> > + virCPUFeatureDefPtr model_b_props,
> > + qemuMonitorCPUModelInfoPtr *model_result)
> > +{
> > +VIR_DEBUG("model_a_name=%s model_a_nprops=%d model_b_name=%s 
> > model_b_nprops=%d",
> > +   model_a_name, model_a_nprops, model_b_name, model_b_nprops);
> > +
> > +QEMU_CHECK_MONITOR(mon);
> > +
> > +return qemuMonitorJSONGetCPUModelComparison(mon, model_a_name, 
> > model_a_nprops,
> > +model_a_props, 
> > model_b_name,
> > +model_b_nprops, 
> > model_b_props,
> > +model_result);
> > +}
> > +
> > +
> >   void
> >   qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info)
> >   {
> > diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
> > index 4ec74f1..f0cf70a 100644
> > --- a/src/qemu/qemu_monitor.h
> > +++ b/src/qemu/qemu_monitor.h
> > @@ -1093,6 +1093,15 @@ int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr 
> > mon,
> >  virCPUFeatureDefPtr model_b_props,
> >  qemuMonitorCPUModelInfoPtr 
> > *model_result);
> >   
> > +int qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
> > + const char *model_a_name,
> > + int model_a_nprops,
> > + virCPUFeatureDefPtr model_a_props,
> > + const char *model_b_name,
> > + int model_b_nprops,
> > + virCPUFeatureDefPtr model_b_props,
> > + qemuMonitorCPUModelInfoPtr 
> > *model_result);
> > +
> >   qemuMonitorCPUModelInfoPtr
> >   qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);
> >   
> > diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
> > index b599ee6..3c33c63 100644
> > --- a/src/qemu/qemu_monitor_json.c
> > +++ b/src/qemu/qemu_monitor_json.c
> > @@ -5875,6 +5875,101 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr 
> > mon,
> >   }
> >   
> >   
> > +static int
> > +qemuMonitorJSONParseCPUModelPropName(size_t pos ATTRIBUTE_UNUSED,
> > + virJSONValuePtr item,
> > + void *opaque)
> > +{
> > +if (!qemuMonitorJSONParseCPUModelProperty(virJSONValueGetString(item),
> > +  item, opaque))
> 
> This need to be changed into
> 
>  if (qemuMonitorJSONParseCPUModelProperty(virJSONValueGetString(item),
>   item, opaque) < 0)
> 
> > +return -1;
> > +
> > +virJSONValueFree(item);
> > +return 0;
> > +}
> > +
> > +
> > +int
> > +qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
> > + const char *model_a_name,
> > + int model_a_nprops,
> > + virCPUFeatureDefPtr model_a_props,
> > + const char *model_b_name,
> > + int model_b_nprops,
> > + virCPUFeatureDefPtr model_b_props,
> > + 

Re: [libvirt] [PATCH] conf: resctrl object is not properly handled

2019-08-20 Thread Michal Privoznik

On 8/20/19 3:18 PM, Daniel Henrique Barboza wrote:



On 8/20/19 7:06 AM, Wang Huaqiang wrote:

resctrl object stored in def->resctrls is shared by cachetune and
memorytune. The domain xml configuration is parsed firstly for
cachetune then memorytune, and the resctrl object will not be created
in parsing settings for memorytune once it found sharing exists.

But resctrl is improperly freed when sharing happens.

Signed-off-by: Wang Huaqiang 
---
  src/conf/domain_conf.c    | 12 +---
  tests/genericxml2xmlindata/memorytune.xml |  4 
  2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 617ccac..604e006 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19590,7 +19590,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
  VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
  ssize_t i = 0;
  int n;
-    int ret = -1;
  ctxt->node = node;
@@ -19632,14 +19631,13 @@ virDomainMemorytuneDefParse(virDomainDefPtr 
def,
  if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, 
flags)))

  return -1;
-    if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, 
resctrl) < 0)

-    goto cleanup;
+    if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, 
resctrl) < 0) {

+    virDomainResctrlDefFree(resctrl);
+    return -1;
+    }
  }
-    ret = 0;
- cleanup:
-    virDomainResctrlDefFree(resctrl);
-    return ret;
+    return 0;
  }


This could also be fixed by putting the free into a conditional:

if (resctrl)
     virDomainRescrtlDefFree(resctrl);


Not really. We want to free @resctrl only if it's a newly allocated 
struct. In case the pointer was obtained via virDomainResctrlVcpuMatch() 
then we must not free it (even though it is not NULL).


Reviewed-by: Michal Privoznik 

And pushed. Thanks for fixing this.

Michal

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2] tools: console: Relax stream EOF handling

2019-08-20 Thread Roman Bolshakov
On Mon, Aug 12, 2019 at 07:01:47PM -0300, Daniel Henrique Barboza wrote:
> The comment I have here is that you're changing virConsoleShutdown
> API for all callers, with this new boolean value 'needAbort', because of a
> scenario (virStreamRecv being called before) that happens only on
> virConsoleEventOnStream.
> 
> 
> This is what I wondered in the review of the previous version of this
> patch:
> 
> "Shouldn't we call virStreamFinish if got=0 and only report an error if
> virStreamFinish returns -1?"
> 
> I tried it out and it worked like a charm for me:
> 
> 
> diff --git a/tools/virsh-console.c b/tools/virsh-console.c
> index e16f841..998662c 100644
> --- a/tools/virsh-console.c
> +++ b/tools/virsh-console.c
> @@ -172,9 +172,12 @@ virConsoleEventOnStream(virStreamPtr st,
>  if (got == -2)
>  goto cleanup; /* blocking */
>  if (got <= 0) {
> -    if (got == 0)
> -    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -   _("console stream EOF"));
> +    if (got == 0) {
> +    got = virStreamFinish(st);
> +    if (got != 0)
> +    virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("console stream EOF"));
> +    }
> 
>  virConsoleShutdown(con);
>  goto cleanup;
> 
> 
> I didn't see any errors by calling virStreamFinish() before virStreamAbort()
> being called by virConsoleShutdown() right after (and by reading the code,
> it appears to be an OK usage), so I am skeptical about safeguarding the
> virStreamAbort() call with a boolean value like you're making here.
> 
> To be clear, I'm not saying your patch is wrong - and perhaps there is a
> case
> for that safeguard inside virConsoleShutdown like you're doing here. My
> point here is that if the code I shown above isn't breaking anything, I'd
> rather
> go for that.
> 
> 

Existing implementations of virStreamFinish and virStreamAbort for esx,
remote and fd streams behave exactly the same. They close the steam
using the same function. I haven't found any other difference. So if we
intend to minimize changes, we should use v1. It will work exactly the
same except it calls virStreamAbort to close the stream. I can also add
a check to print the error if virStreamAbort in virConsoleShutdown
fails.

However, if we want to be correct from documentation standpoint, we
should use v2.

Thanks,
Roman

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] conf: resctrl object is not properly handled

2019-08-20 Thread Daniel Henrique Barboza



On 8/20/19 7:06 AM, Wang Huaqiang wrote:

resctrl object stored in def->resctrls is shared by cachetune and
memorytune. The domain xml configuration is parsed firstly for
cachetune then memorytune, and the resctrl object will not be created
in parsing settings for memorytune once it found sharing exists.

But resctrl is improperly freed when sharing happens.

Signed-off-by: Wang Huaqiang 
---
  src/conf/domain_conf.c| 12 +---
  tests/genericxml2xmlindata/memorytune.xml |  4 
  2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 617ccac..604e006 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19590,7 +19590,6 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,
  VIR_AUTOUNREF(virResctrlAllocPtr) alloc = NULL;
  ssize_t i = 0;
  int n;
-int ret = -1;
  
  ctxt->node = node;
  
@@ -19632,14 +19631,13 @@ virDomainMemorytuneDefParse(virDomainDefPtr def,

  if (!(resctrl = virDomainResctrlNew(node, alloc, vcpus, flags)))
  return -1;
  
-if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0)

-goto cleanup;
+if (VIR_APPEND_ELEMENT(def->resctrls, def->nresctrls, resctrl) < 0) {
+virDomainResctrlDefFree(resctrl);
+return -1;
+}
  }
  
-ret = 0;

- cleanup:
-virDomainResctrlDefFree(resctrl);
-return ret;
+return 0;
  }


This could also be fixed by putting the free into a conditional:

if (resctrl)
    virDomainRescrtlDefFree(resctrl);


But I appreciate one less 'goto' jump to worry about.


Reviewed-by: Daniel Henrique Barboza 

  
  
diff --git a/tests/genericxml2xmlindata/memorytune.xml b/tests/genericxml2xmlindata/memorytune.xml

index ea03e22..7486b54 100644
--- a/tests/genericxml2xmlindata/memorytune.xml
+++ b/tests/genericxml2xmlindata/memorytune.xml
@@ -5,6 +5,10 @@
219136
4

+
+  
+  
+
  




--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 07/19] qemu_command: switch to VIR_AUTOCLEAN for virBuffer

2019-08-20 Thread Ján Tomko
Simplify the code by annotating all the temporary virBuffers
with VIR_AUTOCLEAN.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 194 ++--
 1 file changed, 67 insertions(+), 127 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 60e00042c7..94a6ad546e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -205,7 +205,7 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
 int ret = -1;
 char *alias = NULL;
 char *path = NULL;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
 /* If the -object secret does not exist, then just return. This just
  * means the domain won't be able to use a secret master key and is
@@ -235,7 +235,6 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
 ret = 0;
 
  cleanup:
-virBufferFreeAndReset();
 VIR_FREE(alias);
 VIR_FREE(path);
 return ret;
@@ -737,7 +736,7 @@ static int
 qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
  qemuDomainSecretInfoPtr secinfo)
 {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 int ret = -1;
 virJSONValuePtr props = NULL;
 
@@ -753,7 +752,6 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
 ret  = 0;
 
  cleanup:
-virBufferFreeAndReset();
 virJSONValueFree(props);
 return ret;
 }
@@ -935,7 +933,7 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
 const char *alias,
 virQEMUCapsPtr qemuCaps)
 {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 int ret = -1;
 virJSONValuePtr props = NULL;
 
@@ -952,7 +950,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
 ret = 0;
 
  cleanup:
-virBufferFreeAndReset();
 virJSONValueFree(props);
 return ret;
 }
@@ -988,7 +985,7 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
  qemuDomainSecretInfoPtr secinfo)
 {
 char *ret = NULL;
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 size_t i;
 
 switch ((virStorageNetProtocol) src->protocol) {
@@ -1141,7 +1138,6 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
 }
 
  cleanup:
-virBufferFreeAndReset();
 
 return ret;
 }
@@ -1838,7 +1834,7 @@ static char *
 qemuBuildDriveStr(virDomainDiskDefPtr disk,
   virQEMUCapsPtr qemuCaps)
 {
-virBuffer opt = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) opt = VIR_BUFFER_INITIALIZER;
 int detect_zeroes = virDomainDiskGetDetectZeroesMode(disk->discard,
  disk->detect_zeroes);
 
@@ -1922,7 +1918,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
 return virBufferContentAndReset();
 
  error:
-virBufferFreeAndReset();
 return NULL;
 }
 
@@ -2005,7 +2000,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
unsigned int bootindex,
virQEMUCapsPtr qemuCaps)
 {
-virBuffer opt = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) opt = VIR_BUFFER_INITIALIZER;
 const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
 const char *contAlias;
 char *backendAlias = NULL;
@@ -2343,14 +2338,13 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
 
  error:
 VIR_FREE(backendAlias);
-virBufferFreeAndReset();
 return NULL;
 }
 
 char *
 qemuBuildZPCIDevStr(virDomainDeviceInfoPtr dev)
 {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
 virBufferAsprintf(,
   "zpci,uid=%u,fid=%u,target=%s,id=zpci%u",
@@ -2359,10 +2353,8 @@ qemuBuildZPCIDevStr(virDomainDeviceInfoPtr dev)
   dev->alias,
   dev->addr.pci.zpci.uid);
 
-if (virBufferCheckError() < 0) {
-virBufferFreeAndReset();
+if (virBufferCheckError() < 0)
 return NULL;
-}
 
 return virBufferContentAndReset();
 }
@@ -2405,7 +2397,7 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr 
cmd,
 virQEMUCapsPtr qemuCaps,
 unsigned int bootFloppy)
 {
-virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
+VIR_AUTOCLEAN(virBuffer) fdc_opts = VIR_BUFFER_INITIALIZER;
 bool explicitfdc = qemuDomainNeedsFDC(def);
 bool hasfloppy = false;
 unsigned int bootindex;
@@ -2485,7 +2477,6 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr 
cmd,
 VIR_FREE(backendAlias);
 VIR_FREE(backendStr);
 VIR_FREE(bootindexStr);
-virBufferFreeAndReset(_opts);
 return ret;
 }
 
@@ -2494,15 +2485,13 @@ static int
 qemuBuildObjectCommandline(virCommandPtr cmd,
virJSONValuePtr objProps)
 {
-

[libvirt] [PATCH 19/19] qemuBuildCommandLine: remove unnecessary error label

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 101 +++-
 1 file changed, 49 insertions(+), 52 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 82e2a451c2..8cc8f82aab 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10245,7 +10245,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
   qemuCaps, migrateURI, snapshot, vmop);
 
 if (qemuBuildCommandLineValidate(driver, def) < 0)
-goto error;
+return NULL;
 
 cmd = virCommandNew(def->emulator);
 
@@ -10269,57 +10269,57 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
 }
 
 if (qemuBuildNameCommandLine(cmd, cfg, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (!standalone)
 virCommandAddArg(cmd, "-S"); /* freeze CPU */
 
 if (qemuBuildMasterKeyCommandLine(cmd, priv) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildManagedPRCommandLine(cmd, def, priv) < 0)
-goto error;
+return NULL;
 
 if (enableFips)
 virCommandAddArg(cmd, "-enable-fips");
 
 if (qemuBuildMachineCommandLine(cmd, cfg, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 qemuBuildTSEGCommandLine(cmd, def);
 
 if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 qemuBuildDomainLoaderCommandLine(cmd, def);
 
 if (!migrateURI && !snapshot && qemuDomainAlignMemorySizes(def) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildMemCommandLine(cmd, cfg, def, qemuCaps, priv) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildSmpCommandLine(cmd, def) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildIOThreadCommandLine(cmd, def) < 0)
-goto error;
+return NULL;
 
 if (virDomainNumaGetNodeCount(def->numa) &&
 qemuBuildNumaArgStr(cfg, def, cmd, priv) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildMemoryDeviceCommandLine(cmd, cfg, def, priv) < 0)
-goto error;
+return NULL;
 
 virUUIDFormat(def->uuid, uuid);
 virCommandAddArgList(cmd, "-uuid", uuid, NULL);
 
 if (qemuBuildSmbiosCommandLine(cmd, driver, def) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildVMGenIDCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 /*
  * NB, -nographic *MUST* come before any serial, or monitor
@@ -10343,110 +10343,110 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
 virCommandAddArg(cmd, "-nodefaults");
 
 if (qemuBuildSgaCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildMonitorCommandLine(logManager, secManager, cmd, cfg, def, 
priv) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildClockCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildPMCommandLine(cmd, def, priv) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildBootCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildIOMMUCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildGlobalControllerCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildControllersCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildHubCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildControllersByTypeCommandLine(cmd, def, qemuCaps,
   VIR_DOMAIN_CONTROLLER_TYPE_CCID) 
< 0)
-goto error;
+return NULL;
 
 if (qemuBuildDisksCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildFilesystemCommandLine(cmd, def, qemuCaps) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildNetCommandLine(driver, logManager, secManager, cmd, def,
 qemuCaps, vmop, standalone,
 nnicindexes, nicindexes, ) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildSmartcardCommandLine(logManager, secManager, cmd, cfg, def, 
qemuCaps,
   chardevStdioLogd) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildSerialCommandLine(logManager, secManager, cmd, cfg, def, 
qemuCaps,
chardevStdioLogd) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildParallelsCommandLine(logManager, secManager, cmd, cfg, def, 
qemuCaps,
   chardevStdioLogd) < 0)
-goto error;
+return NULL;
 
 if (qemuBuildChannelsCommandLine(logManager, secManager, cmd, cfg, def, 
qemuCaps,
  chardevStdioLogd) < 0)
-

[libvirt] [PATCH 14/19] qemuBuildShmemCommandLine: add chardev variable

2019-08-20 Thread Ján Tomko
That way devstr will only be used for the device string.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cc589a70b2..6557643dbe 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9197,6 +9197,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
 VIR_AUTOPTR(virJSONValue) memProps = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 char *devstr = NULL;
+VIR_AUTOFREE(char *) chardev = NULL;
 int rc;
 unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
 QEMU_BUILD_CHARDEV_UNIX_FD_PASS;
@@ -9267,16 +9268,15 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
 VIR_FREE(devstr);
 
 if (shmem->server.enabled) {
-devstr = qemuBuildChrChardevStr(logManager, secManager,
+chardev = qemuBuildChrChardevStr(logManager, secManager,
 cmd, cfg, def,
 >server.chr,
 shmem->info.alias, qemuCaps,
 cdevflags);
-if (!devstr)
+if (!chardev)
 return -1;
 
-virCommandAddArgList(cmd, "-chardev", devstr, NULL);
-VIR_FREE(devstr);
+virCommandAddArgList(cmd, "-chardev", chardev, NULL);
 }
 
 return 0;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 08/19] qemu_command: use VIR_AUTOPTR for virJSONValue

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 30 ++
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 94a6ad546e..b5448a074f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -738,7 +738,7 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
 {
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 int ret = -1;
-virJSONValuePtr props = NULL;
+VIR_AUTOPTR(virJSONValue) props = NULL;
 
 if (qemuBuildSecretInfoProps(secinfo, ) < 0)
 return -1;
@@ -752,7 +752,6 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
 ret  = 0;
 
  cleanup:
-virJSONValueFree(props);
 return ret;
 }
 
@@ -935,7 +934,7 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
 {
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 int ret = -1;
-virJSONValuePtr props = NULL;
+VIR_AUTOPTR(virJSONValue) props = NULL;
 
 if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias,
  certEncSecretAlias, qemuCaps, ) < 0)
@@ -950,7 +949,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
 ret = 0;
 
  cleanup:
-virJSONValueFree(props);
 return ret;
 }
 
@@ -1641,7 +1639,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 qemuDomainStorageSourcePrivatePtr srcpriv = 
QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(disk->src);
 qemuDomainSecretInfoPtr secinfo = NULL;
 qemuDomainSecretInfoPtr encinfo = NULL;
-virJSONValuePtr srcprops = NULL;
+VIR_AUTOPTR(virJSONValue) srcprops = NULL;
 char *source = NULL;
 bool rawluks = false;
 int ret = -1;
@@ -1729,7 +1727,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 
  cleanup:
 VIR_FREE(source);
-virJSONValueFree(srcprops);
 return ret;
 }
 
@@ -3407,7 +3404,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
 bool prealloc = false;
 virBitmapPtr nodemask = NULL;
 int ret = -1;
-virJSONValuePtr props = NULL;
+VIR_AUTOPTR(virJSONValue) props = NULL;
 bool nodeSpecified = virDomainNumatuneNodeSpecified(def->numa, 
mem->targetNode);
 unsigned long long pagesize = mem->pagesize;
 bool needHugepage = !!pagesize;
@@ -3651,7 +3648,6 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
 ret = -1;
 
  cleanup:
-virJSONValueFree(props);
 VIR_FREE(memPath);
 return ret;
 }
@@ -3664,7 +3660,7 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
   qemuDomainObjPrivatePtr priv,
   virBufferPtr buf)
 {
-virJSONValuePtr props = NULL;
+VIR_AUTOPTR(virJSONValue) props = NULL;
 char *alias = NULL;
 int ret = -1;
 int rc;
@@ -3690,7 +3686,6 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
 
  cleanup:
 VIR_FREE(alias);
-virJSONValueFree(props);
 
 return ret;
 }
@@ -3703,7 +3698,7 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
   virQEMUDriverConfigPtr cfg,
   qemuDomainObjPrivatePtr priv)
 {
-virJSONValuePtr props = NULL;
+VIR_AUTOPTR(virJSONValue) props = NULL;
 char *alias = NULL;
 int ret = -1;
 
@@ -3727,7 +3722,6 @@ qemuBuildMemoryDimmBackendStr(virBufferPtr buf,
 
  cleanup:
 VIR_FREE(alias);
-virJSONValueFree(props);
 
 return ret;
 }
@@ -5050,7 +5044,7 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr 
dev,
 char *ret = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 char *netsource = NULL;
-virJSONValuePtr srcprops = NULL;
+VIR_AUTOPTR(virJSONValue) srcprops = NULL;
 virDomainHostdevSubsysSCSIPtr scsisrc = >source.subsys.u.scsi;
 virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = >u.iscsi;
 qemuDomainStorageSourcePrivatePtr srcPriv =
@@ -5079,7 +5073,6 @@ qemuBuildSCSIiSCSIHostdevDrvStr(virDomainHostdevDefPtr 
dev,
 
  cleanup:
 VIR_FREE(netsource);
-virJSONValueFree(srcprops);
 return ret;
 }
 
@@ -6080,7 +6073,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
 size_t i;
 
 for (i = 0; i < def->nrngs; i++) {
-virJSONValuePtr props;
+VIR_AUTOPTR(virJSONValue) props = NULL;
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 virDomainRNGDefPtr rng = def->rngs[i];
 char *tmp;
@@ -6107,7 +6100,6 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
 return -1;
 
 rc = virQEMUBuildObjectCommandlineFromJSON(, props);
-virJSONValueFree(props);
 
 if (rc < 0)
 return -1;
@@ -9272,7 +9264,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
   virQEMUCapsPtr qemuCaps,
   bool chardevStdioLogd)
 {
-virJSONValuePtr memProps = NULL;
+VIR_AUTOPTR(virJSONValue) memProps = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 char *devstr = NULL;

[libvirt] [PATCH 01/19] qemuBuildSerialChrDeviceStr: rename cmd to buf

2019-08-20 Thread Ján Tomko
We usually use 'cmd' for a virCommand(Ptr) variable.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e3f4ef624b..98516d2627 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10867,7 +10867,7 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
 virDomainChrDefPtr serial,
 virQEMUCapsPtr qemuCaps)
 {
-virBuffer cmd = VIR_BUFFER_INITIALIZER;
+virBuffer buf = VIR_BUFFER_INITIALIZER;
 virQEMUCapsFlags caps;
 
 switch ((virDomainChrSerialTargetModel) serial->targetModel) {
@@ -10901,21 +10901,21 @@ qemuBuildSerialChrDeviceStr(char **deviceStr,
 goto error;
 }
 
-virBufferAsprintf(, "%s,chardev=char%s,id=%s",
+virBufferAsprintf(, "%s,chardev=char%s,id=%s",
   
virDomainChrSerialTargetModelTypeToString(serial->targetModel),
   serial->info.alias, serial->info.alias);
 
-if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
+if (qemuBuildDeviceAddressStr(, def, >info, qemuCaps) < 0)
 goto error;
 
-if (virBufferCheckError() < 0)
+if (virBufferCheckError() < 0)
 goto error;
 
-*deviceStr = virBufferContentAndReset();
+*deviceStr = virBufferContentAndReset();
 return 0;
 
  error:
-virBufferFreeAndReset();
+virBufferFreeAndReset();
 return -1;
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 13/19] qemuBuildSmpCommandLine: use virCommandAddArgBuffer directly

2019-08-20 Thread Ján Tomko
Instead of getting the string then passing it to virCommand.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 67de0fc35e..cc589a70b2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7606,7 +7606,6 @@ static int
 qemuBuildSmpCommandLine(virCommandPtr cmd,
 virDomainDefPtr def)
 {
-char *smp = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 unsigned int maxvcpus = virDomainDefGetVcpusMax(def);
 unsigned int nvcpus = 0;
@@ -7642,10 +7641,7 @@ qemuBuildSmpCommandLine(virCommandPtr cmd,
 if (virBufferCheckError() < 0)
 return -1;
 
-smp = virBufferContentAndReset();
-virCommandAddArg(cmd, smp);
-VIR_FREE(smp);
-
+virCommandAddArgBuffer(cmd, );
 return 0;
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 05/19] qemu: move TPM vaildation to qemuDomainDeviceDefValidateTPM

2019-08-20 Thread Ján Tomko
Simplify the command line formatter by complicating the validator.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 15 +--
 src/qemu/qemu_domain.c  | 29 +++--
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5e05916b23..3a4acb3166 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10004,7 +10004,6 @@ qemuBuildTPMOpenBackendFDs(const char *tpmdev,
 static char *
 qemuBuildTPMBackendStr(const virDomainDef *def,
virCommandPtr cmd,
-   virQEMUCapsPtr qemuCaps,
int *tpmfd,
int *cancelfd,
char **chardev)
@@ -10033,9 +10032,6 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
 
 switch (tpm->type) {
 case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH))
-goto no_support;
-
 tpmdev = tpm->data.passthrough.source.data.file.path;
 if (!(cancel_path = virTPMCreateCancelPath(tpmdev)))
 goto error;
@@ -10062,9 +10058,6 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
 
 break;
 case VIR_DOMAIN_TPM_TYPE_EMULATOR:
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR))
-goto no_support;
-
 virBufferAddLit(, ",chardev=chrtpm");
 
 if (virAsprintf(chardev, "socket,id=chrtpm,path=%s",
@@ -10081,12 +10074,6 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
 
 return virBufferContentAndReset();
 
- no_support:
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("The QEMU executable %s does not support TPM "
- "backend type %s"),
-   def->emulator, type);
-
  error:
 VIR_FREE(devset);
 VIR_FREE(cancel_path);
@@ -10110,7 +10097,7 @@ qemuBuildTPMCommandLine(virCommandPtr cmd,
 if (!def->tpm)
 return 0;
 
-if (!(optstr = qemuBuildTPMBackendStr(def, cmd, qemuCaps,
+if (!(optstr = qemuBuildTPMBackendStr(def, cmd,
   , ,
   )))
 return -1;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a06672333c..e34d03191d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -6384,7 +6384,8 @@ qemuDomainDeviceDefValidateVsock(const virDomainVsockDef 
*vsock,
 
 static int
 qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
-   const virDomainDef *def ATTRIBUTE_UNUSED)
+   const virDomainDef *def,
+   virQEMUCapsPtr qemuCaps)
 {
 /* TPM 1.2 and 2 are not compatible, so we choose a specific version here 
*/
 if (tpm->version == VIR_DOMAIN_TPM_VERSION_DEFAULT)
@@ -6406,7 +6407,31 @@ qemuDomainDeviceDefValidateTPM(virDomainTPMDef *tpm,
 case VIR_DOMAIN_TPM_VERSION_LAST:
 break;
 }
+
+switch (tpm->type) {
+case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH))
+goto no_support;
+break;
+
+case VIR_DOMAIN_TPM_TYPE_EMULATOR:
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_EMULATOR))
+goto no_support;
+
+break;
+case VIR_DOMAIN_TPM_TYPE_LAST:
+break;
+}
+
 return 0;
+
+ no_support:
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("The QEMU executable %s does not support TPM "
+ "backend type %s"),
+   def->emulator,
+   virDomainTPMBackendTypeToString(tpm->type));
+return -1;
 }
 
 
@@ -6847,7 +6872,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
 break;
 
 case VIR_DOMAIN_DEVICE_TPM:
-ret = qemuDomainDeviceDefValidateTPM(dev->data.tpm, def);
+ret = qemuDomainDeviceDefValidateTPM(dev->data.tpm, def, qemuCaps);
 break;
 
 case VIR_DOMAIN_DEVICE_GRAPHICS:
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 17/19] qemu_command: remove unnecessary labels and ret variables

2019-08-20 Thread Ján Tomko
The recent cleanups allow us to clean up the code a bit.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 741 +++-
 1 file changed, 274 insertions(+), 467 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a4df133ca0..0e9bd77f62 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -202,7 +202,6 @@ static int
 qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
   qemuDomainObjPrivatePtr priv)
 {
-int ret = -1;
 VIR_AUTOFREE(char *) alias = NULL;
 VIR_AUTOFREE(char *) path = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
@@ -225,17 +224,14 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
  * existence of socket files before using.
  */
 if (!(path = qemuDomainGetMasterKeyFilePath(priv->libDir)))
-goto cleanup;
+return -1;
 
 virCommandAddArg(cmd, "-object");
 virBufferAsprintf(, "secret,id=%s,format=raw,file=", alias);
 virQEMUBuildBufferEscapeComma(, path);
 virCommandAddArgBuffer(cmd, );
 
-ret = 0;
-
- cleanup:
-return ret;
+return 0;
 }
 
 
@@ -298,7 +294,6 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
   virDomainDeviceInfoPtr info,
   virQEMUCapsPtr qemuCaps)
 {
-int ret = -1;
 VIR_AUTOFREE(char *) devStr = NULL;
 const char *contAlias = NULL;
 bool contIsPHB = false;
@@ -308,7 +303,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
 size_t i;
 
 if (!(devStr = virPCIDeviceAddressAsString(>addr.pci)))
-goto cleanup;
+return -1;
 for (i = 0; i < domainDef->ncontrollers; i++) {
 virDomainControllerDefPtr cont = domainDef->controllers[i];
 
@@ -324,7 +319,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
  "controller with index %u required "
  "for device at address %s"),
info->addr.pci.bus, devStr);
-goto cleanup;
+return -1;
 }
 
 if (virDomainDeviceAliasIsUserAlias(contAlias)) {
@@ -350,7 +345,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
  "controller with index %u required "
  "for device at address %s"),
info->addr.pci.bus, devStr);
-goto cleanup;
+return -1;
 }
 
 if (contIsPHB && contTargetIndex > 0) {
@@ -376,7 +371,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
 if (!(contAlias = virDomainControllerAliasFind(domainDef,

VIR_DOMAIN_CONTROLLER_TYPE_USB,
info->addr.usb.bus)))
-goto cleanup;
+return -1;
 virBufferAsprintf(buf, ",bus=%s.0", contAlias);
 if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) {
 virBufferAddLit(buf, ",port=");
@@ -397,9 +392,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
   info->addr.isa.irq);
 }
 
-ret = 0;
- cleanup:
-return ret;
+return 0;
 }
 
 
@@ -733,22 +726,18 @@ qemuBuildObjectSecretCommandLine(virCommandPtr cmd,
  qemuDomainSecretInfoPtr secinfo)
 {
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-int ret = -1;
 VIR_AUTOPTR(virJSONValue) props = NULL;
 
 if (qemuBuildSecretInfoProps(secinfo, ) < 0)
 return -1;
 
 if (virQEMUBuildObjectCommandlineFromJSON(, props) < 0)
-goto cleanup;
+return -1;
 
 virCommandAddArg(cmd, "-object");
 virCommandAddArgBuffer(cmd, );
 
-ret  = 0;
-
- cleanup:
-return ret;
+return 0;
 }
 
 
@@ -929,23 +918,19 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
 virQEMUCapsPtr qemuCaps)
 {
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-int ret = -1;
 VIR_AUTOPTR(virJSONValue) props = NULL;
 
 if (qemuBuildTLSx509BackendProps(tlspath, isListen, verifypeer, alias,
  certEncSecretAlias, qemuCaps, ) < 0)
-goto cleanup;
+return -1;
 
 if (virQEMUBuildObjectCommandlineFromJSON(, props) < 0)
-goto cleanup;
+return -1;
 
 virCommandAddArg(cmd, "-object");
 virCommandAddArgBuffer(cmd, );
 
-ret = 0;
-
- cleanup:
-return ret;
+return 0;
 }
 
 
@@ -954,22 +939,18 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
  qemuDomainSecretInfoPtr secinfo)
 {
 VIR_AUTOPTR(virURI) uri = NULL;
-char *ret = NULL;
 
 if (!(uri = qemuBlockStorageSourceGetURI(src)))
-goto cleanup;
+return NULL;
 
 if (src->hosts->socket &&
 virAsprintf(>query, "socket=%s", src->hosts->socket) < 0)
-goto cleanup;
+   

[libvirt] [PATCH 00/19] qemu_command: use more of VIR_AUTO*

2019-08-20 Thread Ján Tomko
Ján Tomko (19):
  qemuBuildSerialChrDeviceStr: rename cmd to buf
  qemuBuildNumaArgStr: split variable declarations
  qemuBuildHotpluggableCPUProps: use VIR_RETURN_PTR
  qemuxml2xmltest: switch TPM tests to use latest caps
  qemu: move TPM vaildation to qemuDomainDeviceDefValidateTPM
  qemuBuildTPMBackendStr: format device and alias separately
  qemu_command: switch to VIR_AUTOCLEAN for virBuffer
  qemu_command: use VIR_AUTOPTR for virJSONValue
  qemu_command: use VIR_AUTOFREE for variables used once
  qemuBuildNetworkDriveURI: use VIR_AUTOPTR for virURI
  qemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE
  qemuBuildRNGCommandLine: use VIR_AUTOFREE
  qemuBuildSmpCommandLine: use virCommandAddArgBuffer directly
  qemuBuildShmemCommandLine: add chardev variable
  qemuBuildShmemCommandLine: use VIR_AUTOFREE for devstr
  qemu_command: use VIR_AUTOUNREF
  qemu_command: remove unnecessary labels and ret variables
  qemuBuildCommandLine: use VIR_AUTO*
  qemuBuildCommandLine: remove unnecessary error label

 src/qemu/qemu_command.c   | 1388 ++---
 src/qemu/qemu_domain.c|   29 +-
 ...> tpm-emulator-tpm2-enc.x86_64-latest.xml} |4 +-
 ...ml => tpm-emulator-tpm2.x86_64-latest.xml} |4 +-
 ...tor.xml => tpm-emulator.x86_64-latest.xml} |4 +-
 ... => tpm-passthrough-crb.x86_64-latest.xml} |4 +-
 xml => tpm-passthrough.x86_64-latest.xml} |4 +-
 tests/qemuxml2xmltest.c   |   10 +-
 8 files changed, 545 insertions(+), 902 deletions(-)
 rename tests/qemuxml2xmloutdata/{tpm-emulator-tpm2-enc.xml => 
tpm-emulator-tpm2-enc.x86_64-latest.xml} (89%)
 rename tests/qemuxml2xmloutdata/{tpm-emulator-tpm2.xml => 
tpm-emulator-tpm2.x86_64-latest.xml} (89%)
 rename tests/qemuxml2xmloutdata/{tpm-emulator.xml => 
tpm-emulator.x86_64-latest.xml} (89%)
 rename tests/qemuxml2xmloutdata/{tpm-passthrough-crb.xml => 
tpm-passthrough-crb.x86_64-latest.xml} (89%)
 rename tests/qemuxml2xmloutdata/{tpm-passthrough.xml => 
tpm-passthrough.x86_64-latest.xml} (89%)

-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 16/19] qemu_command: use VIR_AUTOUNREF

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index e47f30876e..a4df133ca0 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6900,7 +6900,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
 {
 int ret = -1;
 size_t i;
-virCapsPtr caps = NULL;
+VIR_AUTOUNREF(virCapsPtr) caps = NULL;
 virCPUDefPtr cpu = def->cpu;
 
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -6978,7 +6978,6 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
 
 ret = 0;
  cleanup:
-virObjectUnref(caps);
 return ret;
 }
 
@@ -8486,7 +8485,7 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
   virQEMUCapsPtr qemuCaps,
   char **chardev)
 {
-virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
 int ret = -1;
 
 switch ((virDomainChrType)net->data.vhostuser->type) {
@@ -8519,7 +8518,6 @@ qemuInterfaceVhostuserConnect(virQEMUDriverPtr driver,
 
 ret = 0;
  cleanup:
-virObjectUnref(cfg);
 return ret;
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 15/19] qemuBuildShmemCommandLine: use VIR_AUTOFREE for devstr

2019-08-20 Thread Ján Tomko
Now that it's only used once.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6557643dbe..e47f30876e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9196,7 +9196,7 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
 {
 VIR_AUTOPTR(virJSONValue) memProps = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-char *devstr = NULL;
+VIR_AUTOFREE(char *) devstr = NULL;
 VIR_AUTOFREE(char *) chardev = NULL;
 int rc;
 unsigned int cdevflags = QEMU_BUILD_CHARDEV_TCP_NOWAIT |
@@ -9259,13 +9259,10 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager,
 if (!devstr)
 return -1;
 
-if (qemuCommandAddExtDevice(cmd, >info) < 0) {
-VIR_FREE(devstr);
+if (qemuCommandAddExtDevice(cmd, >info) < 0)
 return -1;
-}
 
 virCommandAddArgList(cmd, "-device", devstr, NULL);
-VIR_FREE(devstr);
 
 if (shmem->server.enabled) {
 chardev = qemuBuildChrChardevStr(logManager, secManager,
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 18/19] qemuBuildCommandLine: use VIR_AUTO*

2019-08-20 Thread Ján Tomko
Prepare this big function for a cleanup.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0e9bd77f62..82e2a451c2 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10231,8 +10231,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
 {
 size_t i;
 char uuid[VIR_UUID_STRING_BUFLEN];
-virCommandPtr cmd = NULL;
-virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+VIR_AUTOPTR(virCommand) cmd = NULL;
+VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
 unsigned int bootHostdevNet = 0;
 qemuDomainObjPrivatePtr priv = vm->privateData;
 virDomainDefPtr def = vm->def;
@@ -10487,12 +10487,9 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
 cfg->logTimestamp)
 virCommandAddArgList(cmd, "-msg", "timestamp=on", NULL);
 
-virObjectUnref(cfg);
-return cmd;
+VIR_RETURN_PTR(cmd);
 
  error:
-virObjectUnref(cfg);
-virCommandFree(cmd);
 return NULL;
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 11/19] qemuBuildControllersByTypeCommandLine: use VIR_AUTOFREE

2019-08-20 Thread Ján Tomko
Reduce the scope of the variable to get it freed for every controller
processed.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index db8584243c..298a1c3fea 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3198,12 +3198,12 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
   virQEMUCapsPtr qemuCaps,
   virDomainControllerType type)
 {
-char *devstr = NULL;
 int ret = -1;
 size_t i;
 
 for (i = 0; i < def->ncontrollers; i++) {
 virDomainControllerDefPtr cont = def->controllers[i];
+VIR_AUTOFREE(char *) devstr = NULL;
 
 if (cont->type != type)
 continue;
@@ -3236,7 +3236,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
 continue;
 }
 
-VIR_FREE(devstr);
 if (qemuBuildControllerDevStr(def, cont, qemuCaps, ) < 0)
 goto cleanup;
 
@@ -3251,7 +3250,6 @@ qemuBuildControllersByTypeCommandLine(virCommandPtr cmd,
 
 ret = 0;
  cleanup:
-VIR_FREE(devstr);
 return ret;
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 12/19] qemuBuildRNGCommandLine: use VIR_AUTOFREE

2019-08-20 Thread Ján Tomko
Use separate variables for the chardev and the device.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 16 +++-
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 298a1c3fea..67de0fc35e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6022,7 +6022,8 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
 VIR_AUTOPTR(virJSONValue) props = NULL;
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 virDomainRNGDefPtr rng = def->rngs[i];
-char *tmp;
+VIR_AUTOFREE(char *) chardev = NULL;
+VIR_AUTOFREE(char *) devstr = NULL;
 int rc;
 
 if (!rng->info.alias) {
@@ -6033,14 +6034,12 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
 
 /* possibly add character device for backend */
 if (qemuBuildRNGBackendChrdevStr(logManager, secManager, cmd, cfg, def,
- rng, qemuCaps, ,
+ rng, qemuCaps, ,
  chardevStdioLogd) < 0)
 return -1;
 
-if (tmp) {
-virCommandAddArgList(cmd, "-chardev", tmp, NULL);
-VIR_FREE(tmp);
-}
+if (chardev)
+virCommandAddArgList(cmd, "-chardev", chardev, NULL);
 
 if (qemuBuildRNGBackendProps(rng, qemuCaps, ) < 0)
 return -1;
@@ -6057,10 +6056,9 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
 if (qemuCommandAddExtDevice(cmd, >info) < 0)
 return -1;
 
-if (!(tmp = qemuBuildRNGDevStr(def, rng, qemuCaps)))
+if (!(devstr = qemuBuildRNGDevStr(def, rng, qemuCaps)))
 return -1;
-virCommandAddArgList(cmd, "-device", tmp, NULL);
-VIR_FREE(tmp);
+virCommandAddArgList(cmd, "-device", devstr, NULL);
 }
 
 return 0;
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 09/19] qemu_command: use VIR_AUTOFREE for variables used once

2019-08-20 Thread Ján Tomko
Remove the VIR_FREE's from the cleanup sections.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 207 +---
 1 file changed, 66 insertions(+), 141 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b5448a074f..fe06867a88 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -203,8 +203,8 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
   qemuDomainObjPrivatePtr priv)
 {
 int ret = -1;
-char *alias = NULL;
-char *path = NULL;
+VIR_AUTOFREE(char *) alias = NULL;
+VIR_AUTOFREE(char *) path = NULL;
 VIR_AUTOCLEAN(virBuffer) buf = VIR_BUFFER_INITIALIZER;
 
 /* If the -object secret does not exist, then just return. This just
@@ -235,8 +235,6 @@ qemuBuildMasterKeyCommandLine(virCommandPtr cmd,
 ret = 0;
 
  cleanup:
-VIR_FREE(alias);
-VIR_FREE(path);
 return ret;
 }
 
@@ -301,7 +299,7 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
   virQEMUCapsPtr qemuCaps)
 {
 int ret = -1;
-char *devStr = NULL;
+VIR_AUTOFREE(char *) devStr = NULL;
 const char *contAlias = NULL;
 bool contIsPHB = false;
 int contTargetIndex = 0;
@@ -401,7 +399,6 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
 
 ret = 0;
  cleanup:
-VIR_FREE(devStr);
 return ret;
 }
 
@@ -703,7 +700,7 @@ qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
  virJSONValuePtr *propsret)
 {
 int ret = -1;
-char *keyid = NULL;
+VIR_AUTOFREE(char *) keyid = NULL;
 
 if (!(keyid = qemuDomainGetMasterKeyAlias()))
 return -1;
@@ -715,7 +712,6 @@ qemuBuildSecretInfoProps(qemuDomainSecretInfoPtr secinfo,
"s:iv", secinfo->s.aes.iv,
"s:format", "base64", NULL);
 
-VIR_FREE(keyid);
 return ret;
 }
 
@@ -1518,13 +1514,12 @@ qemuCheckFips(void)
 bool ret = false;
 
 if (virFileExists("/proc/sys/crypto/fips_enabled")) {
-char *buf = NULL;
+VIR_AUTOFREE(char *) buf = NULL;
 
 if (virFileReadAll("/proc/sys/crypto/fips_enabled", 10, ) < 0)
 return ret;
 if (STREQ(buf, "1\n"))
 ret = true;
-VIR_FREE(buf);
 }
 
 return ret;
@@ -1612,7 +1607,7 @@ static int
 qemuBuildDriveSourcePR(virBufferPtr buf,
virDomainDiskDefPtr disk)
 {
-char *alias = NULL;
+VIR_AUTOFREE(char *) alias = NULL;
 const char *defaultAlias = NULL;
 
 if (!disk->src->pr)
@@ -1625,7 +1620,6 @@ qemuBuildDriveSourcePR(virBufferPtr buf,
 
 
 virBufferAsprintf(buf, ",file.pr-manager=%s", alias ? alias : 
defaultAlias);
-VIR_FREE(alias);
 return 0;
 }
 
@@ -1640,7 +1634,7 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 qemuDomainSecretInfoPtr secinfo = NULL;
 qemuDomainSecretInfoPtr encinfo = NULL;
 VIR_AUTOPTR(virJSONValue) srcprops = NULL;
-char *source = NULL;
+VIR_AUTOFREE(char *) source = NULL;
 bool rawluks = false;
 int ret = -1;
 
@@ -1726,7 +1720,6 @@ qemuBuildDriveSourceStr(virDomainDiskDefPtr disk,
 ret = 0;
 
  cleanup:
-VIR_FREE(source);
 return ret;
 }
 
@@ -1839,13 +1832,12 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
 goto error;
 
 if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
-char *drivealias = qemuAliasDiskDriveFromDisk(disk);
+VIR_AUTOFREE(char *) drivealias = qemuAliasDiskDriveFromDisk(disk);
 if (!drivealias)
 goto error;
 
 virBufferAddLit(, "if=none");
 virBufferAsprintf(, ",id=%s", drivealias);
-VIR_FREE(drivealias);
 } else {
 int idx = virDiskNameToIndex(disk->dst);
 
@@ -2000,7 +1992,7 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
 VIR_AUTOCLEAN(virBuffer) opt = VIR_BUFFER_INITIALIZER;
 const char *bus = virDomainDiskQEMUBusTypeToString(disk->bus);
 const char *contAlias;
-char *backendAlias = NULL;
+VIR_AUTOFREE(char *) backendAlias = NULL;
 VIR_AUTOFREE(char *) scsiVPDDeviceId = NULL;
 int controllerModel;
 
@@ -2334,7 +2326,6 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,
 return virBufferContentAndReset();
 
  error:
-VIR_FREE(backendAlias);
 return NULL;
 }
 
@@ -2360,7 +2351,7 @@ static int
 qemuCommandAddZPCIDevice(virCommandPtr cmd,
  virDomainDeviceInfoPtr dev)
 {
-char *devstr = NULL;
+VIR_AUTOFREE(char *) devstr = NULL;
 
 virCommandAddArg(cmd, "-device");
 
@@ -2369,7 +2360,6 @@ qemuCommandAddZPCIDevice(virCommandPtr cmd,
 
 virCommandAddArg(cmd, devstr);
 
-VIR_FREE(devstr);
 return 0;
 }
 
@@ -2399,9 +2389,9 @@ qemuBuildFloppyCommandLineControllerOptions(virCommandPtr 
cmd,
 bool hasfloppy = false;
 unsigned int bootindex;
 char driveLetter;
-char *backendAlias = NULL;
-char *backendStr = NULL;
-char *bootindexStr = NULL;
+

[libvirt] [PATCH 10/19] qemuBuildNetworkDriveURI: use VIR_AUTOPTR for virURI

2019-08-20 Thread Ján Tomko
Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fe06867a88..db8584243c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -953,7 +953,7 @@ static char *
 qemuBuildNetworkDriveURI(virStorageSourcePtr src,
  qemuDomainSecretInfoPtr secinfo)
 {
-virURIPtr uri = NULL;
+VIR_AUTOPTR(virURI) uri = NULL;
 char *ret = NULL;
 
 if (!(uri = qemuBlockStorageSourceGetURI(src)))
@@ -969,7 +969,6 @@ qemuBuildNetworkDriveURI(virStorageSourcePtr src,
 ret = virURIFormat(uri);
 
  cleanup:
-virURIFree(uri);
 return ret;
 }
 
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 06/19] qemuBuildTPMBackendStr: format device and alias separately

2019-08-20 Thread Ján Tomko
Also get rid of the temporary 'type' variable.

Signed-off-by: Ján Tomko 
---
 src/qemu/qemu_command.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3a4acb3166..60e00042c7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -10010,7 +10010,6 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
 {
 const virDomainTPMDef *tpm = def->tpm;
 virBuffer buf = VIR_BUFFER_INITIALIZER;
-const char *type = NULL;
 char *cancel_path = NULL;
 char *devset = NULL;
 char *cancelset = NULL;
@@ -10019,16 +10018,8 @@ qemuBuildTPMBackendStr(const virDomainDef *def,
 *tpmfd = -1;
 *cancelfd = -1;
 
-switch (tpm->type) {
-case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
-case VIR_DOMAIN_TPM_TYPE_EMULATOR:
-type = virDomainTPMBackendTypeToString(tpm->type);
-break;
-case VIR_DOMAIN_TPM_TYPE_LAST:
-goto error;
-}
-
-virBufferAsprintf(, "%s,id=tpm-%s", type, tpm->info.alias);
+virBufferAsprintf(, "%s", virDomainTPMBackendTypeToString(tpm->type));
+virBufferAsprintf(, ",id=tpm-%s", tpm->info.alias);
 
 switch (tpm->type) {
 case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
-- 
2.19.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

  1   2   >