Re: [libvirt] [Xen-devel] Opinions on removing the old, legacy libvirt Xen driver

2016-11-18 Thread Konrad Rzeszutek Wilk
On Fri, Nov 18, 2016 at 02:25:18PM -0700, Jim Fehlig wrote:
> Hi All,
> 
> I briefly mentioned this at an evening event during the KVM Forum / Xen Dev
> Summit, but the list is certainly a better place to discuss such a topic.
> What do folks think about finally removing the old, legacy, xend-based
> driver from the libvirt sources?

RIP.

It will make your life easier! All the code that Joao and Bob are
doing is against libxl and I presume other folks are more interested
in that.

> 
> The Xen community made xl/libxl the primary toolstack in Xen 4.1. In Xen
> 4.2, it was made the default toolstack. In Xen 4.5, xm/xend was completely
> removed from the Xen source tree. According to the Xen release support
> matrix [0], upstream maintenance of Xen 4.1-4.3 has been dropped for some
> time, including "long term" security support. Xen 4.4-4.5 no longer receive
> regular maintenance support, with security support ending in March for 4.4
> and January 2018 for 4.5. In short, the fully maintained upstream Xen
> releases don't even contain xm/xend :-).
> 
> As for downstreams, I doubt anyone is interested in running the last several
> libvirt releases on an old Xen installition with xm/xend, let alone
> libvirt.git master. SUSE, which still supports Xen, has no interest in using
> a new libvirt on older (but still supported) SLES that uses the xm/xend
> toolstack. I struggle to find a good reason to keep any of the old cruft
> under src/xen/. I do think we should keep the xm/sexpr config
> parsing/formatting code src/xenconfig/ since it is useful for converting old
> xm and sexpr config to libvirt domXML.

/me nods.
> 
> Thanks for opinions and comments!
> 
> Regards,
> Jim
> 
> [0] https://wiki.xenproject.org/wiki/Xen_Project_Release_Features
> 
> ___
> Xen-devel mailing list
> xen-de...@lists.xen.org
> https://lists.xen.org/xen-devel

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


Re: [libvirt] [PATCH] libxl: add tunnelled migration support

2016-11-18 Thread Jim Fehlig

On 11/10/2016 09:14 PM, Bob Liu wrote:

Tunnelled migration doesn't require any extra network connections beside the
libvirt daemon.
It's capable of strong encryption and the default option of openstack-nova.

This patch adds the tunnelled migration(Tunnel3params) support to libxl.
On the src side, the data flow is:
 * libxlDoMigrateSend() -> pipe
 * libxlTunnel3MigrationFunc() polls pipe out and then write to dest stream.

While on the dest side:
Stream -> pipe -> 'recvfd of libxlDomainStartRestore'

The usage is the same as p2p migration, execpt adding one extra '--tunnelled' to
the libvirt p2p migration command.


Hi Bob,

Thanks for the patch! A few comments below...



Signed-off-by: Bob Liu 
---
 src/libxl/libxl_driver.c|  58 -
 src/libxl/libxl_migration.c | 281 +---
 src/libxl/libxl_migration.h |   9 ++
 3 files changed, 331 insertions(+), 17 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b66cb1f..bc2633b 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5918,6 +5918,61 @@ libxlDomainMigrateBegin3Params(virDomainPtr domain,
 }

 static int
+libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
+   virStreamPtr st,
+   virTypedParameterPtr params,
+   int nparams,
+   const char *cookiein,
+   int cookieinlen,
+   char **cookieout ATTRIBUTE_UNUSED,
+   int *cookieoutlen ATTRIBUTE_UNUSED,
+   unsigned int flags)
+{
+libxlDriverPrivatePtr driver = dconn->privateData;
+virDomainDefPtr def = NULL;
+const char *dom_xml = NULL;
+const char *dname = NULL;
+const char *uri_in = NULL;
+
+#ifdef LIBXL_HAVE_NO_SUSPEND_RESUME
+virReportUnsupportedError();
+return -1;
+#endif
+
+virCheckFlags(LIBXL_MIGRATION_FLAGS, -1);
+if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 
0)
+goto error;
+
+if (virTypedParamsGetString(params, nparams,
+VIR_MIGRATE_PARAM_DEST_XML,
+_xml) < 0 ||
+virTypedParamsGetString(params, nparams,
+VIR_MIGRATE_PARAM_DEST_NAME,
+) < 0 ||
+virTypedParamsGetString(params, nparams,
+VIR_MIGRATE_PARAM_URI,
+_in) < 0)
+
+goto error;
+
+if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname)))
+goto error;
+
+if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0)
+goto error;
+
+if (libxlDomainMigrationPrepareTunnel3(dconn, st, , cookiein,
+   cookieinlen, flags) < 0)


With the exception of the above two calls, this function is identical to 
libxlDomainMigratePrepare3Params. Perhaps you can use some macro trickery or a 
common function to reduce the duplicate code?



+goto error;
+
+return 0;
+
+ error:
+virDomainDefFree(def);
+return -1;
+}
+
+static int
 libxlDomainMigratePrepare3Params(virConnectPtr dconn,
  virTypedParameterPtr params,
  int nparams,
@@ -6017,7 +6072,7 @@ libxlDomainMigratePerform3Params(virDomainPtr dom,
 if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0)
 goto cleanup;

-if (flags & VIR_MIGRATE_PEER2PEER) {
+if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) {
 if (libxlDomainMigrationPerformP2P(driver, vm, dom->conn, dom_xml,
dconnuri, uri, dname, flags) < 0)
 goto cleanup;
@@ -6501,6 +6556,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 .nodeDeviceReset = libxlNodeDeviceReset, /* 1.2.3 */
 .domainMigrateBegin3Params = libxlDomainMigrateBegin3Params, /* 1.2.6 */
 .domainMigratePrepare3Params = libxlDomainMigratePrepare3Params, /* 1.2.6 
*/
+.domainMigratePrepareTunnel3Params = 
libxlDomainMigratePrepareTunnel3Params, /* 2.5.0 */
 .domainMigratePerform3Params = libxlDomainMigratePerform3Params, /* 1.2.6 
*/
 .domainMigrateFinish3Params = libxlDomainMigrateFinish3Params, /* 1.2.6 */
 .domainMigrateConfirm3Params = libxlDomainMigrateConfirm3Params, /* 1.2.6 
*/
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 534abb8..f3152dc 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -44,6 +44,7 @@
 #include "libxl_migration.h"
 #include "locking/domain_lock.h"
 #include "virtypedparam.h"
+#include "fdstream.h"

 #define VIR_FROM_THIS VIR_FROM_LIBXL

@@ -484,6 +485,90 @@ 

[libvirt] [PATCH v3 1/4] Gathering vhostuser interface stats with ovs

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

When vhostuser interfaces are used, the interface statistics
are not available in /proc/net/dev.

This change looks at the openvswitch interfaces statistics
tables to provide this information for vhostuser interface.

Note that in openvswitch world drop/error doesn't always make sense
for some interface type. When these informations are not available we
set them to 0 on the virDomainInterfaceStats.
---
 src/libvirt_private.syms|   1 +
 src/qemu/qemu_driver.c  |  29 ---
 src/util/virnetdevopenvswitch.c | 106 
 src/util/virnetdevopenvswitch.h |   4 ++
 4 files changed, 133 insertions(+), 7 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index baff82b..aa27f78 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2034,6 +2034,7 @@ virNetDevMidonetUnbindPort;
 # util/virnetdevopenvswitch.h
 virNetDevOpenvswitchAddPort;
 virNetDevOpenvswitchGetMigrateData;
+virNetDevOpenvswitchInterfaceStats;
 virNetDevOpenvswitchRemovePort;
 virNetDevOpenvswitchSetMigrateData;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d039255..87ca09d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -66,6 +66,7 @@
 #include "virhostcpu.h"
 #include "virhostmem.h"
 #include "virstats.h"
+#include "virnetdevopenvswitch.h"
 #include "capabilities.h"
 #include "viralloc.h"
 #include "viruuid.h"
@@ -10975,6 +10976,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
  virDomainInterfaceStatsPtr stats)
 {
 virDomainObjPtr vm;
+virDomainNetDefPtr net = NULL;
 size_t i;
 int ret = -1;
 
@@ -10994,16 +10996,21 @@ qemuDomainInterfaceStats(virDomainPtr dom,
 for (i = 0; i < vm->def->nnets; i++) {
 if (vm->def->nets[i]->ifname &&
 STREQ(vm->def->nets[i]->ifname, path)) {
-ret = 0;
+net = vm->def->nets[i];
 break;
 }
 }
 
-if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
-else
+if (net) {
+if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
+ret = virNetDevOpenvswitchInterfaceStats(path, stats);
+} else {
+ret = virNetInterfaceStats(path, stats);
+}
+} else {
 virReportError(VIR_ERR_INVALID_ARG,
_("invalid path, '%s' is not a known interface"), path);
+}
 
  cleanup:
 virDomainObjEndAPI();
@@ -19140,9 +19147,17 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver 
ATTRIBUTE_UNUSED,
 QEMU_ADD_NAME_PARAM(record, maxparams,
 "net", "name", i, dom->def->nets[i]->ifname);
 
-if (virNetInterfaceStats(dom->def->nets[i]->ifname, ) < 0) {
-virResetLastError();
-continue;
+if (dom->def->nets[i]->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
+if (virNetDevOpenvswitchInterfaceStats(dom->def->nets[i]->ifname,
+   ) < 0) {
+virResetLastError();
+continue;
+}
+} else {
+if (virNetInterfaceStats(dom->def->nets[i]->ifname, ) < 0) {
+virResetLastError();
+continue;
+}
 }
 
 QEMU_ADD_NET_PARAM(record, maxparams, i,
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 9283bbb..db8b542 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -24,6 +24,8 @@
 
 #include 
 
+#include 
+
 #include "virnetdevopenvswitch.h"
 #include "vircommand.h"
 #include "viralloc.h"
@@ -270,3 +272,107 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, 
const char *ifname)
 virCommandFree(cmd);
 return ret;
 }
+
+/**
+ * virNetDevOpenvswitchInterfaceStats:
+ * @ifname: the name of the interface
+ * @stats: the retreived domain interface stat
+ *
+ * Retrieves the OVS interfaces stats
+ *
+ * Returns 0 in case of success or -1 in case of failure
+ */
+int
+virNetDevOpenvswitchInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
+{
+virCommandPtr cmd = NULL;
+char *output;
+long long rx_bytes;
+long long rx_packets;
+long long tx_bytes;
+long long tx_packets;
+long long rx_errs;
+long long rx_drop;
+long long tx_errs;
+long long tx_drop;
+int ret = -1;
+
+// Just ensure the interface exists in ovs
+cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
+   "get", "Interface", ifname,
+   "name", NULL);
+virCommandSetOutputBuffer(cmd, );
+
+if (virCommandRun(cmd, NULL) < 0) {
+// no ovs-vsctl or interface 'ifname' doesn't exists in ovs
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Interface not found"));
+goto cleanup;
+}
+
+

[libvirt] [PATCH v3 3/4] Move virstat.c code to virnetdevtap.c

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

This is just a code move of virstat.c to virnetdevtap.c
---
 po/POTFILES.in |   1 -
 src/Makefile.am|   1 -
 src/libvirt_private.syms   |   4 +-
 src/libxl/libxl_driver.c   |   2 +-
 src/lxc/lxc_driver.c   |   1 -
 src/openvz/openvz_driver.c |   2 +-
 src/qemu/qemu_driver.c |   2 +-
 src/uml/uml_driver.c   |   1 -
 src/util/virnetdevtap.c| 143 
 src/util/virnetdevtap.h|   3 +
 src/util/virstats.c| 178 -
 src/util/virstats.h|  32 
 src/xen/xen_hypervisor.c   |   2 +-
 13 files changed, 151 insertions(+), 221 deletions(-)
 delete mode 100644 src/util/virstats.c
 delete mode 100644 src/util/virstats.h

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 25867ae..50fff6b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -240,7 +240,6 @@ src/util/virscsi.c
 src/util/virsecret.c
 src/util/virsexpr.c
 src/util/virsocketaddr.c
-src/util/virstats.c
 src/util/virstorageencryption.c
 src/util/virstoragefile.c
 src/util/virstring.c
diff --git a/src/Makefile.am b/src/Makefile.am
index aaba9e6..9c958aa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -167,7 +167,6 @@ UTIL_SOURCES =  
\
util/virsecret.c util/virsecret.h   \
util/virsexpr.c util/virsexpr.h \
util/virsocketaddr.h util/virsocketaddr.c   \
-   util/virstats.c util/virstats.h \
util/virstorageencryption.c util/virstorageencryption.h \
util/virstoragefile.c util/virstoragefile.h \
util/virstring.h util/virstring.c   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0036cbd..9fd5920 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2045,6 +2045,7 @@ virNetDevTapCreateInBridgePort;
 virNetDevTapDelete;
 virNetDevTapGetName;
 virNetDevTapGetRealDeviceName;
+virNetDevTapInterfaceStats;
 
 
 # util/virnetdevveth.h
@@ -2366,9 +2367,6 @@ virSocketAddrSetIPv6Addr;
 virSocketAddrSetIPv6AddrNetOrder;
 virSocketAddrSetPort;
 
-# util/virstats.h
-virNetDevTapInterfaceStats;
-
 # util/virstorageencryption.h
 virStorageEncryptionFormat;
 virStorageEncryptionFree;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 67f0e58..9454337 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -61,7 +61,7 @@
 #include "virhostdev.h"
 #include "network/bridge_driver.h"
 #include "locking/domain_lock.h"
-#include "virstats.h"
+#include "virnetdevtap.h"
 #include "cpu/cpu.h"
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 526d40d..7a13c23 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -61,7 +61,6 @@
 #include "virhostcpu.h"
 #include "virhostmem.h"
 #include "viruuid.h"
-#include "virstats.h"
 #include "virhook.h"
 #include "virfile.h"
 #include "virpidfile.h"
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 7bd3acf..5e549e00 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -57,7 +57,7 @@
 #include "virlog.h"
 #include "vircommand.h"
 #include "viruri.h"
-#include "virstats.h"
+#include "virnetdevtap.h"
 #include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_OPENVZ
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 38208b1..1124429 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -65,7 +65,7 @@
 #include "nodeinfo.h"
 #include "virhostcpu.h"
 #include "virhostmem.h"
-#include "virstats.h"
+#include "virnetdevtap.h"
 #include "virnetdevopenvswitch.h"
 #include "capabilities.h"
 #include "viralloc.h"
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4f4a69b..d3fb08a 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -48,7 +48,6 @@
 #include "nodeinfo.h"
 #include "virhostcpu.h"
 #include "virhostmem.h"
-#include "virstats.h"
 #include "capabilities.h"
 #include "viralloc.h"
 #include "viruuid.h"
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 7488a4c..85c0045 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -33,7 +33,13 @@
 #include "viralloc.h"
 #include "virlog.h"
 #include "virstring.h"
+#include "datatypes.h"
 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -44,6 +50,9 @@
 #elif defined(__FreeBSD__)
 # include 
 #endif
+#if defined(HAVE_GETIFADDRS) && defined(AF_LINK)
+# include 
+#endif
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -601,3 +610,137 @@ int virNetDevTapCreateInBridgePort(const char *brname,
 
 return -1;
 }
+
+/* interface stats */
+/* Just reads the named interface, so not Xen or QEMU-specific.
+ * NB. Caller must check that libvirt user is trying to query
+ * the interface of a 

[libvirt] [PATCH v3 0/4] Gathering network interface statistics with openvswitch

2016-11-18 Thread Mehdi Abaakouk
This new version removes the virstat.c from locale configuration.

It also adds a new commit to autodected the ifname of the ovs vhostuser.

Mehdi Abaakouk (4):
  Gathering vhostuser interface stats with ovs
  virstat: fix signature of virstat helper
  Move virstat.c code to virnetdevtap.c
  domain_conf: autodetect vhostuser ifname

 po/POTFILES.in  |   1 -
 src/Makefile.am |   1 -
 src/conf/domain_conf.c  |  10 +++
 src/libvirt_private.syms|   5 +-
 src/libxl/libxl_driver.c|   4 +-
 src/lxc/lxc_driver.c|   3 +-
 src/openvz/openvz_driver.c  |   4 +-
 src/qemu/qemu_driver.c  |  31 +--
 src/uml/uml_driver.c|   1 -
 src/util/virnetdevopenvswitch.c | 106 
 src/util/virnetdevopenvswitch.h |   4 +
 src/util/virnetdevtap.c | 143 
 src/util/virnetdevtap.h |   3 +
 src/util/virstats.c | 178 
 src/util/virstats.h |  31 ---
 src/xen/xen_hypervisor.c|   4 +-
 16 files changed, 298 insertions(+), 231 deletions(-)
 delete mode 100644 src/util/virstats.c
 delete mode 100644 src/util/virstats.h

-- 
2.10.2

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


[libvirt] [PATCH v3 4/4] domain_conf: autodetect vhostuser ifname

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

This change puts the socket filename as ifname for vhostuser netwok
interface.

The filename is the name of the openvswitch interface, this allows the
qemuDomainInterfaceStats to work out of the box without having to
manually set the ifname.
---
 src/conf/domain_conf.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6e008e2..0f91ab3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9098,6 +9098,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
 virDomainActualNetDefPtr actual = NULL;
 xmlNodePtr oldnode = ctxt->node;
 int ret, val;
+char **tokens = NULL;
+size_t ntokens = 0;
 
 if (VIR_ALLOC(def) < 0)
 return NULL;
@@ -9394,6 +9396,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
 
 def->data.vhostuser->type = VIR_DOMAIN_CHR_TYPE_UNIX;
 def->data.vhostuser->data.nix.path = vhostuser_path;
+
+if (!ifname && (tokens = virStringSplitCount(vhostuser_path, "/", 0,
+ ))) {
+if (VIR_STRDUP(ifname, tokens[ntokens-1]) < 0)
+goto error;
+}
+
 vhostuser_path = NULL;
 
 if (STREQ(vhostuser_mode, "server")) {
@@ -9842,6 +9851,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
 VIR_FREE(localaddr);
 VIR_FREE(localport);
 virNWFilterHashTableFree(filterparams);
+virStringFreeListCount(tokens, ntokens);
 
 return def;
 
-- 
2.10.2

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


[libvirt] [PATCH v3 2/4] virstat: fix signature of virstat helper

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

In preparation to the code move to virnetdevtap.c, this change:

* renames virNetInterfaceStats to virNetDevTapInterfaceStats
* changes 'path' to 'ifname', to use the same vocable as other
  method in virnetdevtap.c.
* Add the attributes checker
---
 src/libvirt_private.syms   |  2 +-
 src/libxl/libxl_driver.c   |  2 +-
 src/lxc/lxc_driver.c   |  2 +-
 src/openvz/openvz_driver.c |  2 +-
 src/qemu/qemu_driver.c |  4 ++--
 src/util/virstats.c| 22 +++---
 src/util/virstats.h|  5 +++--
 src/xen/xen_hypervisor.c   |  2 +-
 8 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index aa27f78..0036cbd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2367,7 +2367,7 @@ virSocketAddrSetIPv6AddrNetOrder;
 virSocketAddrSetPort;
 
 # util/virstats.h
-virNetInterfaceStats;
+virNetDevTapInterfaceStats;
 
 # util/virstorageencryption.h
 virStorageEncryptionFormat;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b2f3b16..67f0e58 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4982,7 +4982,7 @@ libxlDomainInterfaceStats(virDomainPtr dom,
 }
 
 if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 else
 virReportError(VIR_ERR_INVALID_ARG,
_("'%s' is not a known interface"), path);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4a0165a..526d40d 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2893,7 +2893,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
 }
 
 if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 else
 virReportError(VIR_ERR_INVALID_ARG,
_("Invalid path, '%s' is not a known interface"), path);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 38a562e..7bd3acf 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2024,7 +2024,7 @@ openvzDomainInterfaceStats(virDomainPtr dom,
 }
 
 if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 else
 virReportError(VIR_ERR_INVALID_ARG,
_("invalid path, '%s' is not a known interface"), path);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 87ca09d..38208b1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11005,7 +11005,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
 if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
 ret = virNetDevOpenvswitchInterfaceStats(path, stats);
 } else {
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 }
 } else {
 virReportError(VIR_ERR_INVALID_ARG,
@@ -19154,7 +19154,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver 
ATTRIBUTE_UNUSED,
 continue;
 }
 } else {
-if (virNetInterfaceStats(dom->def->nets[i]->ifname, ) < 0) {
+if (virNetDevTapInterfaceStats(dom->def->nets[i]->ifname, ) < 
0) {
 virResetLastError();
 continue;
 }
diff --git a/src/util/virstats.c b/src/util/virstats.c
index c4725ed..95b4c38 100644
--- a/src/util/virstats.c
+++ b/src/util/virstats.c
@@ -50,10 +50,10 @@
  */
 #ifdef __linux__
 int
-virNetInterfaceStats(const char *path,
- virDomainInterfaceStatsPtr stats)
+virNetDevTapInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
 {
-int path_len;
+int ifname_len;
 FILE *fp;
 char line[256], *colon;
 
@@ -64,7 +64,7 @@ virNetInterfaceStats(const char *path,
 return -1;
 }
 
-path_len = strlen(path);
+ifname_len = strlen(ifname);
 
 while (fgets(line, sizeof(line), fp)) {
 long long dummy;
@@ -84,8 +84,8 @@ virNetInterfaceStats(const char *path,
 colon = strchr(line, ':');
 if (!colon) continue;
 *colon = '\0';
-if (colon-path_len >= line &&
-STREQ(colon-path_len, path)) {
+if (colon-ifname_len >= line &&
+STREQ(colon-ifname_len, ifname)) {
 /* IMPORTANT NOTE!
  * /proc/net/dev vif.nn sees the network from the point
  * of view of dom0 / hypervisor.  So bytes TRANSMITTED by dom0
@@ -121,8 +121,8 @@ virNetInterfaceStats(const char *path,
 }
 #elif defined(HAVE_GETIFADDRS) && defined(AF_LINK)
 int
-virNetInterfaceStats(const char *path,
- virDomainInterfaceStatsPtr stats)
+virNetDevTapInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
 {
 struct ifaddrs *ifap, *ifa;
 struct 

Re: [libvirt] [Xen-devel] Opinions on removing the old, legacy libvirt Xen driver

2016-11-18 Thread Dario Faggioli
On Fri, 2016-11-18 at 14:25 -0700, Jim Fehlig wrote:
> Hi All,
> 
> I briefly mentioned this at an evening event during the KVM Forum /
> Xen Dev 
> Summit, but the list is certainly a better place to discuss such a
> topic. What 
> do folks think about finally removing the old, legacy, xend-based
> driver from 
> the libvirt sources?
> 
As little as it is worth, I'd like to send my +1 to this.

> As for downstreams, I doubt anyone is interested in running the last
> several 
> libvirt releases on an old Xen installition with xm/xend, let alone
> libvirt.git 
> master. SUSE, which still supports Xen, has no interest in using a
> new libvirt 
> on older (but still supported) SLES that uses the xm/xend toolstack.
> I struggle 
> to find a good reason to keep any of the old cruft under src/xen/. I
> do think we 
> should keep the xm/sexpr config parsing/formatting code
> src/xenconfig/ since it 
> is useful for converting old xm and sexpr config to libvirt domXML.
> 
I totally agree with this analysis of yours.

And allow me to add that, for example, on Fedora 24, I have xen-4.6.4,
which does not have xm/xend.

And yet it appear I can install
libvirt-daemon-driver-xen-1.3.3.2-1.fc24.x86_64 which would be totally
useless and, from a user perspective, very confusing.

So, again, +1.

Regards,
Dario
-- 
<> (Raistlin Majere)
-
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R Ltd., Cambridge (UK)

signature.asc
Description: This is a digitally signed message part
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] Opinions on removing the old, legacy libvirt Xen driver

2016-11-18 Thread Jim Fehlig

Hi All,

I briefly mentioned this at an evening event during the KVM Forum / Xen Dev 
Summit, but the list is certainly a better place to discuss such a topic. What 
do folks think about finally removing the old, legacy, xend-based driver from 
the libvirt sources?


The Xen community made xl/libxl the primary toolstack in Xen 4.1. In Xen 4.2, it 
was made the default toolstack. In Xen 4.5, xm/xend was completely removed from 
the Xen source tree. According to the Xen release support matrix [0], upstream 
maintenance of Xen 4.1-4.3 has been dropped for some time, including "long term" 
security support. Xen 4.4-4.5 no longer receive regular maintenance support, 
with security support ending in March for 4.4 and January 2018 for 4.5. In 
short, the fully maintained upstream Xen releases don't even contain xm/xend :-).


As for downstreams, I doubt anyone is interested in running the last several 
libvirt releases on an old Xen installition with xm/xend, let alone libvirt.git 
master. SUSE, which still supports Xen, has no interest in using a new libvirt 
on older (but still supported) SLES that uses the xm/xend toolstack. I struggle 
to find a good reason to keep any of the old cruft under src/xen/. I do think we 
should keep the xm/sexpr config parsing/formatting code src/xenconfig/ since it 
is useful for converting old xm and sexpr config to libvirt domXML.


Thanks for opinions and comments!

Regards,
Jim

[0] https://wiki.xenproject.org/wiki/Xen_Project_Release_Features

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


Re: [libvirt] [PATCH v3 03/10] Introduce a "scsi_host" hostdev type

2016-11-18 Thread John Ferlan


On 11/18/2016 08:01 AM, Eric Farman wrote:
> 
> 
> On 11/17/2016 06:18 PM, John Ferlan wrote:
>> [...]
>>
 I don't think the current code naming is incorrect, but it does
 slightly paint us into a box with this work.  I'll mull this over
 overnight, and maybe cook up a cleanup patch separate from this
 series.  Or perhaps take your other suggestion and go with the
 inclusion of "vhost" in the functions.
>>> John,
>>>
>>> I sent an RFC patch [1] separate from this series the other day, but
>>> thought that I had the remainder of your comments addressed and so maybe
>>> I'd combine everything into one series.  Then my brain exploded:
>>>
>>> Before:
>>> // These three are all existing code
>>>  virDomainHostdevSubsysSCSIPtr scsisrc = >source.subsys.u.scsi;
>>>  virDomainHostdevSubsysSCSIHostPtr scsihostsrc = >u.host;
>>>  virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = >u.iscsi;
>>> // The next one is new
>>>  virDomainHostdevSubsysHostPtr hostsrc = >source.subsys.u.host;
>>>
>>> After:
>>> // These three are all existing code
>>>  virDomainHostdevSubsysSCSIPtr scsisrc = >source.subsys.u.scsi;
>>>  virDomainHostdevSubsysSCSISCSIHostPtr scsiscsihostsrc =
>>> >u.host;
>>>  virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = >u.iscsi;
>>> // The next one is new
>>>  virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
>>> >source.subsys.u.scsihost;
>>>
>>> So, uh, ugh.  (And it still has an inconsistency because I had to
>>> prepend another "scsi" on the existing "scsihostsrc" ... which means
>>> there's probably a better reworking to have happen here.)
>>>
>>> I could take your other suggestion of "SCSIHostVHost", but I still worry
>>> that that gets viewed as a subset of the existing SCSIHost stuff (which
>>> is a type='scsi' sourceadapter='scsi_host' hostdev), without somehow
>>> cleaning up the existing code.
>>>
>>> For now, I've stashed these changes off to the side.  I could spin a v4
>>> of the vhost-scsi series without any of the s/host/scsihost/ variations
>>> you asked for, but this rabbit hole is probably going to consume me
>>> until the next freeze/holiday.  Thoughts?
>> I've been heads down in some vHBA/NPIV code - less than friendly
>> stuff... It's a customer case, so it's taken priority...
> 
> No problem, those definitely win.
> 
>>
>> Quick thoughts -
>>
>> ... the RFC used SCSISCSI which really looked odd and I think I
>> originally avoided for that very reason when I gone through a similar
>> exercise some time ago.
> 
> Sorry for the deja vu then.  :-)
> 
>>
>> ... since the first issues that caught my attention were in patch4,
>> maybe attack those first - that is change 'Host' to 'SCSCIVHost' API's
>>
>> ... for this patch, it may just be best to change HOST to VHOST and Host
>> to VHost.
> 
> I have patches for these on top of the series (didn't want to rebase
> things too badly in case they went terribly wrong).  The RFC made sense
> because it lined everything up, without introducing a "why isn't the
> type='scsi_vhost' then?" question.  Seeing how it looks now, I'll toss
> those aside for the time being and see how things look with just these
> two.  (Well, there are still some s/HOST/SCSIHOST/ involved; the
> enumerated list comes to mind.)
> 
>>
>> I'll try to put some more thought into it in the morning...
> 
> Again, I appreciate the time you've spent looking at this.  Good luck in
> NPIV-land.

Heads down did good - those got posted today...

So I spent some time working through my patch3 and patch4 comments.
Rather than post to the list - I'll send directly to you and let you
process the data.

Essentially though I think I accomplished everything related *only to*
name changes for patches 3 and 4 (well they're now 2 and 3).

Anyway - I figured since I got you into the problem, I could help get
you out at the very least.

They'll be arriving in your inbox soon.

John

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


[libvirt] [PATCH 1/3] Gathering vhostuser interface stats with ovs

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

When vhostuser interfaces are used, the interface statistics
are not available in /proc/net/dev.

This change looks at the openvswitch interfaces statistics
tables to provide this information for vhostuser interface.

Note that in openvswitch world drop/error doesn't always make sense
for some interface type. When these informations are not available we
set them to 0 on the virDomainInterfaceStats.
---
 src/libvirt_private.syms|   1 +
 src/qemu/qemu_driver.c  |  29 ---
 src/util/virnetdevopenvswitch.c | 106 
 src/util/virnetdevopenvswitch.h |   4 ++
 4 files changed, 133 insertions(+), 7 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index baff82b..aa27f78 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2034,6 +2034,7 @@ virNetDevMidonetUnbindPort;
 # util/virnetdevopenvswitch.h
 virNetDevOpenvswitchAddPort;
 virNetDevOpenvswitchGetMigrateData;
+virNetDevOpenvswitchInterfaceStats;
 virNetDevOpenvswitchRemovePort;
 virNetDevOpenvswitchSetMigrateData;
 
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d039255..87ca09d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -66,6 +66,7 @@
 #include "virhostcpu.h"
 #include "virhostmem.h"
 #include "virstats.h"
+#include "virnetdevopenvswitch.h"
 #include "capabilities.h"
 #include "viralloc.h"
 #include "viruuid.h"
@@ -10975,6 +10976,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
  virDomainInterfaceStatsPtr stats)
 {
 virDomainObjPtr vm;
+virDomainNetDefPtr net = NULL;
 size_t i;
 int ret = -1;
 
@@ -10994,16 +10996,21 @@ qemuDomainInterfaceStats(virDomainPtr dom,
 for (i = 0; i < vm->def->nnets; i++) {
 if (vm->def->nets[i]->ifname &&
 STREQ(vm->def->nets[i]->ifname, path)) {
-ret = 0;
+net = vm->def->nets[i];
 break;
 }
 }
 
-if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
-else
+if (net) {
+if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
+ret = virNetDevOpenvswitchInterfaceStats(path, stats);
+} else {
+ret = virNetInterfaceStats(path, stats);
+}
+} else {
 virReportError(VIR_ERR_INVALID_ARG,
_("invalid path, '%s' is not a known interface"), path);
+}
 
  cleanup:
 virDomainObjEndAPI();
@@ -19140,9 +19147,17 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver 
ATTRIBUTE_UNUSED,
 QEMU_ADD_NAME_PARAM(record, maxparams,
 "net", "name", i, dom->def->nets[i]->ifname);
 
-if (virNetInterfaceStats(dom->def->nets[i]->ifname, ) < 0) {
-virResetLastError();
-continue;
+if (dom->def->nets[i]->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
+if (virNetDevOpenvswitchInterfaceStats(dom->def->nets[i]->ifname,
+   ) < 0) {
+virResetLastError();
+continue;
+}
+} else {
+if (virNetInterfaceStats(dom->def->nets[i]->ifname, ) < 0) {
+virResetLastError();
+continue;
+}
 }
 
 QEMU_ADD_NET_PARAM(record, maxparams, i,
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 9283bbb..db8b542 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -24,6 +24,8 @@
 
 #include 
 
+#include 
+
 #include "virnetdevopenvswitch.h"
 #include "vircommand.h"
 #include "viralloc.h"
@@ -270,3 +272,107 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, 
const char *ifname)
 virCommandFree(cmd);
 return ret;
 }
+
+/**
+ * virNetDevOpenvswitchInterfaceStats:
+ * @ifname: the name of the interface
+ * @stats: the retreived domain interface stat
+ *
+ * Retrieves the OVS interfaces stats
+ *
+ * Returns 0 in case of success or -1 in case of failure
+ */
+int
+virNetDevOpenvswitchInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
+{
+virCommandPtr cmd = NULL;
+char *output;
+long long rx_bytes;
+long long rx_packets;
+long long tx_bytes;
+long long tx_packets;
+long long rx_errs;
+long long rx_drop;
+long long tx_errs;
+long long tx_drop;
+int ret = -1;
+
+// Just ensure the interface exists in ovs
+cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
+   "get", "Interface", ifname,
+   "name", NULL);
+virCommandSetOutputBuffer(cmd, );
+
+if (virCommandRun(cmd, NULL) < 0) {
+// no ovs-vsctl or interface 'ifname' doesn't exists in ovs
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Interface not found"));
+goto cleanup;
+}
+
+

[libvirt] [PATCH 3/3] Move virstat.c code to virnetdevtap.c

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

This is just a code move of virstat.c to virnetdevtap.c
---
 src/Makefile.am|   1 -
 src/libvirt_private.syms   |   4 +-
 src/libxl/libxl_driver.c   |   2 +-
 src/lxc/lxc_driver.c   |   1 -
 src/openvz/openvz_driver.c |   2 +-
 src/qemu/qemu_driver.c |   2 +-
 src/uml/uml_driver.c   |   1 -
 src/util/virnetdevtap.c| 143 
 src/util/virnetdevtap.h|   3 +
 src/util/virstats.c| 178 -
 src/util/virstats.h|  32 
 src/xen/xen_hypervisor.c   |   2 +-
 12 files changed, 151 insertions(+), 220 deletions(-)
 delete mode 100644 src/util/virstats.c
 delete mode 100644 src/util/virstats.h

diff --git a/src/Makefile.am b/src/Makefile.am
index aaba9e6..9c958aa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -167,7 +167,6 @@ UTIL_SOURCES =  
\
util/virsecret.c util/virsecret.h   \
util/virsexpr.c util/virsexpr.h \
util/virsocketaddr.h util/virsocketaddr.c   \
-   util/virstats.c util/virstats.h \
util/virstorageencryption.c util/virstorageencryption.h \
util/virstoragefile.c util/virstoragefile.h \
util/virstring.h util/virstring.c   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0036cbd..9bd4a8d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2043,6 +2043,7 @@ virNetDevOpenvswitchSetMigrateData;
 virNetDevTapCreate;
 virNetDevTapCreateInBridgePort;
 virNetDevTapDelete;
+virNetDevTapInterfaceStats;
 virNetDevTapGetName;
 virNetDevTapGetRealDeviceName;
 
@@ -2366,9 +2367,6 @@ virSocketAddrSetIPv6Addr;
 virSocketAddrSetIPv6AddrNetOrder;
 virSocketAddrSetPort;
 
-# util/virstats.h
-virNetDevTapInterfaceStats;
-
 # util/virstorageencryption.h
 virStorageEncryptionFormat;
 virStorageEncryptionFree;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 67f0e58..9454337 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -61,7 +61,7 @@
 #include "virhostdev.h"
 #include "network/bridge_driver.h"
 #include "locking/domain_lock.h"
-#include "virstats.h"
+#include "virnetdevtap.h"
 #include "cpu/cpu.h"
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 526d40d..7a13c23 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -61,7 +61,6 @@
 #include "virhostcpu.h"
 #include "virhostmem.h"
 #include "viruuid.h"
-#include "virstats.h"
 #include "virhook.h"
 #include "virfile.h"
 #include "virpidfile.h"
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 7bd3acf..5e549e00 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -57,7 +57,7 @@
 #include "virlog.h"
 #include "vircommand.h"
 #include "viruri.h"
-#include "virstats.h"
+#include "virnetdevtap.h"
 #include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_OPENVZ
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 38208b1..1124429 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -65,7 +65,7 @@
 #include "nodeinfo.h"
 #include "virhostcpu.h"
 #include "virhostmem.h"
-#include "virstats.h"
+#include "virnetdevtap.h"
 #include "virnetdevopenvswitch.h"
 #include "capabilities.h"
 #include "viralloc.h"
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 4f4a69b..d3fb08a 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -48,7 +48,6 @@
 #include "nodeinfo.h"
 #include "virhostcpu.h"
 #include "virhostmem.h"
-#include "virstats.h"
 #include "capabilities.h"
 #include "viralloc.h"
 #include "viruuid.h"
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 7488a4c..85c0045 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -33,7 +33,13 @@
 #include "viralloc.h"
 #include "virlog.h"
 #include "virstring.h"
+#include "datatypes.h"
 
+#include 
+#include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -44,6 +50,9 @@
 #elif defined(__FreeBSD__)
 # include 
 #endif
+#if defined(HAVE_GETIFADDRS) && defined(AF_LINK)
+# include 
+#endif
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -601,3 +610,137 @@ int virNetDevTapCreateInBridgePort(const char *brname,
 
 return -1;
 }
+
+/* interface stats */
+/* Just reads the named interface, so not Xen or QEMU-specific.
+ * NB. Caller must check that libvirt user is trying to query
+ * the interface of a domain they own.  We do no such checking.
+ */
+#ifdef __linux__
+int
+virNetDevTapInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
+{
+int ifname_len;
+FILE *fp;
+char line[256], *colon;
+
+fp = fopen("/proc/net/dev", "r");
+if (!fp) {
+

[libvirt] [PATCH v2 0/3] Gathering network interface statistics with openvswitch

2016-11-18 Thread Mehdi Abaakouk
Hi,

The new code have been moved to virnetdevopenvswitch.c
I have also sent the refactoring of virstat.c

Regards,

Mehdi Abaakouk (3):
  Gathering vhostuser interface stats with ovs
  virstat: fix signature of virstat helper
  Move virstat.c code to virnetdevtap.c

 src/Makefile.am |   1 -
 src/libvirt_private.syms|   5 +-
 src/libxl/libxl_driver.c|   4 +-
 src/lxc/lxc_driver.c|   3 +-
 src/openvz/openvz_driver.c  |   4 +-
 src/qemu/qemu_driver.c  |  31 +--
 src/uml/uml_driver.c|   1 -
 src/util/virnetdevopenvswitch.c | 106 
 src/util/virnetdevopenvswitch.h |   4 +
 src/util/virnetdevtap.c | 143 
 src/util/virnetdevtap.h |   3 +
 src/util/virstats.c | 178 
 src/util/virstats.h |  31 ---
 src/xen/xen_hypervisor.c|   4 +-
 14 files changed, 288 insertions(+), 230 deletions(-)
 delete mode 100644 src/util/virstats.c
 delete mode 100644 src/util/virstats.h

-- 
2.10.2

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


[libvirt] [PATCH 2/3] virstat: fix signature of virstat helper

2016-11-18 Thread Mehdi Abaakouk
From: Mehdi Abaakouk 

In preparation to the code move to virnetdevtap.c, this change:

* renames virNetInterfaceStats to virNetDevTapInterfaceStats
* changes 'path' to 'ifname', to use the same vocable as other
  method in virnetdevtap.c.
* Add the attributes checker
---
 src/libvirt_private.syms   |  2 +-
 src/libxl/libxl_driver.c   |  2 +-
 src/lxc/lxc_driver.c   |  2 +-
 src/openvz/openvz_driver.c |  2 +-
 src/qemu/qemu_driver.c |  4 ++--
 src/util/virstats.c| 22 +++---
 src/util/virstats.h|  5 +++--
 src/xen/xen_hypervisor.c   |  2 +-
 8 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index aa27f78..0036cbd 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2367,7 +2367,7 @@ virSocketAddrSetIPv6AddrNetOrder;
 virSocketAddrSetPort;
 
 # util/virstats.h
-virNetInterfaceStats;
+virNetDevTapInterfaceStats;
 
 # util/virstorageencryption.h
 virStorageEncryptionFormat;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b2f3b16..67f0e58 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4982,7 +4982,7 @@ libxlDomainInterfaceStats(virDomainPtr dom,
 }
 
 if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 else
 virReportError(VIR_ERR_INVALID_ARG,
_("'%s' is not a known interface"), path);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4a0165a..526d40d 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2893,7 +2893,7 @@ lxcDomainInterfaceStats(virDomainPtr dom,
 }
 
 if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 else
 virReportError(VIR_ERR_INVALID_ARG,
_("Invalid path, '%s' is not a known interface"), path);
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 38a562e..7bd3acf 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -2024,7 +2024,7 @@ openvzDomainInterfaceStats(virDomainPtr dom,
 }
 
 if (ret == 0)
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 else
 virReportError(VIR_ERR_INVALID_ARG,
_("invalid path, '%s' is not a known interface"), path);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 87ca09d..38208b1 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11005,7 +11005,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
 if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
 ret = virNetDevOpenvswitchInterfaceStats(path, stats);
 } else {
-ret = virNetInterfaceStats(path, stats);
+ret = virNetDevTapInterfaceStats(path, stats);
 }
 } else {
 virReportError(VIR_ERR_INVALID_ARG,
@@ -19154,7 +19154,7 @@ qemuDomainGetStatsInterface(virQEMUDriverPtr driver 
ATTRIBUTE_UNUSED,
 continue;
 }
 } else {
-if (virNetInterfaceStats(dom->def->nets[i]->ifname, ) < 0) {
+if (virNetDevTapInterfaceStats(dom->def->nets[i]->ifname, ) < 
0) {
 virResetLastError();
 continue;
 }
diff --git a/src/util/virstats.c b/src/util/virstats.c
index c4725ed..95b4c38 100644
--- a/src/util/virstats.c
+++ b/src/util/virstats.c
@@ -50,10 +50,10 @@
  */
 #ifdef __linux__
 int
-virNetInterfaceStats(const char *path,
- virDomainInterfaceStatsPtr stats)
+virNetDevTapInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
 {
-int path_len;
+int ifname_len;
 FILE *fp;
 char line[256], *colon;
 
@@ -64,7 +64,7 @@ virNetInterfaceStats(const char *path,
 return -1;
 }
 
-path_len = strlen(path);
+ifname_len = strlen(ifname);
 
 while (fgets(line, sizeof(line), fp)) {
 long long dummy;
@@ -84,8 +84,8 @@ virNetInterfaceStats(const char *path,
 colon = strchr(line, ':');
 if (!colon) continue;
 *colon = '\0';
-if (colon-path_len >= line &&
-STREQ(colon-path_len, path)) {
+if (colon-ifname_len >= line &&
+STREQ(colon-ifname_len, ifname)) {
 /* IMPORTANT NOTE!
  * /proc/net/dev vif.nn sees the network from the point
  * of view of dom0 / hypervisor.  So bytes TRANSMITTED by dom0
@@ -121,8 +121,8 @@ virNetInterfaceStats(const char *path,
 }
 #elif defined(HAVE_GETIFADDRS) && defined(AF_LINK)
 int
-virNetInterfaceStats(const char *path,
- virDomainInterfaceStatsPtr stats)
+virNetDevTapInterfaceStats(const char *ifname,
+   virDomainInterfaceStatsPtr stats)
 {
 struct ifaddrs *ifap, *ifa;
 struct 

Re: [libvirt] [PATCH 0/2] vbox: add support for 5.1.x

2016-11-18 Thread Dawid Zamirski
On Fri, 2016-11-18 at 11:16 -0500, Dawid Zamirski wrote:
> 
> Hi Andrea,
> 
> Sure, in this case those patches simply enable support of VirtualBox
> 5.1.x series in libvirt (prior to that libvirt supported vbox 2.x.x
> to
> 5.0.x)- and as such it does not affect any previous version that
> libvirt supported.  When upstream VirtualBox releases new version
> bumping major/minor version tag it is usually coupled with new COM
> IID
> strings that are bundled in the SDK which essentially bumps the VBOX
> API version as well. Adding those SDK headers to livirt, enables it
> to
> communicate with the updated VBOX COM interface and avoids
> "unsupported
> API version" error message when one does virsh -c vbox:///session
> with
> VirtualBox 5.1.x installed on the machine.
> 
> Regards,
> Dawid

Another try after realizing it's for official NEWS entry :-)

"Added support for API compatibility with VitualBox 5.1.x"


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

Re: [libvirt] [PATCH v5 0/7] New libssh transport

2016-11-18 Thread Andrea Bolognani
On Wed, 2016-11-09 at 15:28 +0100, Pino Toscano wrote:
> Hi,
> 
> this series introduces a new libssh transport in libvirt, based on the
> libssh C library.  This library supports what libssh2 does, and more:
> - easier API for known_hosts handling (there's a ticket upstream to
>   request extensions for it, but what is implemented now works well)
> - potential GSSAPI authentication (not enabled yet because of a libssh
>   bug [1])
> - easier API for ssh-agent support
> 
> The implementation for the new transport is based on the libssh2 one,
> hence it shares origin and style.
> 
> [1] https://red.libssh.org/issues/242
> 
> Thanks,
> 
> Changes from v4 to v5:
> - fixed EOF on unavailable libvirtd on remote
> - fixed variable for an error message
> 
> Changes from v3 to v4:
> - integrate most of the issues spotted by Peter Krempa
> - add patch #3
> - minor naming changes
> 
> Changes from v2 to v3:
> - split into more commits
> - integrate all the issues spotted by Daniel P. Berrange and
>   Peter Krempa
> - restore the specified order of authentication methods (as in
> libssh2)
> - add a related documentation fix
> - minor coding fixes
> 
> Changes from v1 to v2:
> - implemented keyboard interactive
> - code polish, and fixes
> 
> 
> Pino Toscano (7):
>   virNetSocket: allow to not close FD
>   virerror: add error for libssh transport
>   virnetsocket: improve search for default SSH key
>   libssh_transport: add new libssh-based transport
>   remote: expose a new libssh transport
>   spec: enable libssh transport on Fedora
>   docs: fix default value for sshauth option of libssh2/libssh

Would you mind providing a NEWS file entry for this new
feature?

Thanks! :)

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [PATCH V2] qemu: Redefine the "unlimited" memory limits one more time

2016-11-18 Thread Viktor Mihajlovski
With kernel 3.18 (since commit 3e32cb2e0a12b6915056ff04601cf1bb9b44f967) the
"unlimited" value for cgroup memory limits has changed once again as its byte
value is now computed from a page counter.
The new "unlimited" value reported by the cgroup fs is therefore 2**51-1 pages
which is (VIR_DOMAIN_MEMORY_PARAM_UNLIMITED - 3072). This results e.g. in virsh
memtune displaying 9007199254740988 instead of unlimited for the limits.

This patch deals with the rounding issue by scaling the byte values reported
by the kernel and the PARAM_UNLIMITED value to page size and comparing those.

See also libvirt commit 231656bbeb9e4d3bedc44362784c35eee21cf0f4 for the
history for kernel 3.12 and before.

Signed-off-by: Viktor Mihajlovski 
---
V2: Shifting the scaled kb values by 2 is of sufficient to account for
4K pages. Friday night fallout, sorry for that.

 src/util/vircgroup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 24917e7..39c7de2 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2542,7 +2542,7 @@ virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned 
long long *kb)
 goto cleanup;
 
 *kb = limit_in_bytes >> 10;
-if (*kb > VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+if (*kb >> 2 >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED >> 2)
 *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
 ret = 0;
@@ -2604,7 +2604,7 @@ virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned 
long long *kb)
 goto cleanup;
 
 *kb = limit_in_bytes >> 10;
-if (*kb > VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+if (*kb >> 2 >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED >> 2)
 *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
 ret = 0;
@@ -2666,7 +2666,7 @@ virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned 
long long *kb)
 goto cleanup;
 
 *kb = limit_in_bytes >> 10;
-if (*kb > VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+if (*kb >> 2 >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED >> 2)
 *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
 ret = 0;
-- 
1.9.1

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


Re: [libvirt] [PATCH 00/14] Another round of CPU driver changes

2016-11-18 Thread Andrea Bolognani
On Thu, 2016-11-10 at 23:39 +0100, Jiri Denemark wrote:
> This is another step in revisiting all APIs provided by the cpu driver
> and making them a bit more sane. As with the previous round(s), the
> updated APIs will gain virCPU prefix so that they can be easily
> distinguished from the ones that still need some work.
> 
> Jiri Denemark (14):
>   cpu: Rename cpuGetModels
>   cpu: Rename and document cpuModelIsAllowed
>   cpu: Rename cpuDataParse
>   cpu: Rename cpuDataFormat
>   cputest: Don't use preferred model for minimum match CPUs
>   cputest: Don't use unsupported preferred model
>   cputest: Don't use preferred model with forbidden fallback
>   cputest: Don't use superfluous preferred model
>   cputest: Don't use preferred CPU model at all
>   cpu: Make models array in virCPUTranslate constant
>   cputest: Don't test cpuGuestData
>   cpu: Introduce virCPUConvertLegacy API
>   cpu: Avoid adding  to custom CPUs
>   cpu: Drop cpuGuestData

These changes don't seem to be user-visible, right? If they
aren't we can safely keep them out of the NEWS file, or
just go for a very broad "CPU driver improvements"...

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH] vz: fixed migration in p2p mode

2016-11-18 Thread Andrea Bolognani
On Mon, 2016-11-14 at 18:20 +0300, Pavel Glushchak wrote:
> dom xml generated on begin step should be passed
> to perform step in VIR_MIGRATE_PARAM_DEST_XML parameter.
> Otherwise 'XML error: failed to parse xml document' is
> raised on destination host as dom xml is NULL.
> 
> Signed-off-by: Pavel Glushchak 
> ---
>  src/vz/vz_driver.c | 5 +
>  1 file changed, 5 insertions(+)

Do you feel like this should be mentioned in the NEWS file?

If so, would you mind proposing a suitable (short, high-level)
description of the change?

Thanks!

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH v2 00/19] Redo website layout and branding

2016-11-18 Thread Andrea Bolognani
On Tue, 2016-11-08 at 11:50 +, Daniel P. Berrange wrote:
> The current libvirt website design dates from 2008 and
> has not changed significantly since. Compared to
> contemporary open source project websites it looks
> pretty dated and cluttered.
> 
> This series incrementally changes the website to have
> a completely new layout and branding.
> 
> Since the original adobe illustrator files are long
> since lost, this series introduces a newly created
> variant of the libvirt logo with Inkscape as an SVG
> file.
> 
> The libvirt logo used a specific font with angled tops
> to letters like "l", "b" and "t" - this is the "Overpass"
> font, made available by Red Hat under an open source
> font license. The re-branding makes use of webfont
> support so that we can use this font across the entire
> libvirt website for a consistent look.
> 
> The colors of the website CSS now exactly match the
> colors used in the logo in most places.
> 
> The bigger change is in the layout, with the huge
> left hand sitemap nav bar being removed to give more
> space to the main content. The front page now directly
> links to the key pages that were shown to be highly
> visited in the apache web logs. Most of the rest of
> the links are now available from the "docs.html" page
> linked from "Learn" in the top nav bar.
> 
> Another key change is that the download page now
> covers all language bindings, test suites, docs
> released by the project, not merely the core C
> library.
> 
> Finally a new page "contribute.html" is added as the
> source of information useful to people wishing to get
> involved in the libvirt project.
> 
> View the new site here
> 
>  v2: https://berrange.fedorapeople.org/libvirt-new-website-v2/
>  v1: https://berrange.fedorapeople.org/libvirt-new-website/
> 
> 
> Changed in v2:
> 
>   - Fix use of monospace font for code/pre blocks
>   - Set max page width to 60em, to avoid body content
> getting really long lines on wide monitors
>   - Extend footer links to include email and irc
> links on all pages
>   - Use the normal weight Overpass font for body
> content
>   - Re-create logos to avoid anti-aliasing by inkscape
> for cripser look
>   - Add some content to the XML format page
>   - Misc typos
>   - Fix hiding of 'home' text in top banner logo
>   - Provide improved SVG files for logo and PNG
> rendered versions in standard sizes
>   - Replace 'made with libvirt' logo with a new
> 'libvirt powered' logo on apps.html page
> 
> Daniel P. Berrange (19):
>   docs: use overpass font for website
>   docs: add master SVG for libvirt logo
>   docs: switch to new website banner
>   docs: redo style of front page
>   docs: provide new style logos for the apps page
>   docs: add footer to all pages
>   docs: simplify style for headers
>   docs: add page describing contribution to libvirt
>   docs: add three core links in the header bar
>   docs: remove todo page
>   docs: remove related links page
>   Revert "syntax-check: Enforce  inside  elements"
>   docs: rewrite content on front page to be more useful
>   docs: expand downloads page to cover all modules
>   docs: add some improved styling to contact page
>   docs: fill out docs page with useful links
>   docs: remove navigation sidebar from pages
>   docs: remove outdated or duplicated content
>   docs: add some content to the XML format main page

Definitely NEWS file material, I would say! :)

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [PATCH] qemu: Redefine the "unlimited" memory limits one more time

2016-11-18 Thread Viktor Mihajlovski
With kernel 3.18 (since commit 3e32cb2e0a12b6915056ff04601cf1bb9b44f967) the
"unlimited" value for cgroup memory limits has changed once again as its byte
value is now computed from a page counter.
The new "unlimited" value reported by the cgroup fs is therefore 2**51-1 pages
which is (VIR_DOMAIN_MEMORY_PARAM_UNLIMITED - 3072). This results e.g. in virsh
memtune displaying 9007199254740988 instead of unlimited for the limits.

This patch deals with the rounding issue by scaling the byte values reported
by the kernel and the PARAM_UNLIMITED value to page size and comparing those.

See also libvirt commit 231656bbeb9e4d3bedc44362784c35eee21cf0f4 for the
history for kernel 3.12 and before.

Signed-off-by: Viktor Mihajlovski 
---
 src/util/vircgroup.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 24917e7..df92ec6 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2542,7 +2542,7 @@ virCgroupGetMemoryHardLimit(virCgroupPtr group, unsigned 
long long *kb)
 goto cleanup;
 
 *kb = limit_in_bytes >> 10;
-if (*kb > VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+if (*kb >> 4 >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED >> 4)
 *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
 ret = 0;
@@ -2604,7 +2604,7 @@ virCgroupGetMemorySoftLimit(virCgroupPtr group, unsigned 
long long *kb)
 goto cleanup;
 
 *kb = limit_in_bytes >> 10;
-if (*kb > VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+if (*kb >> 4 >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED >> 4)
 *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
 ret = 0;
@@ -2666,7 +2666,7 @@ virCgroupGetMemSwapHardLimit(virCgroupPtr group, unsigned 
long long *kb)
 goto cleanup;
 
 *kb = limit_in_bytes >> 10;
-if (*kb > VIR_DOMAIN_MEMORY_PARAM_UNLIMITED)
+if (*kb >> 4 >= VIR_DOMAIN_MEMORY_PARAM_UNLIMITED >> 4)
 *kb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
 
 ret = 0;
-- 
1.9.1

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


Re: [libvirt] [PATCH 0/4] qemu: Assign static slot numbers for memory devices and fix alias generator

2016-11-18 Thread Andrea Bolognani
On Thu, 2016-11-03 at 07:12 +0100, Peter Krempa wrote:
> See patch 4 for explanation of the bug.
> 
> Peter Krempa (4):
>   conf: Allow specifying only the slot number for hotpluggable memory
>   qemu: process: detect if dimm aliases are broken on reconnect
>   qemu: Assign slots to memory devices prior to usage
>   qemu: Generate memory device aliases according to slot number

Even more than the bug fix itself, it looks like 1/4 would be
a good candidate for a NEWS file entry...

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH 0/2] vbox: add support for 5.1.x

2016-11-18 Thread Dawid Zamirski
On Fri, 2016-11-18 at 16:47 +0100, Andrea Bolognani wrote:
> Would you mind drafting one or two short sentences to describe
> the impact of these changes for users? If everything goes
> according to plans[1], they will be added to the NEWS file.
> 
> Thanks!
> 
> 
> [1] Which it often doesn't :)
> -- 
> Andrea Bolognani / Red Hat / Virtualization

Hi Andrea,

Sure, in this case those patches simply enable support of VirtualBox
5.1.x series in libvirt (prior to that libvirt supported vbox 2.x.x to
5.0.x)- and as such it does not affect any previous version that
libvirt supported.  When upstream VirtualBox releases new version
bumping major/minor version tag it is usually coupled with new COM IID
strings that are bundled in the SDK which essentially bumps the VBOX
API version as well. Adding those SDK headers to livirt, enables it to
communicate with the updated VBOX COM interface and avoids "unsupported
API version" error message when one does virsh -c vbox:///session with
VirtualBox 5.1.x installed on the machine.

Regards,
Dawid

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

[libvirt] [PATCH] Revert "vz: fixed race in vzDomainAttach/DettachDevice"

2016-11-18 Thread Maxim Nestratov
This reverts commit 3a6cf6fc16.

Mistakenly this commit was pushed because I thought I missed the
corret one b880ff42ddb while in fact I didn't.

Signed-off-by: Maxim Nestratov 
---
 src/vz/vz_sdk.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index d61bccf..f63b9a3 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3552,12 +3552,6 @@ prlsdkAttachDevice(vzDriverPtr driver,
 return -1;
 }
 
-if (prlsdkUpdateDomain(driver, dom) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-_("Failed to save new config"));
-return -1;
-}
-
 job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
 if (PRL_FAILED(waitDomainJob(job, dom)))
 return -1;
@@ -3623,12 +3617,6 @@ prlsdkDetachDevice(vzDriverPtr driver ATTRIBUTE_UNUSED,
 goto cleanup;
 }
 
-if (prlsdkUpdateDomain(driver, dom) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-_("Failed to save new config"));
-goto cleanup;
-}
-
 job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
 if (PRL_FAILED(waitDomainJob(job, dom)))
 goto cleanup;
-- 
2.4.11

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


[libvirt] [PATCH] NEWS: Start using the improved format

2016-11-18 Thread Andrea Bolognani
This entry is meant to both get the ball rolling on the
switch and to provide a blueprint of what NEWS file entries
are supposed to look like.
---
We need to start somewhere, and what better way than talking
about the change itself? ;)

 docs/news.html.in | 9 +
 1 file changed, 9 insertions(+)

diff --git a/docs/news.html.in b/docs/news.html.in
index d4d..fca1e29 100644
--- a/docs/news.html.in
+++ b/docs/news.html.in
@@ -16,6 +16,15 @@
 to gauge progress.
 
 
+   v2.5.0: unreleased
+   
+ Switch to an improved NEWS file format
+ List user-visible changes instead of single commits for a better
+ high-level overview of differences between libvirt releases
+ 
+ Various bug fixes and improvements
+   
+
v2.4.0: Nov 1 2016
 
   Documentation:
-- 
2.7.4

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


Re: [libvirt] [PATCH 0/2] Allow hotplug of vhost-mq

2016-11-18 Thread Michal Privoznik
On 18.11.2016 16:57, Andrea Bolognani wrote:
> On Fri, 2016-11-04 at 13:28 +0100, Michal Privoznik wrote:
>> Basically this is trivial. Everything is prepared and the only
>> thing that prevented us from doing this was missing exception in
>> one check. Trivial.
>>  
>> Michal Privoznik (2):
>>qemuDomainAttachNetDevice: Don't overwrite error on rollback
>>qemuDomainAttachNetDevice: Enable multiqueue for vhost-user
> 
> Still a good candidate for a NEWS file entry, don't you
> agree? :)
> 

Sure:

Improvements:

With this release, hotplug of vhostuser typed interfaces with multiqueue
feature was enabled. The packet stream from this kind of interfaces can
thus be processed on multiple cores simultaneously enabling higher
performance.

Michal

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


Re: [libvirt] [PATCH 2/2] fs: Fix probing on no-overwrite of target device

2016-11-18 Thread John Ferlan


On 11/18/2016 07:56 AM, Ján Tomko wrote:
> On Tue, Nov 15, 2016 at 06:48:03PM -0500, John Ferlan wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1363586
>>
>> There's actually a couple of bugs here...
>>
>>only the "input" format type, so any other "types" of format would be
> 
> I could a verb.
> 

Hmm... strange...  my fingers must've started drinking early while
merging changes... I inserted patch1 to make patch2 just a little bit
more readable.  Looks like I got distracted whilst trying to create the
commit message here.

>>filtered during the blkid_do_probe resulting in allowing a new format
>>type to overwrite a previous format type since when it's determined a
>>format type cannot be determined that we'd return 0 (or prior to the
>>previous patch a NOT_FOUND value). So instead of passing just one type
>>to filter on, pass the entire list of virStoragePoolFormatFileSystem
>>types. According to recent docs, this call may be unnecessary unless
>>we care about superblock probing only. Ironically, if the on disk
>>format type was the same as the requested format, the code would then
>>fail on the else condition (fixed in #2).
>>
>>was returning -1 (or prior to previous patch FOUND) with an error
>>which caused the caller to just fail.
> 
> Why is that a bug? IIUC we want to error out if a filesystem was found.
> 

I guess my theory was if you have a xfs partition, writing an xfs
partition shouldn't necessarily fail. Sure it rewrites xfs on xfs. I
guess that's why there was a tristate return.

>> So even though it was found
>>it did nothing.  Change that to compare the on disk type with the
>>passed format type and return 0 or -1 as necessary.
>>
>> Signed-off-by: John Ferlan 
>> ---
>> src/storage/storage_backend_fs.c | 26 +-
>> 1 file changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/src/storage/storage_backend_fs.c
>> b/src/storage/storage_backend_fs.c
>> index 2413e82..74b278d 100644
>> --- a/src/storage/storage_backend_fs.c
>> +++ b/src/storage/storage_backend_fs.c
>> @@ -626,7 +626,8 @@ virStorageBackendFileSystemProbe(const char *device,
>> int ret = -1;
>> blkid_probe probe = NULL;
>> const char *fstype = NULL;
>> -char *names[2], *libblkid_format = NULL;
>> +size_t i;
>> +const char *names[VIR_STORAGE_POOL_FS_LAST] = {0};
>>
>> VIR_DEBUG("Probing for existing filesystem of type %s on device %s",
>>   format, device);
>> @@ -648,25 +649,26 @@ virStorageBackendFileSystemProbe(const char
>> *device,
>> goto error;
>> }
>>
>> -if (VIR_STRDUP(libblkid_format, format) < 0)
>> -goto error;
>> -
>> -names[0] = libblkid_format;
>> -names[1] = NULL;
>> +for (i = 1; i < VIR_STORAGE_POOL_FS_LAST; i++)
>> +names[i - 1] = virStoragePoolFormatFileSystemTypeToString(i);
>>
>> blkid_probe_filter_superblocks_type(probe,
>> BLKID_FLTR_ONLYIN,
>> -names);
>> +(char **)names);
>>
> 
> If we want to extend the probing to other filesystem types, then
> removing the filter completely would be a better option.
> 
> But,
> 
> it seems the code intended to only check for the same fs type, not
> others. From virsh pool-build --help:
> 
>--no-overwrite   do not overwrite an existing pool of this type
>--overwrite  overwrite any existing data
> 

Commit id 'ddcd5674a' written with the logic in mind.  Whether the logic
is valid or not is I suppose a matter of interpretation.

> The API constants are described more ambiguously:
> 
> VIR_STORAGE_POOL_BUILD_NO_OVERWRITE =   4
> Do not overwrite existing pool
> VIR_STORAGE_POOL_BUILD_OVERWRITE=   8
> Overwrite data
> 

and the comments to virStorageBackendFileSystemBuild from commit id
'27758859c':

 * If no flag is set, it only makes the directory; If
 * VIR_STORAGE_POOL_BUILD_NO_OVERWRITE set, it probes to determine if
 * filesystem already exists on the target device, renurning an error
 * if exists, or using mkfs to format the target device if not; If
 * VIR_STORAGE_POOL_BUILD_OVERWRITE is set, mkfs is always executed,
 * any existed data on the target device is overwritten unconditionally.

Still the logic/reasoning doesn't seem to be, well logical... So off to
patch history...

v4 of a series...
http://www.redhat.com/archives/libvir-list/2011-August/msg01495.html

v3 of a series...
http://www.redhat.com/archives/libvir-list/2010-June/msg00040.html
http://www.redhat.com/archives/libvir-list/2010-June/msg00042.html

v1/v2 of the series (intermixed)
http://www.redhat.com/archives/libvir-list/2010-May/msg00403.html


All of which imply the logic for no-overwrite (or some sort of probe
failure) was meant to be as is, even though conceptually I'm not sure it
makes proper sense.  It seems as though what happens is that
probe-failure turned 

Re: [libvirt] [PATCH 0/2] Allow hotplug of vhost-mq

2016-11-18 Thread Andrea Bolognani
On Fri, 2016-11-04 at 13:28 +0100, Michal Privoznik wrote:
> Basically this is trivial. Everything is prepared and the only
> thing that prevented us from doing this was missing exception in
> one check. Trivial.
> 
> Michal Privoznik (2):
>   qemuDomainAttachNetDevice: Don't overwrite error on rollback
>   qemuDomainAttachNetDevice: Enable multiqueue for vhost-user

Still a good candidate for a NEWS file entry, don't you
agree? :)

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH v2 00/15] qemu: Add QMP introspection and gluster debug support

2016-11-18 Thread Andrea Bolognani
On Wed, 2016-11-02 at 17:13 +0100, Peter Krempa wrote:
> Now that the release is out, I fixed the few things pointed out.
> 
> Andrea Bolognani (5):
>   tests: qemucaps: Update ppc64 replies for qemu 2.6.0 release
>   tests: qemucaps: Update aarch64 gicv2 replies for qemu 2.6.0 release
>   tests: qemucaps: Add QMP introspection data for qemu 2.6.0 on ppc64le
>   tests: qemucaps: Add QMP introspection data for qemu 2.6.0 on aarch64
> gicv2
>   tests: qemucaps: Add QMP introspection data for qemu 2.6.0 on aarch64
> gicv3
> 
> Pavel Hrdina (3):
>   tests: qemucaps: Add QMP introspection data for qemu 2.5.0 on x86
>   tests: qemucaps: Add QMP introspection data for qemu 2.6.0 on x86
>   tests: qemucaps: Add QMP introspection data for qemu 2.7.0 on x86
> 
> Peter Krempa (4):
>   util: json: add helper to iterate and steal members of json array
>   qemu: monitor: Add code to retrieve and store QMP schema data
>   tests: qemucaps: Temporarily remove 'query-qmp-schema' from test data
>   qemu: capabilities: Add support for QMP schema introspection
> 
> Prasanna Kumar Kalever (3):
>   qemu: capabilities: Detect support for gluster debug setting
>   qemu: conf: add option for tuning debug logging level
>   qemu: command: Add debug option for gluster volumes

The introspection part is an implementation detail, but I
think the gluster debugging support would be worthy of being
mentioned in the NEWS file.

Would you mind drafting an entry for that? :)

-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH 2/8] virlog: Introduce virLog{Get, Set}DefaultOutput

2016-11-18 Thread Erik Skultety
On Wed, Nov 09, 2016 at 11:22:34AM -0500, John Ferlan wrote:
> 
> 
> On 11/01/2016 06:27 AM, Erik Skultety wrote:
> > The reason why we need something like this lies in the daemon's config 
> > where we
> > treat the @log_outputs variable (but not just this one) the very same way in
> > cases where the variable was explicitly set to an empty string or wasn't 
> > set at
> > all, using some default output in both. The selection of a default output
> > depends on whether the daemon runs daemonized or not. Before the runtime
> > logging APIs can be enabled, we need to make sure that the behaviour will 
> > be the
> > same in case someone tries to replace the set of logging outputs with an 
> > empty
> > string, hoping that it would turn the logging off.
> > In order to be able to reset the logging output to some default we either 
> > need
> > to store the daemon mode or we store a default logging output which we'll be
> > able to fallback to later. This patch goes for the latter by introducing new
> > methods to set and retrieve the default logging output.
> 
> The commit message feels like a continuation of the cover and
> justification for a static virLogDefaultOutput.
> 
> The shortened version is - introduce new helpers to handle managing
> output log file defaults and save/fetch of a default log location. This
> patch will store the default
> 
> All these changes should be usable by lib{virtd|logd|lockd}...  Although
> I didn't quite dig into the details of those...
> 

Sigh, I had it on my mind and then the very next day - puff - I completely
forgot about it compiled the patches one last time and sent patches right away
:/

> > 
> > Signed-off-by: Erik Skultety 
> > ---
> >  src/libvirt_private.syms |  2 ++
> >  src/util/virlog.c| 94 
> > 
> >  src/util/virlog.h|  2 ++
> >  3 files changed, 98 insertions(+)
> > 
> > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> > index 162fda5..5b0e07d 100644
> > --- a/src/libvirt_private.syms
> > +++ b/src/libvirt_private.syms
> > @@ -1877,6 +1877,7 @@ virLogFilterFree;
> >  virLogFilterListFree;
> >  virLogFilterNew;
> >  virLogFindOutput;
> > +virLogGetDefaultOutput;
> >  virLogGetDefaultPriority;
> >  virLogGetFilters;
> >  virLogGetNbFilters;
> > @@ -1895,6 +1896,7 @@ virLogParseOutputs;
> >  virLogPriorityFromSyslog;
> >  virLogProbablyLogMessage;
> >  virLogReset;
> > +virLogSetDefaultOutput;
> >  virLogSetDefaultPriority;
> >  virLogSetFilters;
> >  virLogSetFromEnv;
> > diff --git a/src/util/virlog.c b/src/util/virlog.c
> > index 8f831fc..4ac72dc 100644
> > --- a/src/util/virlog.c
> > +++ b/src/util/virlog.c
> > @@ -50,6 +50,7 @@
> >  #include "virtime.h"
> >  #include "intprops.h"
> >  #include "virstring.h"
> > +#include "configmake.h"
> >  
> >  /* Journald output is only supported on Linux new enough to expose
> >   * htole64.  */
> > @@ -105,6 +106,7 @@ struct _virLogOutput {
> >  char *name;
> >  };
> >  
> > +static char *virLogDefaultOutput;
> 
> After reading through to the end, I could see use for a
> virLogDefaultFilter too...  But that's a different problem. Focus,
> focus, focus on the current one ;-)!
>

Well, I'm only doing this because we have to stay consistent with the config
file. The defaults for filters on the other hand do not support any defaults,
you don't set any, you don't have any. I can imagine we could have the same for
the filters as you suggest if libvirt supported something like 'save as default'
which then would make sense for both. But since the outputs defaults are
hard-coded, the difference in the interpretation of the default in both cases
could end up IMHO slightly confusing, but maybe I'm looking at it from the wrong
angle.

> >  static virLogOutputPtr *virLogOutputs;
> >  static size_t virLogNbOutputs;
> >  
> > @@ -146,6 +148,98 @@ virLogUnlock(void)
> >  virMutexUnlock();
> >  }
> >  
> 
> Two spaces between functions (more than one occurrence)
> 
> > +static int
> > +virLogSetDefaultOutputToStderr(void)
> > +{
> > +char *tmp = NULL;
> > +if (virAsprintf(, "%d:stderr", virLogGetDefaultPriority()) < 0)
> > +return -1;
> > +
> > +virLogDefaultOutput = tmp;
> > +return 0;
> 
> Or more simply
> 
> return virAsprintf(, ...);
> 
> of course on error virLogDefaultOutput = NULL;, which shouldn't matter
> since this is only ever being done once

Well I can rewrite it, no problem whatsoever, I just looked at it as if I wrote
any other function, disregarding the fact that it's going to be called once and
once only completely and instead treated it like it's going to be called
regularly and so we should not touch caller's reference if we're not 100% sure
nothing can wrong anymore.

> 
> Also since virLogDefaultPriority is owned here, do you really need the
> virLogGetDefaultPriority() helper?
> 

Yeah, I certainly don't, true that :).

> > +}
> > +
> > +static int
> > 

Re: [libvirt] [PATCH 0/2] vbox: add support for 5.1.x

2016-11-18 Thread Andrea Bolognani
On Mon, 2016-11-07 at 16:03 -0500, Dawid Zamirski wrote:
> With VBox 5.1.x release new SDK header needs to be added to libvirt
> sources. Sending as attachments due to the size of the first patch
> being a large header file taken from VBOX SDK.
> 
> Dawid Zamirski (2):
>   vbox: add vbox 5.1 C API header file.
>   vbox: hookup the 5.1 C API to the unified driver.

Would you mind drafting one or two short sentences to describe
the impact of these changes for users? If everything goes
according to plans[1], they will be added to the NEWS file.

Thanks!


[1] Which it often doesn't :)
-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH v4 0/6] Newer ivshmem models

2016-11-18 Thread Andrea Bolognani
On Wed, 2016-10-26 at 12:51 +0200, Martin Kletzander wrote:
> v4:
>  - Incorporated John's review
> 
> v3:
>  - https://www.redhat.com/archives/libvir-list/2016-September/msg01232.html
> 
> 
> Martin Kletzander (6):
>   conf, qemu: Add support for shmem model
>   conf, qemu: Add newer shmem models
>   qemu: Add capabilities for ivshmem-{plain,doorbell}
>   qemu: Save various defaults for shmem
>   qemu: Support newer ivshmem device variants
>   qemu: Add support for hot/cold-(un)plug of shmem devices

This looks like a user-visible improvement that would
deserve of being highlighted in the NEWS file.

Care to propose such an entry? :)




-- 
Andrea Bolognani / Red Hat / Virtualization

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

Re: [libvirt] [PATCH 2/4] docs: Upgrade Overpass fonts to 3.0

2016-11-18 Thread Daniel P. Berrange
On Fri, Nov 18, 2016 at 03:23:55PM +, Daniel P. Berrange wrote:
> On Fri, Nov 18, 2016 at 04:05:52PM +0100, Martin Kletzander wrote:
> > Since we are useing Overpass for the web pages, we might be using the

s/useing/using/

> > latest version.
> > 
> > Signed-off-by: Martin Kletzander 
> > ---
> > 
> > Notes:
> > I'm not sure where Dan got the hinted versions.  Also what version
> > that is.  The upstream repository of the Overpass font is unusable for
> 
> The previous version was only officially avaiable in TTF format, so I
> used transfonter to generate the web font version:
> 
>   http://transfonter.org/
> 
> I enabled hinting since it was said to display better in Windows, but
> I have no way of checking that personally. I don't think it is particularly
> important - unless you really want to test windows I'd just stick to the
> official woff files.
> 
> > getting any info.  So I also removed 'thin' and 'heavy' versions (with
> > their "extra" variants.
> 
> You seem to have added as many variants as you removed, so not sure about
> this last sentance.

Oh but ACK regardless - please don't resend this huge patch just push
it :-)


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://entangle-photo.org   -o-http://search.cpan.org/~danberr/ :|

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


Re: [libvirt] [PATCH 0/4] docs: User Overpass 3.0 as a font

2016-11-18 Thread Michal Privoznik
On 18.11.2016 16:21, Daniel P. Berrange wrote:
> On Fri, Nov 18, 2016 at 04:05:50PM +0100, Martin Kletzander wrote:
>> I heard Overpass 3.0 was released, so let's update to that.  There are
>> some changes that I noticed.  There are more font weights than we had
>> before.  The one we decided to use is now probably the 'semibold' one.
>> So the regular font is a little thinner, but not as much as the
>> 'light' one.  I think this time it is the perfect middle ground
> 
> Yep, a little bit thinner is exactly what I wanted but couldn't
> get with previous version :-)
> 
>> between the discussed variants in the previous thread.  Also it makes
>> the mono font the same size as the other font.  I kinda like that, but
>> if others don't, we can add font-size: 12px; to the style.
> 
> I think I could see benefit in the monospace font being one or two pt
> smaller that in your screenshot, because monospace text gets very
> wide very quickly

Exactly what I wanted to say. With the current version I can clearly see
difference between say  and the regular test. With your patches
is not that visible in a block of text.

Michal

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


Re: [libvirt] [PATCH 2/4] docs: Upgrade Overpass fonts to 3.0

2016-11-18 Thread Daniel P. Berrange
On Fri, Nov 18, 2016 at 04:05:52PM +0100, Martin Kletzander wrote:
> Since we are useing Overpass for the web pages, we might be using the
> latest version.
> 
> Signed-off-by: Martin Kletzander 
> ---
> 
> Notes:
> I'm not sure where Dan got the hinted versions.  Also what version
> that is.  The upstream repository of the Overpass font is unusable for

The previous version was only officially avaiable in TTF format, so I
used transfonter to generate the web font version:

  http://transfonter.org/

I enabled hinting since it was said to display better in Windows, but
I have no way of checking that personally. I don't think it is particularly
important - unless you really want to test windows I'd just stick to the
official woff files.

> getting any info.  So I also removed 'thin' and 'heavy' versions (with
> their "extra" variants.

You seem to have added as many variants as you removed, so not sure about
this last sentance.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://entangle-photo.org   -o-http://search.cpan.org/~danberr/ :|

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


Re: [libvirt] [PATCH 0/4] docs: User Overpass 3.0 as a font

2016-11-18 Thread Daniel P. Berrange
On Fri, Nov 18, 2016 at 04:05:50PM +0100, Martin Kletzander wrote:
> I heard Overpass 3.0 was released, so let's update to that.  There are
> some changes that I noticed.  There are more font weights than we had
> before.  The one we decided to use is now probably the 'semibold' one.
> So the regular font is a little thinner, but not as much as the
> 'light' one.  I think this time it is the perfect middle ground

Yep, a little bit thinner is exactly what I wanted but couldn't
get with previous version :-)

> between the discussed variants in the previous thread.  Also it makes
> the mono font the same size as the other font.  I kinda like that, but
> if others don't, we can add font-size: 12px; to the style.

I think I could see benefit in the monospace font being one or two pt
smaller that in your screenshot, because monospace text gets very
wide very quickly

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://entangle-photo.org   -o-http://search.cpan.org/~danberr/ :|

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


[libvirt] [PATCH 1/4] docs: Clean-up font definitions

2016-11-18 Thread Martin Kletzander
Some of those were duplicate, so remove those.  In order to better see
such things in the future, sort them so they are "regular, italic,
bold, bold-italic, light, light-italic".

Signed-off-by: Martin Kletzander 
---
 docs/fonts/stylesheet.css | 18 ++
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/docs/fonts/stylesheet.css b/docs/fonts/stylesheet.css
index 4e988519374d..e381bd47be59 100644
--- a/docs/fonts/stylesheet.css
+++ b/docs/fonts/stylesheet.css
@@ -1,19 +1,5 @@
 @font-face {
font-family: 'LibvirtOverpass';
-   src: url('hinted-Overpass-Italic.woff') format('woff');
-   font-weight: normal;
-   font-style: italic;
-}
-
-@font-face {
-   font-family: 'LibvirtOverpass';
-   src: url('hinted-Overpass-Bold.woff') format('woff');
-   font-weight: bold;
-   font-style: normal;
-}
-
-@font-face {
-   font-family: 'LibvirtOverpass';
src: url('hinted-Overpass-Reg.woff') format('woff');
font-weight: normal;
font-style: normal;
@@ -21,9 +7,9 @@

 @font-face {
font-family: 'LibvirtOverpass';
-   src: url('hinted-Overpass-Reg.woff') format('woff');
+   src: url('hinted-Overpass-Italic.woff') format('woff');
font-weight: normal;
-   font-style: normal;
+   font-style: italic;
 }

 @font-face {
-- 
2.10.2

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


[libvirt] [PATCH] tests: Adapt to gluster_debug_level in qemu.conf

2016-11-18 Thread Michal Privoznik
After a944bd92 we gained support for setting gluster debug level.
However, due to stupid space we haven't tested whether augeas
file actually works.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu.conf | 2 +-
 src/qemu/test_libvirtd_qemu.aug.in | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 070d37b..2b2bd60 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -664,4 +664,4 @@
 #
 # Defaults to 4
 #
-# gluster_debug_level = 9
+#gluster_debug_level = 9
diff --git a/src/qemu/test_libvirtd_qemu.aug.in 
b/src/qemu/test_libvirtd_qemu.aug.in
index 805fa0e..f586e95 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -90,3 +90,4 @@ module Test_libvirtd_qemu =
 { "3" = "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd" }
 }
 { "stdio_handler" = "logd" }
+{ "gluster_debug_level" = "9" }
-- 
2.8.4

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


[libvirt] [PATCH 3/4] docs: Add monospaced Overpass fonts

2016-11-18 Thread Martin Kletzander
Overpass 3.0 has monospaced fonts, so why not have the same font for
the monospaced parts of the documentation.

Signed-off-by: Martin Kletzander 
---
 docs/fonts/stylesheet.css | 21 +
 1 file changed, 21 insertions(+)

diff --git a/docs/fonts/stylesheet.css b/docs/fonts/stylesheet.css
index 9b86bc448116..1a06f22c35e3 100644
--- a/docs/fonts/stylesheet.css
+++ b/docs/fonts/stylesheet.css
@@ -39,3 +39,24 @@
font-weight: 300;
font-style: italic;
 }
+
+@font-face {
+   font-family: 'LibvirtOverpassMono';
+   src: url('overpass-mono-regular.woff') format('woff');
+   font-weight: normal;
+   font-style: normal;
+}
+
+@font-face {
+   font-family: 'LibvirtOverpassMono';
+   src: url('overpass-mono-bold.woff') format('woff');
+   font-weight: bold;
+   font-style: normal;
+}
+
+@font-face {
+   font-family: 'LibvirtOverpassMonoLight';
+   src: url('overpass-mono-light.woff') format('woff');
+   font-weight: 300;
+   font-style: normal;
+}
-- 
2.10.2

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


[libvirt] [PATCH 4/4] docs: Use Overpass Mono as the monospace font

2016-11-18 Thread Martin Kletzander
Signed-off-by: Martin Kletzander 
---
 docs/generic.css | 4 
 1 file changed, 4 insertions(+)

diff --git a/docs/generic.css b/docs/generic.css
index 02383017a91b..f7083b6e6c7f 100644
--- a/docs/generic.css
+++ b/docs/generic.css
@@ -71,3 +71,7 @@ h6 {
   margin-top: 0.75em;
   font-size: 0.8em;
 }
+
+code, pre {
+  font-family: LibvirtOverpassMono;
+}
-- 
2.10.2

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


[libvirt] [PATCH 0/4] docs: User Overpass 3.0 as a font

2016-11-18 Thread Martin Kletzander
I heard Overpass 3.0 was released, so let's update to that.  There are
some changes that I noticed.  There are more font weights than we had
before.  The one we decided to use is now probably the 'semibold' one.
So the regular font is a little thinner, but not as much as the
'light' one.  I think this time it is the perfect middle ground
between the discussed variants in the previous thread.  Also it makes
the mono font the same size as the other font.  I kinda like that, but
if others don't, we can add font-size: 12px; to the style.

Here is side-by-side comparison on my screen:

  http://people.redhat.com/~mkletzan/libvirt-newfonts.png


Martin Kletzander (4):
  docs: Clean-up font definitions
  docs: Upgrade Overpass fonts to 3.0
  docs: Add monospaced Overpass fonts
  docs: Use Overpass Mono as the monospace font

 docs/fonts/hinted-Overpass-Bold.woff| Bin 48136 -> 0 bytes
 docs/fonts/hinted-Overpass-BoldItalic.woff  | Bin 51008 -> 0 bytes
 docs/fonts/hinted-Overpass-Italic.woff  | Bin 51908 -> 0 bytes
 docs/fonts/hinted-Overpass-Light.woff   | Bin 49452 -> 0 bytes
 docs/fonts/hinted-Overpass-LightItalic.woff | Bin 51752 -> 0 bytes
 docs/fonts/hinted-Overpass-Reg.woff | Bin 48144 -> 0 bytes
 docs/fonts/overpass-bold-italic.woff| Bin 0 -> 46524 bytes
 docs/fonts/overpass-bold.woff   | Bin 0 -> 43612 bytes
 docs/fonts/overpass-italic.woff | Bin 0 -> 46744 bytes
 docs/fonts/overpass-light-italic.woff   | Bin 0 -> 45844 bytes
 docs/fonts/overpass-light.woff  | Bin 0 -> 43576 bytes
 docs/fonts/overpass-regular.woff| Bin 0 -> 44272 bytes
 docs/fonts/stylesheet.css   |  49 
 docs/generic.css|   4 +++
 14 files changed, 32 insertions(+), 21 deletions(-)
 delete mode 100644 docs/fonts/hinted-Overpass-Bold.woff
 delete mode 100644 docs/fonts/hinted-Overpass-BoldItalic.woff
 delete mode 100644 docs/fonts/hinted-Overpass-Italic.woff
 delete mode 100644 docs/fonts/hinted-Overpass-Light.woff
 delete mode 100644 docs/fonts/hinted-Overpass-LightItalic.woff
 delete mode 100644 docs/fonts/hinted-Overpass-Reg.woff
 create mode 100644 docs/fonts/overpass-bold-italic.woff
 create mode 100644 docs/fonts/overpass-bold.woff
 create mode 100644 docs/fonts/overpass-italic.woff
 create mode 100644 docs/fonts/overpass-light-italic.woff
 create mode 100644 docs/fonts/overpass-light.woff
 create mode 100644 docs/fonts/overpass-regular.woff

--
2.10.2

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


[libvirt] [PATCH 08/11] iscsi: Converge more createVport checks

2016-11-18 Thread John Ferlan
Remove duplicated code - make one path through

Signed-off-by: John Ferlan 
---
 src/storage/storage_backend_scsi.c | 35 +++
 1 file changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c 
b/src/storage/storage_backend_scsi.c
index 9863880..df48b1a 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -722,39 +722,26 @@ createVport(virConnectPtr conn,
 goto cleanup;
 }
 
-/* If a parent was provided, then let's make sure it's vhost capable */
 if (adapter->data.fchost.parent) {
-if (virGetSCSIHostNumber(adapter->data.fchost.parent, _host) < 
0)
-return -1;
-
-if (!virIsCapableFCHost(NULL, parent_host)) {
-virReportError(VIR_ERR_XML_ERROR,
-   _("parent '%s' specified for vHBA "
- "is not vport capable"),
-   adapter->data.fchost.parent);
-return -1;
-}
-}
-
-if (!adapter->data.fchost.parent) {
+if (VIR_STRDUP(parent_hoststr, adapter->data.fchost.parent) < 0)
+goto cleanup;
+} else {
 if (!(parent_hoststr = virFindFCHostCapableVport(NULL))) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
_("'parent' for vHBA not specified, and "
  "cannot find one on this host"));
 goto cleanup;
 }
+}
 
-if (virGetSCSIHostNumber(parent_hoststr, _host) < 0)
-goto cleanup;
+if (virGetSCSIHostNumber(parent_hoststr, _host) < 0)
+goto cleanup;
 
-/* NOTE:
- * We do not save the parent_hoststr in adapter->data.fchost.parent
- * since we could be writing out the 'def' to the saved XML config.
- * If we wrote out the name in the XML, then future starts would
- * always use the same parent rather than finding the "best available"
- * parent. Besides we have a way to determine the parent based on
- * the 'name' field.
- */
+if (adapter->data.fchost.parent && !virIsCapableFCHost(NULL, parent_host)) 
{
+virReportError(VIR_ERR_XML_ERROR,
+   _("parent '%s' specified for vHBA is not vport 
capable"),
+   parent_hoststr);
+goto cleanup;
 }
 
 /* Since we're creating the vHBA, then we need to manage removing it
-- 
2.7.4

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


[libvirt] [PATCH 10/11] util: Introduce virGetFCHostNameByFabricWWN

2016-11-18 Thread John Ferlan
Create a utility routine in order to read the scsi_host fabric_name files
looking for a match to a passed fabric_name

Signed-off-by: John Ferlan 
---
 src/libvirt_private.syms |  1 +
 src/util/virutil.c   | 86 
 src/util/virutil.h   |  4 +++
 3 files changed, 78 insertions(+), 13 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 5673bda..3921897 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2620,6 +2620,7 @@ virGetDeviceID;
 virGetDeviceUnprivSGIO;
 virGetEnvAllowSUID;
 virGetEnvBlockSUID;
+virGetFCHostNameByFabricWWN;
 virGetFCHostNameByWWN;
 virGetGroupID;
 virGetGroupList;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index a135819..fb72f2d 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2166,6 +2166,18 @@ virManageVport(const int parent_host,
 return ret;
 }
 
+# define READ_WWN(wwn_path, buf)  \
+do {  \
+if (virFileReadAll(wwn_path, 1024, ) < 0) \
+goto cleanup; \
+if ((p = strchr(buf, '\n')))  \
+*p = '\0';\
+if (STRPREFIX(buf, "0x")) \
+p = buf + strlen("0x");   \
+else  \
+p = buf;  \
+} while (0)
+
 /* virGetFCHostNameByWWN:
  *
  * Iterate over the sysfs tree to get FC host name (e.g. host5)
@@ -2192,18 +2204,6 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
 if (virDirOpen(, prefix) < 0)
 return NULL;
 
-# define READ_WWN(wwn_path, buf)  \
-do {  \
-if (virFileReadAll(wwn_path, 1024, ) < 0) \
-goto cleanup; \
-if ((p = strchr(buf, '\n')))  \
-*p = '\0';\
-if (STRPREFIX(buf, "0x")) \
-p = buf + strlen("0x");   \
-else  \
-p = buf;  \
-} while (0)
-
 while (virDirRead(dir, , prefix) > 0) {
 VIR_FREE(wwnn_buf);
 VIR_FREE(wwnn_path);
@@ -2239,7 +2239,6 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
 }
 
  cleanup:
-# undef READ_WWN
 VIR_DIR_CLOSE(dir);
 VIR_FREE(wwnn_path);
 VIR_FREE(wwpn_path);
@@ -2248,6 +2247,67 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
 return ret;
 }
 
+/* virGetFCHostNameByFabricWWN:
+ *
+ * Iterate over the sysfs tree to get FC host name (e.g. host5)
+ * by the provided "fabric_wwn". This would find a host on a SAN.
+ *
+ * Returns the FC host name which must be freed by the caller,
+ * or NULL on failure.
+ */
+char *
+virGetFCHostNameByFabricWWN(const char *sysfs_prefix,
+const char *fabric_wwn)
+{
+const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH;
+struct dirent *entry = NULL;
+DIR *dir = NULL;
+char *fabric_wwn_path = NULL;
+char *fabric_wwn_buf = NULL;
+char *vport_create_path = NULL;
+char *p;
+char *ret = NULL;
+
+if (virDirOpen(, prefix) < 0)
+return NULL;
+
+while (virDirRead(dir, , prefix) > 0) {
+VIR_FREE(fabric_wwn_path);
+VIR_FREE(fabric_wwn_buf);
+VIR_FREE(vport_create_path);
+
+if (virAsprintf(_wwn_path, "%s/%s/fabric_name", prefix,
+entry->d_name) < 0)
+goto cleanup;
+
+/* Existing vHBA's will have the same fabric_name, but won't
+ * have the vport_create file - so we check for both */
+if (virAsprintf(_create_path, "%s/%s/vport_create", prefix,
+entry->d_name) < 0)
+goto cleanup;
+
+if (!virFileExists(fabric_wwn_path) ||
+!virFileExists(vport_create_path))
+continue;
+
+READ_WWN(fabric_wwn_path, fabric_wwn_buf);
+
+if (STRNEQ(fabric_wwn, p))
+continue;
+
+ignore_value(VIR_STRDUP(ret, entry->d_name));
+break;
+}
+
+ cleanup:
+VIR_DIR_CLOSE(dir);
+VIR_FREE(fabric_wwn_path);
+VIR_FREE(fabric_wwn_buf);
+VIR_FREE(vport_create_path);
+return ret;
+}
+# undef READ_WWN
+
 # define PORT_STATE_ONLINE "Online"
 
 /* virFindFCHostCapableVport:
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 8c0d83c..3fbd7b0 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -206,6 +206,10 @@ char *virGetFCHostNameByWWN(const char *sysfs_prefix,
 const char *wwpn)
 ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
 
+char *virGetFCHostNameByFabricWWN(const char *sysfs_prefix,
+  const char *fabric_wwn)
+

[libvirt] [PATCH 11/11] iscsi: Add parent wwnn/wwpn or fabric capability for createVport

2016-11-18 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1349696

As it turns out using only the 'parent' to achieve the goal of a
consistent vHBA parent has issues with reboots where the scsi_hostX
parent could change to scsi_hostY causing either failure to create
the vHBA or usage of the wrong HBA for our vHBA.

Thus add the ability to search for the "parent" by the parent wwnn/
wwpn values or just a fabric_name if someone only cares to ensure
usage of the same SAN for the vHBA.

Signed-off-by: John Ferlan 
---
 src/storage/storage_backend_scsi.c | 23 +--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c 
b/src/storage/storage_backend_scsi.c
index df48b1a..4f13d5c 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -695,6 +695,7 @@ createVport(virConnectPtr conn,
 unsigned int parent_host;
 char *name = NULL;
 char *parent_hoststr = NULL;
+bool skip_capable_check = false;
 virStoragePoolFCRefreshInfoPtr cbdata = NULL;
 virThread thread;
 int ret = -1;
@@ -725,6 +726,23 @@ createVport(virConnectPtr conn,
 if (adapter->data.fchost.parent) {
 if (VIR_STRDUP(parent_hoststr, adapter->data.fchost.parent) < 0)
 goto cleanup;
+} else if (adapter->data.fchost.parent_wwnn &&
+   adapter->data.fchost.parent_wwpn) {
+if (!(parent_hoststr =
+  virGetFCHostNameByWWN(NULL, adapter->data.fchost.parent_wwnn,
+adapter->data.fchost.parent_wwpn))) {
+virReportError(VIR_ERR_XML_ERROR, "%s",
+   _("cannot find parent using provided wwnn/wwpn"));
+goto cleanup;
+}
+} else if (adapter->data.fchost.parent_fabric_wwn) {
+if (!(parent_hoststr =
+  virGetFCHostNameByFabricWWN(NULL,
+  
adapter->data.fchost.parent_fabric_wwn))) {
+virReportError(VIR_ERR_XML_ERROR, "%s",
+   _("cannot find parent using provided fabric_wwn"));
+goto cleanup;
+}
 } else {
 if (!(parent_hoststr = virFindFCHostCapableVport(NULL))) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -732,14 +750,15 @@ createVport(virConnectPtr conn,
  "cannot find one on this host"));
 goto cleanup;
 }
+skip_capable_check = true;
 }
 
 if (virGetSCSIHostNumber(parent_hoststr, _host) < 0)
 goto cleanup;
 
-if (adapter->data.fchost.parent && !virIsCapableFCHost(NULL, parent_host)) 
{
+if (!skip_capable_check && !virIsCapableFCHost(NULL, parent_host)) {
 virReportError(VIR_ERR_XML_ERROR,
-   _("parent '%s' specified for vHBA is not vport 
capable"),
+   _("parent '%s' is not vport capable"),
parent_hoststr);
 goto cleanup;
 }
-- 
2.7.4

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


[libvirt] [PATCH 09/11] util: Remove need for extra VIR_FREE's in virGetFCHostNameByWWN

2016-11-18 Thread John Ferlan
Rather than extraneous VIR_FREE's depending on where we are in the code,
move them to the top of the loop and in the cleanup path.

Signed-off-by: John Ferlan 
---
 src/util/virutil.c | 27 +--
 1 file changed, 9 insertions(+), 18 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index 844c947..a135819 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2205,43 +2205,34 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
 } while (0)
 
 while (virDirRead(dir, , prefix) > 0) {
+VIR_FREE(wwnn_buf);
+VIR_FREE(wwnn_path);
+VIR_FREE(wwpn_buf);
+VIR_FREE(wwpn_path);
+
 if (virAsprintf(_path, "%s/%s/node_name", prefix,
 entry->d_name) < 0)
 goto cleanup;
 
-if (!virFileExists(wwnn_path)) {
-VIR_FREE(wwnn_path);
+if (!virFileExists(wwnn_path))
 continue;
-}
 
 READ_WWN(wwnn_path, wwnn_buf);
 
-if (STRNEQ(wwnn, p)) {
-VIR_FREE(wwnn_buf);
-VIR_FREE(wwnn_path);
+if (STRNEQ(wwnn, p))
 continue;
-}
 
 if (virAsprintf(_path, "%s/%s/port_name", prefix,
 entry->d_name) < 0)
 goto cleanup;
 
-if (!virFileExists(wwpn_path)) {
-VIR_FREE(wwnn_buf);
-VIR_FREE(wwnn_path);
-VIR_FREE(wwpn_path);
+if (!virFileExists(wwpn_path))
 continue;
-}
 
 READ_WWN(wwpn_path, wwpn_buf);
 
-if (STRNEQ(wwpn, p)) {
-VIR_FREE(wwnn_path);
-VIR_FREE(wwpn_path);
-VIR_FREE(wwnn_buf);
-VIR_FREE(wwpn_buf);
+if (STRNEQ(wwpn, p))
 continue;
-}
 
 ignore_value(VIR_STRDUP(ret, entry->d_name));
 break;
-- 
2.7.4

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


[libvirt] [PATCH 06/11] iscsi: Clean up createVport exit paths

2016-11-18 Thread John Ferlan
Use the ret = -1, goto cleanup, etc. rather than current hodgepodge.

Signed-off-by: John Ferlan 
---
 src/storage/storage_backend_scsi.c | 34 --
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c 
b/src/storage/storage_backend_scsi.c
index 99504f4..cf93fdc 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -697,6 +697,7 @@ createVport(virConnectPtr conn,
 char *parent_hoststr = NULL;
 virStoragePoolFCRefreshInfoPtr cbdata = NULL;
 virThread thread;
+int ret = -1;
 
 if (adapter->type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)
 return 0;
@@ -725,17 +726,14 @@ createVport(virConnectPtr conn,
  */
 if ((name = virGetFCHostNameByWWN(NULL, adapter->data.fchost.wwnn,
   adapter->data.fchost.wwpn))) {
-int retval = 0;
-
 /* If a parent was provided, let's make sure the 'name' we've
  * retrieved has the same parent
  */
 if (adapter->data.fchost.parent &&
-!checkVhbaSCSIHostParent(conn, name, adapter->data.fchost.parent))
-retval = -1;
+checkVhbaSCSIHostParent(conn, name, adapter->data.fchost.parent))
+ret = 0;
 
-VIR_FREE(name);
-return retval;
+goto cleanup;
 }
 
 if (!adapter->data.fchost.parent) {
@@ -743,13 +741,11 @@ createVport(virConnectPtr conn,
 virReportError(VIR_ERR_XML_ERROR, "%s",
_("'parent' for vHBA not specified, and "
  "cannot find one on this host"));
-return -1;
+goto cleanup;
 }
 
-if (virGetSCSIHostNumber(parent_hoststr, _host) < 0) {
-VIR_FREE(parent_hoststr);
-return -1;
-}
+if (virGetSCSIHostNumber(parent_hoststr, _host) < 0)
+goto cleanup;
 
 /* NOTE:
  * We do not save the parent_hoststr in adapter->data.fchost.parent
@@ -759,7 +755,6 @@ createVport(virConnectPtr conn,
  * parent. Besides we have a way to determine the parent based on
  * the 'name' field.
  */
-VIR_FREE(parent_hoststr);
 }
 
 /* Since we're creating the vHBA, then we need to manage removing it
@@ -771,13 +766,13 @@ createVport(virConnectPtr conn,
 adapter->data.fchost.managed = VIR_TRISTATE_BOOL_YES;
 if (configFile) {
 if (virStoragePoolSaveConfig(configFile, pool->def) < 0)
-return -1;
+goto cleanup;
 }
 }
 
 if (virManageVport(parent_host, adapter->data.fchost.wwpn,
adapter->data.fchost.wwnn, VPORT_CREATE) < 0)
-return -1;
+goto cleanup;
 
 virFileWaitForDevices();
 
@@ -790,8 +785,7 @@ createVport(virConnectPtr conn,
   adapter->data.fchost.wwpn))) {
 if (VIR_ALLOC(cbdata) == 0) {
 memcpy(cbdata->pool_uuid, pool->def->uuid, VIR_UUID_BUFLEN);
-cbdata->fchost_name = name;
-name = NULL;
+VIR_STEAL_PTR(cbdata->fchost_name, name);
 
 if (virThreadCreate(, false, virStoragePoolFCRefreshThread,
 cbdata) < 0) {
@@ -800,10 +794,14 @@ createVport(virConnectPtr conn,
 virStoragePoolFCRefreshDataFree(cbdata);
 }
 }
-VIR_FREE(name);
 }
 
-return 0;
+ret = 0;
+
+ cleanup:
+VIR_FREE(name);
+VIR_FREE(parent_hoststr);
+return ret;
 }
 
 static int
-- 
2.7.4

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


[libvirt] [PATCH 07/11] iscsi: Change order of checks in createVport

2016-11-18 Thread John Ferlan
Move the check for an already existing vHBA to the top of the function.
No sense in first decoding a provided parent if the next thing we're going
to do is fail if a provided wwnn/wwpn already exists.

Signed-off-by: John Ferlan 
---
 src/storage/storage_backend_scsi.c | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/storage/storage_backend_scsi.c 
b/src/storage/storage_backend_scsi.c
index cf93fdc..9863880 100644
--- a/src/storage/storage_backend_scsi.c
+++ b/src/storage/storage_backend_scsi.c
@@ -706,20 +706,6 @@ createVport(virConnectPtr conn,
   conn, NULLSTR(configFile), NULLSTR(adapter->data.fchost.parent),
   adapter->data.fchost.wwnn, adapter->data.fchost.wwpn);
 
-/* If a parent was provided, then let's make sure it's vhost capable */
-if (adapter->data.fchost.parent) {
-if (virGetSCSIHostNumber(adapter->data.fchost.parent, _host) < 
0)
-return -1;
-
-if (!virIsCapableFCHost(NULL, parent_host)) {
-virReportError(VIR_ERR_XML_ERROR,
-   _("parent '%s' specified for vHBA "
- "is not vport capable"),
-   adapter->data.fchost.parent);
-return -1;
-}
-}
-
 /* If we find an existing HBA/vHBA within the fc_host sysfs
  * using the wwnn/wwpn, then a nodedev is already created for
  * this pool and we don't have to create the vHBA
@@ -736,6 +722,20 @@ createVport(virConnectPtr conn,
 goto cleanup;
 }
 
+/* If a parent was provided, then let's make sure it's vhost capable */
+if (adapter->data.fchost.parent) {
+if (virGetSCSIHostNumber(adapter->data.fchost.parent, _host) < 
0)
+return -1;
+
+if (!virIsCapableFCHost(NULL, parent_host)) {
+virReportError(VIR_ERR_XML_ERROR,
+   _("parent '%s' specified for vHBA "
+ "is not vport capable"),
+   adapter->data.fchost.parent);
+return -1;
+}
+}
+
 if (!adapter->data.fchost.parent) {
 if (!(parent_hoststr = virFindFCHostCapableVport(NULL))) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
-- 
2.7.4

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


[libvirt] [PATCH 01/11] nodedev: Fix crash in libvirtd on vHBA creation path

2016-11-18 Thread John Ferlan
Providing XML such as:


  vhba
  


  


would crash libvirt because the '' isn't a required field, but
for vHBA creation it's expected (day 1 issue - see commit id '81d0ffbc').
The nodedev.rng added in commit id '2c22a68c' has this as an optional field.
NB: On normal udev discovery if a parent field wasn't found, it would be
set to "computer" by udevSetParent, so this is a somewhat unique path.

Signed-off-by: John Ferlan 
---
 src/conf/node_device_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 1cd0baf..bf5b22f 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -118,7 +118,7 @@ virNodeDeviceObjPtr 
virNodeDeviceFindByName(virNodeDeviceObjListPtr devs,
 
 for (i = 0; i < devs->count; i++) {
 virNodeDeviceObjLock(devs->objs[i]);
-if (STREQ(devs->objs[i]->def->name, name))
+if (STREQ_NULLABLE(devs->objs[i]->def->name, name))
 return devs->objs[i];
 virNodeDeviceObjUnlock(devs->objs[i]);
 }
-- 
2.7.4

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


[libvirt] [PATCH 05/11] conf: Add more fchost search fields for storage pool vHBA creation

2016-11-18 Thread John Ferlan
Add new fields to the fchost structure to allow creation of a vHBA via
the storage pool when a parent_wwnn/parent_wwpn or parent_fabric_wwn is
supplied in the storage pool XML.

Signed-off-by: John Ferlan 
---
 docs/schemas/basictypes.rng | 15 +++
 src/conf/storage_conf.c | 21 +++--
 src/conf/storage_conf.h |  3 +++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/docs/schemas/basictypes.rng b/docs/schemas/basictypes.rng
index 1b4f980..cc560e6 100644
--- a/docs/schemas/basictypes.rng
+++ b/docs/schemas/basictypes.rng
@@ -427,6 +427,21 @@
   
 
   
+  
+
+  
+
+  
+  
+
+  
+
+  
+  
+
+  
+
+  
   
 
   
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 7e7bb72..25fb983 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -335,6 +335,9 @@ 
virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapterPtr adapter)
 VIR_FREE(adapter->data.fchost.wwnn);
 VIR_FREE(adapter->data.fchost.wwpn);
 VIR_FREE(adapter->data.fchost.parent);
+VIR_FREE(adapter->data.fchost.parent_wwnn);
+VIR_FREE(adapter->data.fchost.parent_wwpn);
+VIR_FREE(adapter->data.fchost.parent_fabric_wwn);
 } else if (adapter->type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
 VIR_FREE(adapter->data.scsi_host.name);
@@ -591,10 +594,17 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
 }
 }
 
-source->adapter.data.fchost.wwnn =
-virXPathString("string(./adapter/@wwnn)", ctxt);
+source->adapter.data.fchost.parent_wwnn =
+virXPathString("string(./adapter/@parent_wwnn)", ctxt);
+source->adapter.data.fchost.parent_wwpn =
+virXPathString("string(./adapter/@parent_wwpn)", ctxt);
+source->adapter.data.fchost.parent_fabric_wwn =
+virXPathString("string(./adapter/@parent_fabric_wwn)", ctxt);
+
 source->adapter.data.fchost.wwpn =
 virXPathString("string(./adapter/@wwpn)", ctxt);
+source->adapter.data.fchost.wwnn =
+virXPathString("string(./adapter/@wwnn)", ctxt);
 } else if (source->adapter.type ==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {
 
@@ -1100,6 +1110,13 @@ virStoragePoolSourceFormat(virBufferPtr buf,
 if (src->adapter.data.fchost.managed)
 virBufferAsprintf(buf, " managed='%s'",
   
virTristateBoolTypeToString(src->adapter.data.fchost.managed));
+virBufferEscapeString(buf, " parent_wwnn='%s'",
+  src->adapter.data.fchost.parent_wwnn);
+virBufferEscapeString(buf, " parent_wwpn='%s'",
+  src->adapter.data.fchost.parent_wwpn);
+virBufferEscapeString(buf, " parent_fabric_wwn='%s'",
+  src->adapter.data.fchost.parent_fabric_wwn);
+
 virBufferAsprintf(buf, " wwnn='%s' wwpn='%s'/>\n",
   src->adapter.data.fchost.wwnn,
   src->adapter.data.fchost.wwpn);
diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
index 185ae5e..b35471d 100644
--- a/src/conf/storage_conf.h
+++ b/src/conf/storage_conf.h
@@ -193,6 +193,9 @@ struct _virStoragePoolSourceAdapter {
 } scsi_host;
 struct {
 char *parent;
+char *parent_wwnn;
+char *parent_wwpn;
+char *parent_fabric_wwn;
 char *wwnn;
 char *wwpn;
 int managed;/* enum virTristateSwitch */
-- 
2.7.4

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


[libvirt] [PATCH 04/11] nodedev: Add the ability to create vHBA by parent wwnn/wwpn or fabric_wwn

2016-11-18 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1349696

When creating a vHBA, the process is to feed XML to nodeDeviceCreateXML
that lists the  scsi_hostX to use to create the vHBA. However,
between reboots, it's possible that the  changes its scsi_hostX
to scsi_hostY and saved XML to perform the creation will either fail or
create a vHBA using the wrong parent.

So add the ability to provide  and  or
 in order to use those values as more consistent
search parameters. For some providing the wwnn/wwpn pair will provide
the most specific search option, while for others providing a fabric_wwn
will at least ensure usage of the same SAN.

This patch will add the new fields to the nodedev.rng for input purposes
only since the input XML is essentially thrown away, no need to Format
the values since they'd already be printed as part of the scsi_host
data block.

New API virNodeDeviceGetParentHostByWWNs will take the parent_wwnn and
parent_wwpn in order to search the list of devices for matching capability
data fields wwnn and wwpn.

New API virNodeDeviceGetParentHostByFabricWWN will take the parent_fabric_wwn
in order to search the list of devices for matching capability data field
fabric_wwn.

Signed-off-by: John Ferlan 
---
 docs/schemas/nodedev.rng |  15 +
 src/conf/node_device_conf.c  | 120 +++
 src/conf/node_device_conf.h  |  14 
 src/libvirt_private.syms |   2 +
 src/node_device/node_device_driver.c |  13 
 5 files changed, 164 insertions(+)

diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng
index 93a88d8..6fe49a3 100644
--- a/docs/schemas/nodedev.rng
+++ b/docs/schemas/nodedev.rng
@@ -18,6 +18,21 @@
   
 
   
+  
+
+  
+
+  
+  
+
+  
+
+  
+  
+
+  
+
+  
 
   
 
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 3aa77cf..cecd915 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -92,6 +92,30 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, const 
char *cap)
 }
 
 
+/* virNodeDeviceFindFCCapDef:
+ * @dev: Pointer to current device
+ *
+ * Search the device object 'caps' array for fc_host capability.
+ *
+ * Returns:
+ * Pointer to the caps or NULL if not found
+ */
+static virNodeDevCapsDefPtr
+virNodeDeviceFindFCCapDef(const virNodeDeviceObj *dev)
+{
+virNodeDevCapsDefPtr caps = dev->def->caps;
+
+while (caps) {
+if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST &&
+(caps->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST))
+break;
+
+caps = caps->next;
+}
+return caps;
+}
+
+
 /* virNodeDeviceFindVPORTCapDef:
  * @dev: Pointer to current device
  *
@@ -152,6 +176,46 @@ virNodeDeviceObjPtr 
virNodeDeviceFindByName(virNodeDeviceObjListPtr devs,
 
 
 static virNodeDeviceObjPtr
+virNodeDeviceFindByWWNs(virNodeDeviceObjListPtr devs,
+const char *parent_wwnn,
+const char *parent_wwpn)
+{
+size_t i;
+
+for (i = 0; i < devs->count; i++) {
+virNodeDevCapsDefPtr cap;
+virNodeDeviceObjLock(devs->objs[i]);
+if ((cap = virNodeDeviceFindFCCapDef(devs->objs[i])) &&
+STREQ_NULLABLE(cap->data.scsi_host.wwnn, parent_wwnn) &&
+STREQ_NULLABLE(cap->data.scsi_host.wwpn, parent_wwpn))
+return devs->objs[i];
+virNodeDeviceObjUnlock(devs->objs[i]);
+}
+
+return NULL;
+}
+
+
+static virNodeDeviceObjPtr
+virNodeDeviceFindByFabricWWN(virNodeDeviceObjListPtr devs,
+ const char *parent_fabric_wwn)
+{
+size_t i;
+
+for (i = 0; i < devs->count; i++) {
+virNodeDevCapsDefPtr cap;
+virNodeDeviceObjLock(devs->objs[i]);
+if ((cap = virNodeDeviceFindFCCapDef(devs->objs[i])) &&
+STREQ_NULLABLE(cap->data.scsi_host.fabric_wwn, parent_fabric_wwn))
+return devs->objs[i];
+virNodeDeviceObjUnlock(devs->objs[i]);
+}
+
+return NULL;
+}
+
+
+static virNodeDeviceObjPtr
 virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs,
const char *cap)
 {
@@ -177,6 +241,9 @@ void virNodeDeviceDefFree(virNodeDeviceDefPtr def)
 
 VIR_FREE(def->name);
 VIR_FREE(def->parent);
+VIR_FREE(def->parent_wwnn);
+VIR_FREE(def->parent_wwpn);
+VIR_FREE(def->parent_fabric_wwn);
 VIR_FREE(def->driver);
 VIR_FREE(def->sysfs_path);
 VIR_FREE(def->parent_sysfs_path);
@@ -1652,6 +1719,10 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
 
 /* Extract device parent, if any */
 def->parent = virXPathString("string(./parent[1])", ctxt);
+def->parent_wwnn = virXPathString("string(./parent_wwnn[1])", ctxt);
+def->parent_wwpn = virXPathString("string(./parent_wwpn[1])", ctxt);
+def->parent_fabric_wwn = 

[libvirt] [PATCH 02/11] nodedev: Create helpers to search for vport capable nodedevs

2016-11-18 Thread John Ferlan
Extract out code from virNodeDeviceGetParentHost into helpers - it's
going to be reused in upcoming patches to search on more fields

Create virNodeDeviceFindVPORTCapDef in order to return a virNodeDevCapsDefPtr
of the VPORT_OPS and virNodeDeviceFindFCParentHost to use the function and
generate an error message if the device doesn't have the capability.

Also clean up the processing in virNodeDeviceGetParentHost to remove
need for goto's.

Signed-off-by: John Ferlan 
---
 src/conf/node_device_conf.c | 83 +++--
 1 file changed, 57 insertions(+), 26 deletions(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index bf5b22f..5396681 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -92,6 +92,30 @@ int virNodeDeviceHasCap(const virNodeDeviceObj *dev, const 
char *cap)
 }
 
 
+/* virNodeDeviceFindVPORTCapDef:
+ * @dev: Pointer to current device
+ *
+ * Search the device object 'caps' array for vport_ops capability.
+ *
+ * Returns:
+ * Pointer to the caps or NULL if not found
+ */
+static virNodeDevCapsDefPtr
+virNodeDeviceFindVPORTCapDef(const virNodeDeviceObj *dev)
+{
+virNodeDevCapsDefPtr caps = dev->def->caps;
+
+while (caps) {
+if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST &&
+(caps->data.scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS))
+break;
+
+caps = caps->next;
+}
+return caps;
+}
+
+
 virNodeDeviceObjPtr
 virNodeDeviceFindBySysfsPath(virNodeDeviceObjListPtr devs,
  const char *sysfs_path)
@@ -1752,6 +1776,35 @@ virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
 /*
  * Return the NPIV dev's parent device name
  */
+/* virNodeDeviceFindFCParentHost:
+ * @parent: Pointer to node device object
+ * @parent_host: Pointer to return parent host number
+ *
+ * Search the capabilities for the device to find the FC capabilities
+ * in order to set the parent_host value.
+ *
+ * Returns:
+ *   0 on success with parent_host set, -1 otherwise;
+ */
+static int
+virNodeDeviceFindFCParentHost(virNodeDeviceObjPtr parent,
+  int *parent_host)
+{
+virNodeDevCapsDefPtr cap = virNodeDeviceFindVPORTCapDef(parent);
+
+if (!cap) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Parent device %s is not capable "
+ "of vport operations"),
+   parent->def->name);
+return -1;
+}
+
+*parent_host = cap->data.scsi_host.host;
+return 0;
+}
+
+
 int
 virNodeDeviceGetParentHost(virNodeDeviceObjListPtr devs,
const char *dev_name,
@@ -1759,41 +1812,19 @@ virNodeDeviceGetParentHost(virNodeDeviceObjListPtr devs,
int *parent_host)
 {
 virNodeDeviceObjPtr parent = NULL;
-virNodeDevCapsDefPtr cap = NULL;
-int ret = 0;
+int ret;
 
-parent = virNodeDeviceFindByName(devs, parent_name);
-if (parent == NULL) {
+if (!(parent = virNodeDeviceFindByName(devs, parent_name))) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not find parent device for '%s'"),
dev_name);
-ret = -1;
-goto out;
-}
-
-cap = parent->def->caps;
-while (cap != NULL) {
-if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST &&
-(cap->data.scsi_host.flags &
- VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)) {
-*parent_host = cap->data.scsi_host.host;
-break;
-}
-
-cap = cap->next;
+return -1;
 }
 
-if (cap == NULL) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Parent device %s is not capable "
- "of vport operations"),
-   parent->def->name);
-ret = -1;
-}
+ret = virNodeDeviceFindFCParentHost(parent, parent_host);
 
 virNodeDeviceObjUnlock(parent);
 
- out:
 return ret;
 }
 
-- 
2.7.4

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


[libvirt] [PATCH 03/11] nodedev: Add ability to find a vport capable vHBA

2016-11-18 Thread John Ferlan
If a  is not supplied in the XML used to create a non-persistent
vHBA, then instead of failing, let's try to find a "vports" capable node
device and use that.

Signed-off-by: John Ferlan 
---
 src/conf/node_device_conf.c  | 39 
 src/conf/node_device_conf.h  |  3 +++
 src/libvirt_private.syms |  1 +
 src/node_device/node_device_driver.c | 15 +-
 4 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 5396681..3aa77cf 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -151,6 +151,23 @@ virNodeDeviceObjPtr 
virNodeDeviceFindByName(virNodeDeviceObjListPtr devs,
 }
 
 
+static virNodeDeviceObjPtr
+virNodeDeviceFindByCap(virNodeDeviceObjListPtr devs,
+   const char *cap)
+{
+size_t i;
+
+for (i = 0; i < devs->count; i++) {
+virNodeDeviceObjLock(devs->objs[i]);
+if (virNodeDeviceHasCap(devs->objs[i], cap))
+return devs->objs[i];
+virNodeDeviceObjUnlock(devs->objs[i]);
+}
+
+return NULL;
+}
+
+
 void virNodeDeviceDefFree(virNodeDeviceDefPtr def)
 {
 virNodeDevCapsDefPtr caps;
@@ -1828,6 +1845,28 @@ virNodeDeviceGetParentHost(virNodeDeviceObjListPtr devs,
 return ret;
 }
 
+
+int
+virNodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs,
+ int *parent_host)
+{
+virNodeDeviceObjPtr parent = NULL;
+int ret;
+
+if (!(parent = virNodeDeviceFindByCap(devs, "vports"))) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Could not find any vport capable device"));
+return -1;
+}
+
+ret = virNodeDeviceFindFCParentHost(parent, parent_host);
+
+virNodeDeviceObjUnlock(parent);
+
+return ret;
+}
+
+
 void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
 {
 size_t i = 0;
diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h
index 9f00500..2b2aed7 100644
--- a/src/conf/node_device_conf.h
+++ b/src/conf/node_device_conf.h
@@ -273,6 +273,9 @@ int virNodeDeviceGetParentHost(virNodeDeviceObjListPtr devs,
const char *parent_name,
int *parent_host);
 
+int virNodeDeviceFindVportParentHost(virNodeDeviceObjListPtr devs,
+ int *parent_host);
+
 void virNodeDeviceDefFree(virNodeDeviceDefPtr def);
 
 void virNodeDeviceObjFree(virNodeDeviceObjPtr dev);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index baff82b..de14a7e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -699,6 +699,7 @@ virNodeDeviceDefParseNode;
 virNodeDeviceDefParseString;
 virNodeDeviceFindByName;
 virNodeDeviceFindBySysfsPath;
+virNodeDeviceFindVportParentHost;
 virNodeDeviceGetParentHost;
 virNodeDeviceGetWWNs;
 virNodeDeviceHasCap;
diff --git a/src/node_device/node_device_driver.c 
b/src/node_device/node_device_driver.c
index 91bb142..0e091fe 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -584,11 +584,16 @@ nodeDeviceCreateXML(virConnectPtr conn,
 if (virNodeDeviceGetWWNs(def, , ) == -1)
 goto cleanup;
 
-if (virNodeDeviceGetParentHost(>devs,
-   def->name,
-   def->parent,
-   _host) == -1) {
-goto cleanup;
+if (def->parent) {
+if (virNodeDeviceGetParentHost(>devs,
+   def->name,
+   def->parent,
+   _host) < 0)
+goto cleanup;
+} else {
+/* Try to find "a" vport capable scsi_host when no parent supplied */
+if (virNodeDeviceFindVportParentHost(>devs, _host) < 0)
+goto cleanup;
 }
 
 if (virManageVport(parent_host,
-- 
2.7.4

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


[libvirt] [PATCH 00/11] Allow creation of vHBA by parent_wwnn/wwpn or fabric_name

2016-11-18 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1349696

Lots of details in the bz, but essentially the problem is that providing
a "parent" scsi_hostX value has drawbacks on reboots because what was
scsi_hostX could turn into scsi_hostY on subsequent reboots.

So add the ability to use the parent wwnn/wwpn or fabric_wwn as 'search'
criteria in order to create either non persistent vHBA's via nodedev or
persistent vHBA's via storage pools.

NB: Documentation of this "process" is on the wiki:

http://wiki.libvirt.org/page/NPIV_in_libvirt

and would need to be adjusted once/if the changes are accepted.


John Ferlan (11):
  nodedev: Fix crash in libvirtd on vHBA creation path
  nodedev: Create helpers to search for vport capable nodedevs
  nodedev: Add ability to find a vport capable vHBA
  nodedev: Add the ability to create vHBA by parent wwnn/wwpn or
fabric_wwn
  conf: Add more fchost search fields for storage pool vHBA creation
  iscsi: Clean up createVport exit paths
  iscsi: Change order of checks in createVport
  iscsi: Converge more createVport checks
  util: Remove need for extra VIR_FREE's in virGetFCHostNameByWWN
  util: Introduce virGetFCHostNameByFabricWWN
  iscsi: Add parent wwnn/wwpn or fabric capability for createVport

 docs/schemas/basictypes.rng  |  15 +++
 docs/schemas/nodedev.rng |  15 +++
 src/conf/node_device_conf.c  | 234 +++
 src/conf/node_device_conf.h  |  17 +++
 src/conf/storage_conf.c  |  21 +++-
 src/conf/storage_conf.h  |   3 +
 src/libvirt_private.syms |   4 +
 src/node_device/node_device_driver.c |  28 -
 src/storage/storage_backend_scsi.c   |  86 +++--
 src/util/virutil.c   | 113 -
 src/util/virutil.h   |   4 +
 11 files changed, 439 insertions(+), 101 deletions(-)

-- 
2.7.4

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


Re: [libvirt] [PATCH] Fix scheduler support check

2016-11-18 Thread Martin Kletzander

On Fri, Nov 18, 2016 at 10:59:58AM +0100, Erik Skultety wrote:

On Fri, Nov 18, 2016 at 10:34:47AM +0100, Martin Kletzander wrote:

Commit 94cc577807ba tried fixing build on systems that did not have
SCHED_BATCH or SCHED_IDLE defined.  But instead of changing it to
conditional support, it rather completely disabled the support for
setting any scheduler.  Since then, such old systems are not
supported, but rather than reverting that commit, let's change that to
the conditional support.  That way any addition to the list of
schedulers can follow the same style so that we're consistent in the
future.

Signed-off-by: Martin Kletzander 
---

Notes:
Of course there are various ways how to address that, I went with
case.  Also defining undefined SCHED_* to -1 makes some gnulib
syntax-check go haywire.

 src/util/virprocess.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 718c4a2664e1..39d6b30c40f2 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1183,7 +1183,7 @@ virProcessExitWithStatus(int status)
 exit(value);
 }

-#if HAVE_SCHED_SETSCHEDULER && defined(SCHED_BATCH) && defined(SCHED_IDLE)
+#if HAVE_SCHED_SETSCHEDULER

 static int
 virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
@@ -1196,10 +1196,18 @@ virProcessSchedTranslatePolicy(virProcessSchedPolicy 
policy)
 return SCHED_BATCH;

 case VIR_PROC_POLICY_IDLE:
+# ifdef SCHED_IDLE
 return SCHED_IDLE;
+# else
+return -1;
+# endif

 case VIR_PROC_POLICY_FIFO:
+# ifdef SCHED_FIFO
 return SCHED_FIFO;
+# else
+return -1;
+# endif



Didn't you by any chance mean to make SCHED_BATCH conditional instead of
SCHED_FIFO which might have probably been part of the kernel since forever (at
least man 7 sched doesn't say anything about when it was added).



Um... well, I wonder in what version of this patch I changed that.
Probably somewhere between 3rd and 7th version.  I'll fix that back.
Thanks.


ACK with that fixed.

Erik


 case VIR_PROC_POLICY_RR:
 return SCHED_RR;
@@ -1225,6 +1233,13 @@ virProcessSetScheduler(pid_t pid,
 if (!policy)
 return 0;

+if (pol < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("Scheduler '%s' is not supported on this platform"),
+   virProcessSchedPolicyTypeToString(policy));
+return -1;
+}
+
 if (pol == SCHED_FIFO || pol == SCHED_RR) {
 int min = 0;
 int max = 0;
--
2.10.2

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





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


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

Re: [libvirt] [PATCH] virstats: Gathering net interface stats with ovs

2016-11-18 Thread Daniel P. Berrange
On Fri, Nov 18, 2016 at 09:06:51AM +0100, Mehdi Abaakouk wrote:
> When vhostuser or ovs interfaces are used, the interface statistics
> are not always available in /proc/net/dev.
> 
> This change looks at the openvswitch interfaces statistics
> tables to provide this information in additional to /proc/net/dev.
> 
> Note that in openvswitch world drop/error doesn't always make sense
> for some interface type. When these informations are not available we
> set them to 0 on the virDomainInterfaceStats.
> ---
>  src/util/virstats.c | 99 
> +++--
>  1 file changed, 96 insertions(+), 3 deletions(-)
> 
> diff --git a/src/util/virstats.c b/src/util/virstats.c
> index c4725ed..457526d 100644
> --- a/src/util/virstats.c
> +++ b/src/util/virstats.c
> @@ -34,6 +34,7 @@
>  # include 
>  #endif
>  
> +#include "vircommand.h"
>  #include "virerror.h"
>  #include "datatypes.h"
>  #include "virstats.h"
> @@ -115,9 +116,101 @@ virNetInterfaceStats(const char *path,
>  }
>  VIR_FORCE_FCLOSE(fp);
>  
> -virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -   _("/proc/net/dev: Interface not found"));
> -return -1;
> +
> +/* We don't find the interface in /proc/net/dev, let's see if we can find
> + * it in openvswitch. We only looks for bytes and packets first.
> + * errors and dropped does not exists for all type of ovs interfaces.
> + * For the same reason as /proc/net/dev the TX/RX fields appear to be
> + * swapped here.
> + */
> +virCommandPtr cmd = NULL;
> +char *output;
> +long long rx_bytes;
> +long long rx_packets;
> +long long tx_bytes;
> +long long tx_packets;
> +long long rx_errs;
> +long long rx_drop;
> +long long tx_errs;
> +long long tx_drop;
> +int ret = -1;
> +
> +// Just ensure the interface exists in ovs
> +cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
> +   "get", "Interface", path,
> +   "name", NULL);
> +virCommandSetOutputBuffer(cmd, );
> +
> +if (virCommandRun(cmd, NULL) < 0) {
> +// no ovs-vsctl or interface 'path' doesn't exists in ovs
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("Interface not found"));
> +goto cleanup;
> +}
> +
> +VIR_FREE(output);
> +virCommandFree(cmd);
> +
> +cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
> +   "get", "Interface", path,
> +   "statistics:rx_bytes",
> +   "statistics:rx_packets",
> +   "statistics:tx_bytes",
> +   "statistics:tx_packets", NULL);
> +virCommandSetOutputBuffer(cmd, );
> +
> +if (virCommandRun(cmd, NULL) < 0) {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("Interface doesn't have statistics"));
> +goto cleanup;
> +}
> +
> +if (sscanf(output, "%lld\n%lld\n%lld\n%lld\n",
> +   _bytes, _packets, _bytes, _packets) != 4) {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("Fail to parse ovs-vsctl output"));
> +goto cleanup;
> +}
> +
> +stats->rx_bytes = rx_bytes;
> +stats->rx_packets = rx_packets;
> +stats->tx_bytes = tx_bytes;
> +stats->tx_packets = tx_packets;
> +
> +VIR_FREE(output);
> +virCommandFree(cmd);
> +
> +cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
> +   "get", "Interface", path,
> +   "statistics:rx_errors",
> +   "statistics:rx_dropped",
> +   "statistics:tx_errors",
> +   "statistics:tx_dropped", NULL);
> +virCommandSetOutputBuffer(cmd, );
> +if (virCommandRun(cmd, NULL) < 0) {
> +// This interface don't have errors or dropped, so set them to 0
> +stats->rx_errs = 0;
> +stats->rx_drop = 0;
> +stats->tx_errs = 0;
> +stats->tx_drop = 0;
> +} else if (sscanf(output, "%lld\n%lld\n%lld\n%lld\n",
> +  _errs, _drop, _errs, _drop) == 4) {
> +stats->rx_errs = rx_errs;
> +stats->rx_drop = rx_drop;
> +stats->tx_errs = tx_errs;
> +stats->tx_drop = tx_drop;
> +ret = 0;
> +} else {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("Fail to parse ovs-vsctl output"));
> +goto cleanup;
> +}
> +ret = 0;
> +
> + cleanup:
> +VIR_FREE(output);
> +virCommandFree(cmd);
> +return ret;
>  }
>  #elif defined(HAVE_GETIFADDRS) && defined(AF_LINK)
>  int

Rather than putting all this new code in virnetstats.h, I think we need
todo some refactoring here. The existing code ought to live in a method
in virnetdevtap.c, while your new code should live in a method in the

[libvirt] [PATCH 3/3] qemu: Removed an outdated comment in qemuDomainSaveImageStartVM()

2016-11-18 Thread Marc Hartmayer
Removed the comment 'Set the migration source' as it isn't valid anymore
and 'start it up' isn't useful as qemuProcessStart() is already a
speaking name.

Signed-off-by: Marc Hartmayer 
---
 src/qemu/qemu_driver.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d039255..49c7303 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6609,7 +6609,6 @@ qemuDomainSaveImageStartVM(virConnectPtr conn,
 }
 }
 
-/* Set the migration source and start it up. */
 if (qemuProcessStart(conn, driver, vm, asyncJob,
  "stdio", *fd, path, NULL,
  VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
-- 
2.5.5

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


[libvirt] [PATCH 1/3] virfile: Only generate a warning if there is something to report

2016-11-18 Thread Marc Hartmayer
Only generate a warning if there is something to report.

Signed-off-by: Marc Hartmayer 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/util/virfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index a45279a..f006abf 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -325,7 +325,7 @@ virFileWrapperFdClose(virFileWrapperFdPtr wfd)
 return 0;
 
 ret = virCommandWait(wfd->cmd, NULL);
-if (wfd->err_msg)
+if (wfd->err_msg && *wfd->err_msg)
 VIR_WARN("iohelper reports: %s", wfd->err_msg);
 
 return ret;
-- 
2.5.5

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


[libvirt] [PATCH 0/3] Couple of small fixes and improvements

2016-11-18 Thread Marc Hartmayer
Fixed trailing '/' for path, removed an obsolete comment, and removed
a useless warning.

Bjoern Walk (1):
  virutil: fix trailing '/' for path prefixes

Marc Hartmayer (2):
  virfile: Only generate a warning if there is something to report
  qemu: Removed an outdated comment in qemuDomainSaveImageStartVM()

 src/qemu/qemu_driver.c | 1 -
 src/util/virfile.c | 2 +-
 src/util/virutil.c | 4 ++--
 3 files changed, 3 insertions(+), 4 deletions(-)

-- 
2.5.5

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


[libvirt] [PATCH 2/3] virutil: fix trailing '/' for path prefixes

2016-11-18 Thread Marc Hartmayer
From: Bjoern Walk 

The path prefixes for sysfs trees are always prepended by paths
beginning with a slash, making the trailing slash in the prefix
redundant.

Signed-off-by: Bjoern Walk 
Reviewed-by: Marc Hartmayer 
Reviewed-by: Boris Fiuczynski 
---
 src/util/virutil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index 844c947..0291378 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1777,8 +1777,8 @@ virGetDeviceUnprivSGIO(const char *path,
 }
 
 #ifdef __linux__
-# define SYSFS_FC_HOST_PATH "/sys/class/fc_host/"
-# define SYSFS_SCSI_HOST_PATH "/sys/class/scsi_host/"
+# define SYSFS_FC_HOST_PATH "/sys/class/fc_host"
+# define SYSFS_SCSI_HOST_PATH "/sys/class/scsi_host"
 
 /* virReadSCSIUniqueId:
  * @sysfs_prefix: "scsi_host" sysfs path, defaults to SYSFS_SCSI_HOST_PATH
-- 
2.5.5

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


Re: [libvirt] [PATCH v3 03/10] Introduce a "scsi_host" hostdev type

2016-11-18 Thread Eric Farman



On 11/17/2016 06:18 PM, John Ferlan wrote:

[...]


I don't think the current code naming is incorrect, but it does
slightly paint us into a box with this work.  I'll mull this over
overnight, and maybe cook up a cleanup patch separate from this
series.  Or perhaps take your other suggestion and go with the
inclusion of "vhost" in the functions.

John,

I sent an RFC patch [1] separate from this series the other day, but
thought that I had the remainder of your comments addressed and so maybe
I'd combine everything into one series.  Then my brain exploded:

Before:
// These three are all existing code
 virDomainHostdevSubsysSCSIPtr scsisrc = >source.subsys.u.scsi;
 virDomainHostdevSubsysSCSIHostPtr scsihostsrc = >u.host;
 virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = >u.iscsi;
// The next one is new
 virDomainHostdevSubsysHostPtr hostsrc = >source.subsys.u.host;

After:
// These three are all existing code
 virDomainHostdevSubsysSCSIPtr scsisrc = >source.subsys.u.scsi;
 virDomainHostdevSubsysSCSISCSIHostPtr scsiscsihostsrc =
>u.host;
 virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = >u.iscsi;
// The next one is new
 virDomainHostdevSubsysSCSIHostPtr scsihostsrc =
>source.subsys.u.scsihost;

So, uh, ugh.  (And it still has an inconsistency because I had to
prepend another "scsi" on the existing "scsihostsrc" ... which means
there's probably a better reworking to have happen here.)

I could take your other suggestion of "SCSIHostVHost", but I still worry
that that gets viewed as a subset of the existing SCSIHost stuff (which
is a type='scsi' sourceadapter='scsi_host' hostdev), without somehow
cleaning up the existing code.

For now, I've stashed these changes off to the side.  I could spin a v4
of the vhost-scsi series without any of the s/host/scsihost/ variations
you asked for, but this rabbit hole is probably going to consume me
until the next freeze/holiday.  Thoughts?

I've been heads down in some vHBA/NPIV code - less than friendly
stuff... It's a customer case, so it's taken priority...


No problem, those definitely win.



Quick thoughts -

... the RFC used SCSISCSI which really looked odd and I think I
originally avoided for that very reason when I gone through a similar
exercise some time ago.


Sorry for the deja vu then.  :-)



... since the first issues that caught my attention were in patch4,
maybe attack those first - that is change 'Host' to 'SCSCIVHost' API's

... for this patch, it may just be best to change HOST to VHOST and Host
to VHost.


I have patches for these on top of the series (didn't want to rebase 
things too badly in case they went terribly wrong).  The RFC made sense 
because it lined everything up, without introducing a "why isn't the 
type='scsi_vhost' then?" question.  Seeing how it looks now, I'll toss 
those aside for the time being and see how things look with just these 
two.  (Well, there are still some s/HOST/SCSIHOST/ involved; the 
enumerated list comes to mind.)




I'll try to put some more thought into it in the morning...


Again, I appreciate the time you've spent looking at this.  Good luck in 
NPIV-land.


 - Eric



John


  - Eric

[1] https://www.redhat.com/archives/libvir-list/2016-November/msg00808.html


[...]



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


Re: [libvirt] [PATCH 2/2] fs: Fix probing on no-overwrite of target device

2016-11-18 Thread Ján Tomko

On Tue, Nov 15, 2016 at 06:48:03PM -0500, John Ferlan wrote:

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

There's actually a couple of bugs here...

   only the "input" format type, so any other "types" of format would be


I could a verb.


   filtered during the blkid_do_probe resulting in allowing a new format
   type to overwrite a previous format type since when it's determined a
   format type cannot be determined that we'd return 0 (or prior to the
   previous patch a NOT_FOUND value). So instead of passing just one type
   to filter on, pass the entire list of virStoragePoolFormatFileSystem
   types. According to recent docs, this call may be unnecessary unless
   we care about superblock probing only. Ironically, if the on disk
   format type was the same as the requested format, the code would then
   fail on the else condition (fixed in #2).

   was returning -1 (or prior to previous patch FOUND) with an error
   which caused the caller to just fail.


Why is that a bug? IIUC we want to error out if a filesystem was found.


So even though it was found
   it did nothing.  Change that to compare the on disk type with the
   passed format type and return 0 or -1 as necessary.

Signed-off-by: John Ferlan 
---
src/storage/storage_backend_fs.c | 26 +-
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 2413e82..74b278d 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -626,7 +626,8 @@ virStorageBackendFileSystemProbe(const char *device,
int ret = -1;
blkid_probe probe = NULL;
const char *fstype = NULL;
-char *names[2], *libblkid_format = NULL;
+size_t i;
+const char *names[VIR_STORAGE_POOL_FS_LAST] = {0};

VIR_DEBUG("Probing for existing filesystem of type %s on device %s",
  format, device);
@@ -648,25 +649,26 @@ virStorageBackendFileSystemProbe(const char *device,
goto error;
}

-if (VIR_STRDUP(libblkid_format, format) < 0)
-goto error;
-
-names[0] = libblkid_format;
-names[1] = NULL;
+for (i = 1; i < VIR_STORAGE_POOL_FS_LAST; i++)
+names[i - 1] = virStoragePoolFormatFileSystemTypeToString(i);

blkid_probe_filter_superblocks_type(probe,
BLKID_FLTR_ONLYIN,
-names);
+(char **)names);



If we want to extend the probing to other filesystem types, then
removing the filter completely would be a better option.

But,

it seems the code intended to only check for the same fs type, not
others. From virsh pool-build --help:

   --no-overwrite   do not overwrite an existing pool of this type
   --overwrite  overwrite any existing data

The API constants are described more ambiguously:

VIR_STORAGE_POOL_BUILD_NO_OVERWRITE =   4
Do not overwrite existing pool
VIR_STORAGE_POOL_BUILD_OVERWRITE=   8
Overwrite data


if (blkid_do_probe(probe) != 0) {
VIR_INFO("No filesystem of type '%s' found on device '%s'",
 format, device);
ret = 0;
} else if (blkid_probe_lookup_value(probe, "TYPE", , NULL) == 0) {
-virReportError(VIR_ERR_STORAGE_POOL_BUILT,
-   _("Existing filesystem of type '%s' found on "
- "device '%s'"),
-   fstype, device);
+if (STRNEQ(fstype, format)) {
+virReportError(VIR_ERR_STORAGE_POOL_BUILT,
+   _("Existing filesystem of type '%s' found on "
+ "device '%s'"),


When I tried to create an ext4 pool over an xfs filesystem, the
resulting error message was confusing:

error: Storage pool already built: Existing filesystem of type 'xfs'
found on device '/dev/sda5'


+   fstype, device);
+} else {



+ret = 0;


This is definitely wrong. If the existing filesystem matched the one
that had been requested by the user,
we would call mkfs again despite the NO_OVERWRITE flag.


So it all boils down to the interpretation of the NO_OVERWRITE flag:
[0] Do not overwrite the requested filesystem
[A] Do not overwrite a filesystem libvirt knows about
[B] Do not overwrite any filesystem
[C] Do not overwrite any useful-looking data.

This patch did [A] (with the exception of the on-disk filesystem
matching the requested filesystem).

To match the 'virsh help' interpretation 'do not overwrite an existing
pool of this type', I guess the current situation [0] already satisfies
that (but the man page does not agree - and for disk pools it mentions
that libvirt uses 'parted' to determine this, which is oddly specific).


If we treat 'of this type' literally, e.g. anything that might be a
type='fs' pool, then we should remove the filter and let blkid check
for all filesystems [B].


[C] might be more user-friendly, 

Re: [libvirt] [PATCH 1/2] fs: Remove virStoragePoolProbeResult and FILESYSTEM_PROBE_ values

2016-11-18 Thread Ján Tomko

On Tue, Nov 15, 2016 at 06:48:02PM -0500, John Ferlan wrote:

They're not necessary - either we have an error or not especially since
the caller only checked for the "NOT_FOUND" case.

Signed-off-by: John Ferlan 
---
src/storage/storage_backend_fs.c | 16 +++-
src/storage/storage_backend_fs.h |  5 -
2 files changed, 7 insertions(+), 14 deletions(-)



ACK

Jan


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

[libvirt] [PATCH 1/2] qemu: Update cgroup on RNG hotplug

2016-11-18 Thread Michal Privoznik
If users try to hotplug RNG device with a backend different to
/dev/random or /dev/urandom the whole operation fails as qemu is
unable to access the device. The problem is we don't update
device CGroups during the operation.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_cgroup.c  | 62 +++--
 src/qemu/qemu_cgroup.h  |  4 
 src/qemu/qemu_hotplug.c | 17 --
 3 files changed, 69 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 1443f7e..e7ce032 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -569,6 +569,54 @@ qemuSetupFirmwareCgroup(virDomainObjPtr vm)
 }
 
 
+int
+qemuSetupRNGCgroup(virDomainObjPtr vm,
+   virDomainRNGDefPtr rng)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+int rv;
+
+if (rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM) {
+VIR_DEBUG("Setting Cgroup ACL for RNG device");
+rv = virCgroupAllowDevicePath(priv->cgroup,
+  rng->source.file,
+  VIR_CGROUP_DEVICE_RW, false);
+virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
+ rng->source.file,
+ "rw", rv == 0);
+if (rv < 0 &&
+!virLastErrorIsSystemErrno(ENOENT))
+return -1;
+}
+
+return 0;
+}
+
+
+int
+qemuTeardownRNGCgroup(virDomainObjPtr vm,
+  virDomainRNGDefPtr rng)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+int rv;
+
+if (rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM) {
+VIR_DEBUG("Setting Cgroup ACL for RNG device");
+rv = virCgroupDenyDevicePath(priv->cgroup,
+ rng->source.file,
+ VIR_CGROUP_DEVICE_RW, false);
+virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
+ rng->source.file,
+ "rw", rv == 0);
+if (rv < 0 &&
+!virLastErrorIsSystemErrno(ENOENT))
+return -1;
+}
+
+return 0;
+}
+
+
 static int
 qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
virDomainObjPtr vm)
@@ -663,18 +711,8 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
 }
 
 for (i = 0; i < vm->def->nrngs; i++) {
-if (vm->def->rngs[i]->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM) {
-VIR_DEBUG("Setting Cgroup ACL for RNG device");
-rv = virCgroupAllowDevicePath(priv->cgroup,
-  vm->def->rngs[i]->source.file,
-  VIR_CGROUP_DEVICE_RW, false);
-virDomainAuditCgroupPath(vm, priv->cgroup, "allow",
- vm->def->rngs[i]->source.file,
- "rw", rv == 0);
-if (rv < 0 &&
-!virLastErrorIsSystemErrno(ENOENT))
-goto cleanup;
-}
+if (qemuSetupRNGCgroup(vm, vm->def->rngs[i]) < 0)
+goto cleanup;
 }
 
 ret = 0;
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index 623823e..1c3b7ff 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -43,6 +43,10 @@ int qemuSetupHostdevCgroup(virDomainObjPtr vm,
 int qemuTeardownHostdevCgroup(virDomainObjPtr vm,
   virDomainHostdevDefPtr dev)
ATTRIBUTE_RETURN_CHECK;
+int qemuSetupRNGCgroup(virDomainObjPtr vm,
+   virDomainRNGDefPtr rng);
+int qemuTeardownRNGCgroup(virDomainObjPtr vm,
+  virDomainRNGDefPtr rng);
 int qemuConnectCgroup(virQEMUDriverPtr driver,
   virDomainObjPtr vm);
 int qemuSetupCgroup(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 6b3a068..b43d9dd 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1951,6 +1951,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
 char *tlsAlias = NULL;
 char *secAlias = NULL;
 bool releaseaddr = false;
+bool teardowncgroup = false;
 bool chardevAdded = false;
 bool objAdded = false;
 bool tlsobjAdded = false;
@@ -1996,6 +1997,10 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
 goto cleanup;
 }
 
+if (qemuSetupRNGCgroup(vm, rng) < 0)
+goto cleanup;
+teardowncgroup = true;
+
 if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD)
 qemuDomainPrepareChardevSourceTLS(rng->source.chardev, cfg);
 
@@ -2073,8 +2078,13 @@ qemuDomainAttachRNGDevice(virConnectPtr conn,
 virJSONValueFree(tlsProps);
 virJSONValueFree(secProps);
 virJSONValueFree(props);
-if (ret < 0 && releaseaddr)
-qemuDomainReleaseDeviceAddress(vm, >info, NULL);
+if (ret < 0) {
+if (releaseaddr)
+qemuDomainReleaseDeviceAddress(vm, >info, NULL);

[libvirt] [PATCH 0/2] qemu: Update CGroups on some devices hotplug

2016-11-18 Thread Michal Privoznik
We are already doing that for some devices (e.g. disks,
hostdevs), but completely forgot about some others (chardevs and
RNGs). So far the hotplug worked by pure chance as /dev/random
and /dev/urandom are enabled in the device CGroups by default.

Michal Privoznik (2):
  qemu: Update cgroup on RNG hotplug
  qemu: Update cgroup on chardev hotplug

 src/qemu/qemu_cgroup.c  | 108 +---
 src/qemu/qemu_cgroup.h  |   8 
 src/qemu/qemu_hotplug.c |  37 ++---
 3 files changed, 131 insertions(+), 22 deletions(-)

-- 
2.8.4

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


[libvirt] [PATCH 2/2] qemu: Update cgroup on chardev hotplug

2016-11-18 Thread Michal Privoznik
Just like in the previous commit, we are not updating CGroups on
chardev hot(un-)plug and thus leaving qemu unable to access any
non-default device users are trying to hotplug.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_cgroup.c  | 46 ++
 src/qemu/qemu_cgroup.h  |  4 
 src/qemu/qemu_hotplug.c | 20 
 3 files changed, 62 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index e7ce032..50e3d35 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -189,10 +189,32 @@ qemuSetupChrSourceCgroup(virDomainObjPtr vm,
 return ret;
 }
 
+
 static int
-qemuSetupChardevCgroup(virDomainDefPtr def ATTRIBUTE_UNUSED,
-   virDomainChrDefPtr dev,
-   void *opaque)
+qemuTeardownChrSourceCgroup(virDomainObjPtr vm,
+virDomainChrSourceDefPtr source)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+int ret;
+
+if (source->type != VIR_DOMAIN_CHR_TYPE_DEV)
+return 0;
+
+VIR_DEBUG("Process path '%s' for device", source->data.file.path);
+
+ret = virCgroupDenyDevicePath(priv->cgroup, source->data.file.path,
+  VIR_CGROUP_DEVICE_RW, false);
+virDomainAuditCgroupPath(vm, priv->cgroup, "deny",
+ source->data.file.path, "rw", ret == 0);
+
+return ret;
+}
+
+
+static int
+qemuSetupChardevCgroupCB(virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainChrDefPtr dev,
+ void *opaque)
 {
 virDomainObjPtr vm = opaque;
 
@@ -617,6 +639,22 @@ qemuTeardownRNGCgroup(virDomainObjPtr vm,
 }
 
 
+int
+qemuSetupChardevCgroup(virDomainObjPtr vm,
+   virDomainChrDefPtr dev)
+{
+return qemuSetupChrSourceCgroup(vm, dev->source);
+}
+
+
+int
+qemuTeardownChardevCgroup(virDomainObjPtr vm,
+  virDomainChrDefPtr dev)
+{
+return qemuTeardownChrSourceCgroup(vm, dev->source);
+}
+
+
 static int
 qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
virDomainObjPtr vm)
@@ -693,7 +731,7 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
 
 if (virDomainChrDefForeach(vm->def,
true,
-   qemuSetupChardevCgroup,
+   qemuSetupChardevCgroupCB,
vm) < 0)
 goto cleanup;
 
diff --git a/src/qemu/qemu_cgroup.h b/src/qemu/qemu_cgroup.h
index 1c3b7ff..6e2c742 100644
--- a/src/qemu/qemu_cgroup.h
+++ b/src/qemu/qemu_cgroup.h
@@ -47,6 +47,10 @@ int qemuSetupRNGCgroup(virDomainObjPtr vm,
virDomainRNGDefPtr rng);
 int qemuTeardownRNGCgroup(virDomainObjPtr vm,
   virDomainRNGDefPtr rng);
+int qemuSetupChardevCgroup(virDomainObjPtr vm,
+   virDomainChrDefPtr dev);
+int qemuTeardownChardevCgroup(virDomainObjPtr vm,
+  virDomainChrDefPtr dev);
 int qemuConnectCgroup(virQEMUDriverPtr driver,
   virDomainObjPtr vm);
 int qemuSetupCgroup(virQEMUDriverPtr driver,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b43d9dd..5038ce1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1830,6 +1830,7 @@ int qemuDomainAttachChrDevice(virConnectPtr conn,
 char *charAlias = NULL;
 bool chardevAttached = false;
 bool tlsobjAdded = false;
+bool teardowncgroup = false;
 bool secobjAdded = false;
 virJSONValuePtr tlsProps = NULL;
 char *tlsAlias = NULL;
@@ -1851,6 +1852,10 @@ int qemuDomainAttachChrDevice(virConnectPtr conn,
 if (rc == 1)
 need_release = true;
 
+if (qemuSetupChardevCgroup(vm, chr) < 0)
+goto cleanup;
+teardowncgroup = true;
+
 if (qemuBuildChrDeviceStr(, vmdef, chr, priv->qemuCaps) < 0)
 goto cleanup;
 
@@ -1903,10 +1908,14 @@ int qemuDomainAttachChrDevice(virConnectPtr conn,
  audit:
 virDomainAuditChardev(vm, NULL, chr, "attach", ret == 0);
  cleanup:
-if (ret < 0 && virDomainObjIsActive(vm))
-qemuDomainChrInsertPreAllocCleanup(vmdef, chr);
-if (ret < 0 && need_release)
-qemuDomainReleaseDeviceAddress(vm, >info, NULL);
+if (ret < 0) {
+if (virDomainObjIsActive(vm))
+qemuDomainChrInsertPreAllocCleanup(vmdef, chr);
+if (need_release)
+qemuDomainReleaseDeviceAddress(vm, >info, NULL);
+if (teardowncgroup && qemuTeardownChardevCgroup(vm, chr) < 0)
+VIR_WARN("Unable to remove chr device cgroup ACL on hotplug fail");
+}
 VIR_FREE(tlsAlias);
 virJSONValueFree(tlsProps);
 VIR_FREE(secAlias);
@@ -3847,6 +3856,9 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
 if (rc < 0)
 goto cleanup;
 
+if (qemuTeardownChardevCgroup(vm, chr) < 0)
+VIR_WARN("Failed to remove chr device 

Re: [libvirt] [Qemu-ppc] [RFC PATCH qemu] spapr_pci: Create PCI-express root bus by default

2016-11-18 Thread David Gibson
On Thu, Nov 17, 2016 at 01:02:57PM +1100, Alexey Kardashevskiy wrote:
> On 16/11/16 01:02, Andrea Bolognani wrote:
> > On Tue, 2016-11-01 at 13:46 +1100, David Gibson wrote:
> >> On Mon, Oct 31, 2016 at 03:10:23PM +1100, Alexey Kardashevskiy wrote:
> >>>  
> >>> On 31/10/16 13:53, David Gibson wrote:
>   
>  On Fri, Oct 28, 2016 at 12:07:12PM +0200, Greg Kurz wrote:
> >  
> > On Fri, 28 Oct 2016 18:56:40 +1100
> > Alexey Kardashevskiy  wrote:
> >  
> >>  
> >> At the moment sPAPR PHB creates a root buf of TYPE_PCI_BUS type.
> >> This means that vfio-pci devices attached to it (and this is
> >> a default behaviour) hide PCIe extended capabilities as
> >> the bus does not pass a pci_bus_is_express(pdev->bus) check.
> >>  
> >> This changes adds a default PCI bus type property to sPAPR PHB
> >> and uses TYPE_PCIE_BUS if none passed; older machines get TYPE_PCI_BUS
> >> for backward compatibility as a bus type is used in the bus name
> >> so the root bus name becomes "pcie.0" instead of "pci.0".
> >>  
> >> Signed-off-by: Alexey Kardashevskiy 
> >> ---
> >>  
> >> What can possibly go wrong with such change of a name?
> >> From devices prospective, I cannot see any.
> >>  
> >> libvirt might get upset as "pci.0" will not be available,
> >> will it make sense to create pcie.0 as a root bus and always
> >> add a PCIe->PCI bridge and name its bus "pci.0"?
> >>  
> >> Or create root bus from TYPE_PCIE_BUS and force name to "pci.0"?
> >> pci_register_bus() can do this.
> >>  
> >>  
> >> ---
> >>   hw/ppc/spapr.c  | 5 +
> >>   hw/ppc/spapr_pci.c  | 5 -
> >>   include/hw/pci-host/spapr.h | 1 +
> >>   3 files changed, 10 insertions(+), 1 deletion(-)
> >>  
> >> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> >> index 0b3820b..a268511 100644
> >> --- a/hw/ppc/spapr.c
> >> +++ b/hw/ppc/spapr.c
> >> @@ -2541,6 +2541,11 @@ DEFINE_SPAPR_MACHINE(2_8, "2.8", true);
> >>   .driver   = TYPE_SPAPR_PCI_HOST_BRIDGE, \
> >>   .property = "mem64_win_size",   \
> >>   .value= "0",\
> >> +},  \
> >> +{   \
> >> +.driver   = TYPE_SPAPR_PCI_HOST_BRIDGE, \
> >> +.property = "root_bus_type",\
> >> +.value= TYPE_PCI_BUS,   \
> >>   },
> >>   
> >>   static void phb_placement_2_7(sPAPRMachineState *spapr, uint32_t 
> >> index,
> >> diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
> >> index 7cde30e..2fa1f22 100644
> >> --- a/hw/ppc/spapr_pci.c
> >> +++ b/hw/ppc/spapr_pci.c
> >> @@ -1434,7 +1434,9 @@ static void spapr_phb_realize(DeviceState *dev, 
> >> Error **errp)
> >>   bus = pci_register_bus(dev, NULL,
> >>  pci_spapr_set_irq, pci_spapr_map_irq, 
> >> sphb,
> >>  >memspace, >iospace,
> >> -   PCI_DEVFN(0, 0), PCI_NUM_PINS, 
> >> TYPE_PCI_BUS);
> >> +   PCI_DEVFN(0, 0), PCI_NUM_PINS,
> >> +   sphb->root_bus_type ? sphb->root_bus_type :
> >> +   TYPE_PCIE_BUS);
> >  
> > Shouldn't we ensure that sphb->root_bus_type is either TYPE_PCIE_BUS or
> > TYPE_PCI_BUS ?
>   
>  Yes, I think so.  In fact, I think it would be better to make the
>  property a boolean that just selects PCI-E, rather than this which
>  exposes qemu (semi-)internal type names on the comamnd line.
> >>>  
> >>> Sure, a "pcie-root" boolean property should do.
> >>>  
> >>> However this is not my main concern, I rather wonder if we have to have
> >>> pci.0 when we pick PCIe for the root.
> >>  
> >> Right.
> >>  
> >> I've added Andrea Bologna to the CC list to get a libvirt perspective.
> > 
> > Thanks for doing so: changes such as this one can have quite
> > an impact on the upper layers of the stack, so the earliest
> > libvirt is involved in the discussion the better.
> > 
> > I'm going to go a step further and cross-post to libvir-list
> > in order to give other libvirt contributors a chance to chime
> > in too.
> > 
> >> Andrea,
> >>  
> >> To summarise the issue here:
> >> * As I've said before the PAPR spec kinda-sorta abstracts the
> >>   difference between vanilla PCI and PCI-E
> >> * However, because within qemu we're declaring the bus as PCI that
> >>   means some PCI-E devices aren't working right
> >> * In particular it means that PCI-E extended config space isn't
> >>   available
> >>  
> >> The proposal is to change (on newer machine types) the spapr PHB code
> >> to declare a PCI-E bus 

Re: [libvirt] [PATCH] Fix scheduler support check

2016-11-18 Thread Erik Skultety
On Fri, Nov 18, 2016 at 10:34:47AM +0100, Martin Kletzander wrote:
> Commit 94cc577807ba tried fixing build on systems that did not have
> SCHED_BATCH or SCHED_IDLE defined.  But instead of changing it to
> conditional support, it rather completely disabled the support for
> setting any scheduler.  Since then, such old systems are not
> supported, but rather than reverting that commit, let's change that to
> the conditional support.  That way any addition to the list of
> schedulers can follow the same style so that we're consistent in the
> future.
> 
> Signed-off-by: Martin Kletzander 
> ---
> 
> Notes:
> Of course there are various ways how to address that, I went with
> case.  Also defining undefined SCHED_* to -1 makes some gnulib
> syntax-check go haywire.
> 
>  src/util/virprocess.c | 17 -
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virprocess.c b/src/util/virprocess.c
> index 718c4a2664e1..39d6b30c40f2 100644
> --- a/src/util/virprocess.c
> +++ b/src/util/virprocess.c
> @@ -1183,7 +1183,7 @@ virProcessExitWithStatus(int status)
>  exit(value);
>  }
> 
> -#if HAVE_SCHED_SETSCHEDULER && defined(SCHED_BATCH) && defined(SCHED_IDLE)
> +#if HAVE_SCHED_SETSCHEDULER
> 
>  static int
>  virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
> @@ -1196,10 +1196,18 @@ virProcessSchedTranslatePolicy(virProcessSchedPolicy 
> policy)
>  return SCHED_BATCH;
> 
>  case VIR_PROC_POLICY_IDLE:
> +# ifdef SCHED_IDLE
>  return SCHED_IDLE;
> +# else
> +return -1;
> +# endif
> 
>  case VIR_PROC_POLICY_FIFO:
> +# ifdef SCHED_FIFO
>  return SCHED_FIFO;
> +# else
> +return -1;
> +# endif
> 

Didn't you by any chance mean to make SCHED_BATCH conditional instead of
SCHED_FIFO which might have probably been part of the kernel since forever (at
least man 7 sched doesn't say anything about when it was added).

ACK with that fixed.

Erik

>  case VIR_PROC_POLICY_RR:
>  return SCHED_RR;
> @@ -1225,6 +1233,13 @@ virProcessSetScheduler(pid_t pid,
>  if (!policy)
>  return 0;
> 
> +if (pol < 0) {
> +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +   _("Scheduler '%s' is not supported on this platform"),
> +   virProcessSchedPolicyTypeToString(policy));
> +return -1;
> +}
> +
>  if (pol == SCHED_FIFO || pol == SCHED_RR) {
>  int min = 0;
>  int max = 0;
> -- 
> 2.10.2
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list


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

[libvirt] [PATCH] Fix scheduler support check

2016-11-18 Thread Martin Kletzander
Commit 94cc577807ba tried fixing build on systems that did not have
SCHED_BATCH or SCHED_IDLE defined.  But instead of changing it to
conditional support, it rather completely disabled the support for
setting any scheduler.  Since then, such old systems are not
supported, but rather than reverting that commit, let's change that to
the conditional support.  That way any addition to the list of
schedulers can follow the same style so that we're consistent in the
future.

Signed-off-by: Martin Kletzander 
---

Notes:
Of course there are various ways how to address that, I went with
case.  Also defining undefined SCHED_* to -1 makes some gnulib
syntax-check go haywire.

 src/util/virprocess.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 718c4a2664e1..39d6b30c40f2 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -1183,7 +1183,7 @@ virProcessExitWithStatus(int status)
 exit(value);
 }

-#if HAVE_SCHED_SETSCHEDULER && defined(SCHED_BATCH) && defined(SCHED_IDLE)
+#if HAVE_SCHED_SETSCHEDULER

 static int
 virProcessSchedTranslatePolicy(virProcessSchedPolicy policy)
@@ -1196,10 +1196,18 @@ virProcessSchedTranslatePolicy(virProcessSchedPolicy 
policy)
 return SCHED_BATCH;

 case VIR_PROC_POLICY_IDLE:
+# ifdef SCHED_IDLE
 return SCHED_IDLE;
+# else
+return -1;
+# endif

 case VIR_PROC_POLICY_FIFO:
+# ifdef SCHED_FIFO
 return SCHED_FIFO;
+# else
+return -1;
+# endif

 case VIR_PROC_POLICY_RR:
 return SCHED_RR;
@@ -1225,6 +1233,13 @@ virProcessSetScheduler(pid_t pid,
 if (!policy)
 return 0;

+if (pol < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("Scheduler '%s' is not supported on this platform"),
+   virProcessSchedPolicyTypeToString(policy));
+return -1;
+}
+
 if (pol == SCHED_FIFO || pol == SCHED_RR) {
 int min = 0;
 int max = 0;
-- 
2.10.2

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


Re: [libvirt] [PATCH] configure: Look for daemons in **/sbin

2016-11-18 Thread Martin Kletzander

On Wed, Nov 16, 2016 at 08:29:49PM +0100, Guido Günther wrote:

Unify the logic we use for looking up daemons and admin binaries. Some
lookups prefered $PATH over **/sbin while others left out $PATH
entierly.  We add **/sbin since non-root users might not have these in
their path.

This also unbreaks libvirt when built on Debian systems with usrmerge[0]
and run on systems without it.

[0]: https://packages.debian.org/sid/usrmerge
---
configure.ac | 84 +++-
1 file changed, 43 insertions(+), 41 deletions(-)



ACK.  The only missing ones are using libexec paths or are used in
bhyve, so I think this is fine.

Thanks for cleaning it up in the whole configure.ac

Martin


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

Re: [libvirt] [Qemu-ppc] [RFC PATCH qemu] spapr_pci: Create PCI-express root bus by default

2016-11-18 Thread Andrea Bolognani
On Thu, 2016-11-17 at 13:02 +1100, Alexey Kardashevskiy wrote:
> > That said, considering that a big part of the PCI address
> > allocation logic is based off whether the specific machine
> > type exposes a legay PCI Root Bus or a PCI Express Root Bus,
> > libvirt will need a way to be able to tell which one is which.
> > 
> > Version checks are pretty much out of the question, as they
> > fail as soon as downstream releases enter the picture. A
> > few ways we could deal with the situation:
> > 
> >   1) switch to PCI Express on newer machine types, and
> >  expose some sort of capability through QMP so that
> >  libvirt can know about the switch

[...]
> > Option 1) would break horribly with existing libvirt
> > versions, and so would Option 2) if we default to using
> 
> How exactly 1) will break libvirt? Migrating from pseries-2.7 to
> pseries-2.8 does not work anyway, and machines are allowed to behave
> different from version to version, what distinct difference will using
> "pseries-pcie-X.Y" make?

Existing libvirt versions assume that pseries guests have
a legacy PCI root bus, and will base their PCI address
allocation / PCI topology decisions on that fact: they
will, for example, use legacy PCI bridges.

So if you used a new QEMU binary with a libvirt version
that doesn't know about the change, new guests would end up
using the wrong controllers. Existing guests would not be
affected as they would stick with the older machine types,
of course.

> I believe after we introduced the very first
> pseries-pcie-X.Y, we will just stop adding new pseries-X.Y.

Isn't i440fx still being updated despite the fact that q35
exists? Granted, there are a lot more differences between
those two machine types than just the root bus type.

Even if no newer pseries-x.y were to be added after
introducing pseries-pcie, you could still easily create
guests that use either root bus, so no loss in functionality.

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [PATCH] virstats: Gathering net interface stats with ovs

2016-11-18 Thread Mehdi Abaakouk
When vhostuser or ovs interfaces are used, the interface statistics
are not always available in /proc/net/dev.

This change looks at the openvswitch interfaces statistics
tables to provide this information in additional to /proc/net/dev.

Note that in openvswitch world drop/error doesn't always make sense
for some interface type. When these informations are not available we
set them to 0 on the virDomainInterfaceStats.
---
 src/util/virstats.c | 99 +++--
 1 file changed, 96 insertions(+), 3 deletions(-)

diff --git a/src/util/virstats.c b/src/util/virstats.c
index c4725ed..457526d 100644
--- a/src/util/virstats.c
+++ b/src/util/virstats.c
@@ -34,6 +34,7 @@
 # include 
 #endif
 
+#include "vircommand.h"
 #include "virerror.h"
 #include "datatypes.h"
 #include "virstats.h"
@@ -115,9 +116,101 @@ virNetInterfaceStats(const char *path,
 }
 VIR_FORCE_FCLOSE(fp);
 
-virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-   _("/proc/net/dev: Interface not found"));
-return -1;
+
+/* We don't find the interface in /proc/net/dev, let's see if we can find
+ * it in openvswitch. We only looks for bytes and packets first.
+ * errors and dropped does not exists for all type of ovs interfaces.
+ * For the same reason as /proc/net/dev the TX/RX fields appear to be
+ * swapped here.
+ */
+virCommandPtr cmd = NULL;
+char *output;
+long long rx_bytes;
+long long rx_packets;
+long long tx_bytes;
+long long tx_packets;
+long long rx_errs;
+long long rx_drop;
+long long tx_errs;
+long long tx_drop;
+int ret = -1;
+
+// Just ensure the interface exists in ovs
+cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
+   "get", "Interface", path,
+   "name", NULL);
+virCommandSetOutputBuffer(cmd, );
+
+if (virCommandRun(cmd, NULL) < 0) {
+// no ovs-vsctl or interface 'path' doesn't exists in ovs
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Interface not found"));
+goto cleanup;
+}
+
+VIR_FREE(output);
+virCommandFree(cmd);
+
+cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
+   "get", "Interface", path,
+   "statistics:rx_bytes",
+   "statistics:rx_packets",
+   "statistics:tx_bytes",
+   "statistics:tx_packets", NULL);
+virCommandSetOutputBuffer(cmd, );
+
+if (virCommandRun(cmd, NULL) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Interface doesn't have statistics"));
+goto cleanup;
+}
+
+if (sscanf(output, "%lld\n%lld\n%lld\n%lld\n",
+   _bytes, _packets, _bytes, _packets) != 4) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Fail to parse ovs-vsctl output"));
+goto cleanup;
+}
+
+stats->rx_bytes = rx_bytes;
+stats->rx_packets = rx_packets;
+stats->tx_bytes = tx_bytes;
+stats->tx_packets = tx_packets;
+
+VIR_FREE(output);
+virCommandFree(cmd);
+
+cmd = virCommandNewArgList(OVSVSCTL, "--timeout=5",
+   "get", "Interface", path,
+   "statistics:rx_errors",
+   "statistics:rx_dropped",
+   "statistics:tx_errors",
+   "statistics:tx_dropped", NULL);
+virCommandSetOutputBuffer(cmd, );
+if (virCommandRun(cmd, NULL) < 0) {
+// This interface don't have errors or dropped, so set them to 0
+stats->rx_errs = 0;
+stats->rx_drop = 0;
+stats->tx_errs = 0;
+stats->tx_drop = 0;
+} else if (sscanf(output, "%lld\n%lld\n%lld\n%lld\n",
+  _errs, _drop, _errs, _drop) == 4) {
+stats->rx_errs = rx_errs;
+stats->rx_drop = rx_drop;
+stats->tx_errs = tx_errs;
+stats->tx_drop = tx_drop;
+ret = 0;
+} else {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Fail to parse ovs-vsctl output"));
+goto cleanup;
+}
+ret = 0;
+
+ cleanup:
+VIR_FREE(output);
+virCommandFree(cmd);
+return ret;
 }
 #elif defined(HAVE_GETIFADDRS) && defined(AF_LINK)
 int
-- 
2.10.2

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


[libvirt] [PATCH] Gathering network interface statistics with openvswitch

2016-11-18 Thread Mehdi Abaakouk
Hi,

To follow up, my question about vhostuser/ovs interfaces statistics.

This is my porposal to implement this feature.

Regards,

Mehdi Abaakouk (1):
  virstats: Gathering net interface stats with ovs

 src/util/virstats.c | 99 +++--
 1 file changed, 96 insertions(+), 3 deletions(-)

-- 
2.10.2

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