[libvirt] [PATCH v2] secret: Introduce virSecretGetSecretString

2016-04-04 Thread John Ferlan
Commit id 'fb2bd208' essentially copied the qemuGetSecretString
creating an libxlGetSecretString.  Rather than have multiple copies
of the same code, create src/secret/secret_util.{c,h} files and
place the common function in there.

Modify the the build in order to build the module as a library
which is then pulled in by both the qemu and libxl drivers for
usage from both qemu_command.c and libxl_conf.c

Signed-off-by: John Ferlan 
---

My Makefile.am skills are weak at best - not sure I got it totally
right, but I think I'm at least close (it builds and links).

 po/POTFILES.in   |   1 +
 src/Makefile.am  |  17 ++-
 src/libvirt_private.syms |   4 ++
 src/libxl/libxl_conf.c   |  82 +++-
 src/qemu/qemu_command.c  |  87 --
 src/secret/secret_util.c | 120 +++
 src/secret/secret_util.h |  35 ++
 7 files changed, 190 insertions(+), 156 deletions(-)
 create mode 100644 src/secret/secret_util.c
 create mode 100644 src/secret/secret_util.h

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0d7f9f9..21d4cc6 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -155,6 +155,7 @@ src/rpc/virnetserverservice.c
 src/rpc/virnetsshsession.c
 src/rpc/virnettlscontext.c
 src/secret/secret_driver.c
+src/secret/secret_util.c
 src/security/security_apparmor.c
 src/security/security_dac.c
 src/security/security_driver.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 1726d06..5a3dd11 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -936,6 +936,9 @@ INTERFACE_DRIVER_SOURCES += 
\
 endif WITH_UDEV
 endif WITH_INTERFACE
 
+SECRET_UTIL_SOURCES =  \
+   secret/secret_util.h secret/secret_util.c
+
 SECRET_DRIVER_SOURCES =\
secret/secret_driver.h secret/secret_driver.c
 
@@ -1123,6 +1126,12 @@ libvirt_cpu_la_CFLAGS = \
-I$(srcdir)/conf $(AM_CFLAGS)
 libvirt_cpu_la_SOURCES = $(CPU_SOURCES)
 
+noinst_LTLIBRARIES += libvirt_secret.la
+libvirt_la_BUILT_LIBADD += libvirt_secret.la
+libvirt_secret_la_CFLAGS = $(AM_CFLAGS)
+libvirt_secret_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_secret_la_SOURCES = $(SECRET_UTIL_SOURCES)
+
 if WITH_VMX
 noinst_LTLIBRARIES += libvirt_vmx.la
 libvirt_la_BUILT_LIBADD += libvirt_vmx.la
@@ -1303,10 +1312,13 @@ libvirt_driver_libxl_impl_la_CFLAGS =   \
$(LIBXL_CFLAGS) \
-I$(srcdir)/access  \
-I$(srcdir)/conf\
+   -I$(srcdir)/secret  \
-I$(srcdir)/xenconfig   \
$(AM_CFLAGS)
 libvirt_driver_libxl_impl_la_LDFLAGS = $(AM_LDFLAGS)
-libvirt_driver_libxl_impl_la_LIBADD = $(LIBXL_LIBS) libvirt_xenconfig.la
+libvirt_driver_libxl_impl_la_LIBADD = $(LIBXL_LIBS) \
+ libvirt_xenconfig.la \
+ libvirt_secret.la
 libvirt_driver_libxl_impl_la_SOURCES = $(LIBXL_DRIVER_SOURCES)
 
 conf_DATA += libxl/libxl.conf
@@ -1337,12 +1349,14 @@ libvirt_driver_qemu_impl_la_CFLAGS = \
$(LIBNL_CFLAGS) \
-I$(srcdir)/access \
-I$(srcdir)/conf \
+   -I$(srcdir)/secret \
$(AM_CFLAGS)
 libvirt_driver_qemu_impl_la_LDFLAGS = $(AM_LDFLAGS)
 libvirt_driver_qemu_impl_la_LIBADD = $(CAPNG_LIBS) \
 $(GNUTLS_LIBS) \
$(LIBNL_LIBS) \
$(LIBXML_LIBS) \
+   libvirt_secret.la \
$(NULL)
 libvirt_driver_qemu_impl_la_SOURCES = $(QEMU_DRIVER_SOURCES)
 
@@ -1873,6 +1887,7 @@ EXTRA_DIST += 
\
$(SECURITY_DRIVER_SELINUX_SOURCES)  \
$(SECURITY_DRIVER_APPARMOR_SOURCES) \
$(SECRET_DRIVER_SOURCES)\
+   $(SECRET_UTIL_SOURCES)  \
$(VBOX_DRIVER_EXTRA_DIST)   \
$(VMWARE_DRIVER_SOURCES)\
$(XENCONFIG_SOURCES)\
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 684f06c..a473158 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1038,6 +1038,10 @@ nodeGetThreadsPerSubcore;
 nodeSetMemoryParameters;
 
 
+# secret/secret_util.h
+virSecretGetSecretString;
+
+
 # security/security_driver.h
 virSecurityDriverLookup;
 
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 82ba417..d16280d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -46,7 +46,7 @@
 #include "libxl_conf.h"
 #include "libxl_utils.h"
 #include "virstoragefile.h"
-#include "base64.h"
+#include 

Re: [libvirt] [PATCH] util: Create virsecret module adding virSecretGetSecretString

2016-04-04 Thread John Ferlan

[...]


>>
>> The secret driver should be calling functions from src/util, not the
>> other way around.
>>
>> Could this function be moved into src/secret?
>>
> 
> Won't that place dependencies on secret_driver for libxl_driver and
> qemu_driver?  IOW: Some sort of Makefile magic to get a symbol from the
> src/secret/secret_util.c (assuming that's the name). That is Makefile
> magic for which I'm not sure how to generate...
> 

I think I figured out the magic incantation... Patches sent shortly

[...]

John

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


[libvirt] Next Generation Config Mgmt + Libvirt

2016-04-04 Thread James
Dear libvir[t] hackers,

## Intro

I'd like to tell you about a project I'm working on, how it pertains to
libvirt, and to inspire you about this idea.

I thought I'd first give you some quick background about myself... Skip
to '## Project' if you'd prefer... I'm James, but I go by purpleidea on
a lot of the internet. I've been a happy libvirt user for very many
years, and I'm a huge fan of the project. I'm also a Red Hat engineer.

I remember using libvirt for both lxc and regular vm's. I even remember
being sad when virt-system-service died. I love using both virsh and
virt-manager.

I think libvirt is such a nice approach, I even went out of my way and
hacked on vagrant-libvirt, and Oh-My-Vagrant, since I wanted to use
libvirt instead of virtualbox, even though virtualbox was much more
popular and apparently easier.

## Project

I started a Next Generation Config Mgmt project called "mgmt". Think
declarative management similar to puppet and chef, although my system
is better because:

* it runs in parallel
* is event based
* functions as a distributed system

There's an introductory blog post [2], two other posts [3,4] and a
video:

https://www.youtube.com/watch?v=GVhpPF0j-iE=1

## Why Libvirt?

The reason this is all very relevant to libvirt, is that since we are
event based, a native libvirt "resource" would be a particularly cool
and powerful thing to have in mgmt. This would enable a user to
declaratively manage libvirt resources, *and* work out automatically
how to change and modify the resource when a configuration change
happens.

This is a highly sought after property. I'd like for mgmt+libvirt to be
the first to do this right. Since there haven't been any event based
management systems that this would work with, we'd be pioneers.

## Help

I don't have enough knowledge of the internals or time to drive
creation of this resource. I was hoping one or more of you might be
interested in working on this, and or suggesting the project to others.
I will of course mentor the developers(s) if they so wish, and help as
much as possible. The project is in golang, and so recommendations on
how best to communicate with and receive events from libvirtd in golang
are welcome. I'm currently considering one of the two libvirt golang
bindings that I've found but other ideas are welcome too.

## Thanks

Thank you in advance, and please let me know if you're interested. We
also have an IRC channel: #mgmtconfig if you'd prefer to talk over IRC.

Cheers,
James
@purpleidea

[1] https://ttboj.wordpress.com/?s=vagrant
[2] https://ttboj.wordpress.com/2016/01/18/next-generation-configuratio
n-mgmt/
[3] https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/
[4] https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/


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] [PATCH v3 07/11] util: Add more getters to threadpool parameters

2016-04-04 Thread Erik Skultety
In order for the client to see all thread counts and limits, current total
and free worker count getters need to be introduced. Client might also be
interested in the job queue length, so provide a getter for that too. As with
the other getters, preparing for the admin interface, mutual exclusion is used
within all getters.

Signed-off-by: Erik Skultety 
---
 src/libvirt_private.syms |  3 +++
 src/util/virthreadpool.c | 33 +
 src/util/virthreadpool.h |  3 +++
 3 files changed, 39 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 684f06c..e9a2bce 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2347,6 +2347,9 @@ virThreadJobSetWorker;
 
 # util/virthreadpool.h
 virThreadPoolFree;
+virThreadPoolGetCurrentWorkers;
+virThreadPoolGetFreeWorkers;
+virThreadPoolGetJobQueueDepth;
 virThreadPoolGetMaxWorkers;
 virThreadPoolGetMinWorkers;
 virThreadPoolGetPriorityWorkers;
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 7ceb090..fec8620 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -317,6 +317,39 @@ size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr 
pool)
 return ret;
 }
 
+size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool)
+{
+size_t ret;
+
+virMutexLock(>mutex);
+ret = pool->nWorkers;
+virMutexUnlock(>mutex);
+
+return ret;
+}
+
+size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool)
+{
+size_t ret;
+
+virMutexLock(>mutex);
+ret = pool->freeWorkers;
+virMutexUnlock(>mutex);
+
+return ret;
+}
+
+size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool)
+{
+size_t ret;
+
+virMutexLock(>mutex);
+ret = pool->jobQueueDepth;
+virMutexUnlock(>mutex);
+
+return ret;
+}
+
 /*
  * @priority - job priority
  * Return: 0 on success, -1 otherwise
diff --git a/src/util/virthreadpool.h b/src/util/virthreadpool.h
index 538b62f..bc0c907 100644
--- a/src/util/virthreadpool.h
+++ b/src/util/virthreadpool.h
@@ -46,6 +46,9 @@ virThreadPoolPtr virThreadPoolNewFull(size_t minWorkers,
 size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool);
 size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool);
 size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetCurrentWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetFreeWorkers(virThreadPoolPtr pool);
+size_t virThreadPoolGetJobQueueDepth(virThreadPoolPtr pool);
 
 void virThreadPoolFree(virThreadPoolPtr pool);
 
-- 
2.4.11

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


[libvirt] [PATCH v3 06/11] util: Use a mutex when retrieving threadpool data

2016-04-04 Thread Erik Skultety
So far, the values the affected getters retrieve are static, i.e. there's no
way of changing them during runtime. But admin interface will later enable
not only getting but changing them as well. So to prevent phenomenons like
torn reads or concurrent reads and writes of unaligned values, use mutual
exclusion when getting these values (writes do, understandably, use them
already).

Signed-off-by: Erik Skultety 
---
 src/util/virthreadpool.c | 24 +---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index e2e9fe4..7ceb090 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -286,17 +286,35 @@ void virThreadPoolFree(virThreadPoolPtr pool)
 
 size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool)
 {
-return pool->minWorkers;
+size_t ret;
+
+virMutexLock(>mutex);
+ret = pool->minWorkers;
+virMutexUnlock(>mutex);
+
+return ret;
 }
 
 size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool)
 {
-return pool->maxWorkers;
+size_t ret;
+
+virMutexLock(>mutex);
+ret = pool->maxWorkers;
+virMutexUnlock(>mutex);
+
+return ret;
 }
 
 size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool)
 {
-return pool->nPrioWorkers;
+size_t ret;
+
+virMutexLock(>mutex);
+ret = pool->nPrioWorkers;
+virMutexUnlock(>mutex);
+
+return ret;
 }
 
 /*
-- 
2.4.11

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


[libvirt] [PATCH v3 00/11] Introduce worker tuning APIs

2016-04-04 Thread Erik Skultety
since v2:
- all getters are now protected by threadpool mutex to prevent torn reads in
concurrent execution
- some checks in adminDispatchServerGetThreadpoolParameters were redundant,
thus were optimizes out
- fixed memory leak in adminDispatchServerGetThreadpoolParameters when
allocating a newlist although typed params serialization already does that
- fixed some cosmetic issues like exporting a function prototype one patch
earlier than it should actually be introduced - a mistake that got there by
interactive rebase

Erik Skultety (11):
  po: Fix record ordering in POTFILES.in
  libvirt-host: Move virTypedParam* to libvirt-common
  admin: Enable usage of typed parameters
  util: Refactor thread creation by introducing virThreadPoolExpand
  util: Report system error when virThreadCreateFull fails
  util: Use a mutex when retrieving threadpool data
  util: Add more getters to threadpool parameters
  admin: Prepare admin protocol for future worker related procedures
  admin: Introduce virAdmServerGethreadPoolParameters
  admin: Introduce virAdmServerSetThreadPoolParameters
  virt-admin: Introduce srv-workertune command

 cfg.mk  |   2 +-
 daemon/admin.c  |  88 +
 daemon/admin_server.c   | 110 +
 daemon/admin_server.h   |  11 ++
 include/libvirt/libvirt-admin.h |  71 +++
 include/libvirt/libvirt-common.h.in | 185 
 include/libvirt/libvirt-host.h  | 186 
 po/POTFILES.in  |   4 +-
 src/admin/admin_protocol.x  |  54 +++-
 src/admin/admin_remote.c|  77 
 src/admin_protocol-structs  |  45 +++
 src/libvirt-admin.c |  83 +
 src/libvirt_admin_private.syms  |   3 +
 src/libvirt_admin_public.syms   |   2 +
 src/libvirt_private.syms|   4 +
 src/rpc/virnetserver.c  |  37 ++
 src/rpc/virnetserver.h  |  13 ++
 src/util/virthreadpool.c| 238 +---
 src/util/virthreadpool.h|   8 ++
 tools/virt-admin.c  | 132 
 20 files changed, 1096 insertions(+), 257 deletions(-)

-- 
2.4.11

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


[libvirt] [PATCH v3 09/11] admin: Introduce virAdmServerGethreadPoolParameters

2016-04-04 Thread Erik Skultety
New API to retrieve current server workerpool specs. Since it uses typed
parameters, more specs to retrieve can be further included in the pool of
supported ones.

Signed-off-by: Erik Skultety 
---
 daemon/admin.c  | 45 +++
 daemon/admin_server.c   | 67 +
 daemon/admin_server.h   |  6 
 include/libvirt/libvirt-admin.h |  6 
 po/POTFILES.in  |  1 +
 src/admin/admin_protocol.x  | 19 +++-
 src/admin/admin_remote.c| 43 ++
 src/admin_protocol-structs  | 11 +++
 src/libvirt-admin.c | 46 
 src/libvirt_admin_private.syms  |  2 ++
 src/libvirt_admin_public.syms   |  1 +
 src/rpc/virnetserver.c  | 22 ++
 src/rpc/virnetserver.h  |  8 +
 13 files changed, 276 insertions(+), 1 deletion(-)

diff --git a/daemon/admin.c b/daemon/admin.c
index 3169cdd..530f6bf 100644
--- a/daemon/admin.c
+++ b/daemon/admin.c
@@ -37,6 +37,7 @@
 #include "virnetserver.h"
 #include "virstring.h"
 #include "virthreadjob.h"
+#include "virtypedparam.h"
 
 #define VIR_FROM_THIS VIR_FROM_ADMIN
 
@@ -133,4 +134,48 @@ adminConnectGetLibVersion(virNetDaemonPtr dmn 
ATTRIBUTE_UNUSED,
 return 0;
 }
 
+static int
+adminDispatchServerGetThreadpoolParameters(virNetServerPtr server 
ATTRIBUTE_UNUSED,
+   virNetServerClientPtr client,
+   virNetMessagePtr msg 
ATTRIBUTE_UNUSED,
+   virNetMessageErrorPtr rerr,
+   struct 
admin_server_get_threadpool_parameters_args *args,
+   struct 
admin_server_get_threadpool_parameters_ret *ret)
+{
+int rv = -1;
+virNetServerPtr srv = NULL;
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+struct daemonAdmClientPrivate *priv =
+virNetServerClientGetPrivateData(client);
+
+if (!(srv = virNetDaemonGetServer(priv->dmn, args->server.name)))
+goto cleanup;
+
+if (adminDaemonGetThreadPoolParameters(srv, , ,
+   args->flags) < 0)
+goto cleanup;
+
+if (nparams > ADMIN_SERVER_THREADPOOL_PARAMETERS_MAX) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Number of threadpool parameters %d exceeds max "
+ "allowed limit: %d"), nparams,
+   ADMIN_SERVER_THREADPOOL_PARAMETERS_MAX);
+goto cleanup;
+}
+
+if (virTypedParamsSerialize(params, nparams,
+(virTypedParameterRemotePtr *) 
>params.params_val,
+>params.params_len, 0) < 0)
+goto cleanup;
+
+rv = 0;
+ cleanup:
+if (rv < 0)
+virNetMessageSaveError(rerr);
+
+virTypedParamsFree(params, nparams);
+virObjectUnref(srv);
+return rv;
+}
 #include "admin_dispatch.h"
diff --git a/daemon/admin_server.c b/daemon/admin_server.c
index 1d30ea5..e7d48b8 100644
--- a/daemon/admin_server.c
+++ b/daemon/admin_server.c
@@ -31,6 +31,7 @@
 #include "virnetdaemon.h"
 #include "virnetserver.h"
 #include "virstring.h"
+#include "virthreadpool.h"
 
 #define VIR_FROM_THIS VIR_FROM_ADMIN
 
@@ -68,3 +69,69 @@ adminConnectLookupServer(virNetDaemonPtr dmn,
 
 return virNetDaemonGetServer(dmn, name);
 }
+
+int
+adminDaemonGetThreadPoolParameters(virNetServerPtr srv,
+   virTypedParameterPtr *params,
+   int *nparams,
+   unsigned int flags)
+{
+int ret = -1;
+int maxparams = 0;
+size_t minWorkers;
+size_t maxWorkers;
+size_t nWorkers;
+size_t freeWorkers;
+size_t nPrioWorkers;
+size_t jobQueueDepth;
+virTypedParameterPtr tmpparams = NULL;
+
+virCheckFlags(0, -1);
+
+if (virNetServerGetThreadPoolParameters(srv, , ,
+, ,
+,
+) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Unable to retrieve threadpool parameters"));
+goto cleanup;
+}
+
+if (virTypedParamsAddUInt(, nparams,
+  , VIR_THREADPOOL_WORKERS_MIN,
+  minWorkers) < 0)
+goto cleanup;
+
+if (virTypedParamsAddUInt(, nparams,
+  , VIR_THREADPOOL_WORKERS_MAX,
+  maxWorkers) < 0)
+goto cleanup;
+
+if (virTypedParamsAddUInt(, nparams,
+  , VIR_THREADPOOL_WORKERS_CURRENT,
+  nWorkers) < 0)
+goto cleanup;
+
+if (virTypedParamsAddUInt(, nparams,
+  , 

[libvirt] [PATCH v3 10/11] admin: Introduce virAdmServerSetThreadPoolParameters

2016-04-04 Thread Erik Skultety
Since threadpool increments the current number of threads according to current
load, i.e. how many jobs are waiting in the queue. The count however, is
constrained by max and min limits of workers. The logic of this new API works
like this:
1) setting the minimum
a) When the limit is increased, depending on the current number of
   threads, new threads are possibly spawned if the current number of
   threads is less than the new minimum limit
b) Decreasing the minimum limit has no possible effect on the current
   number of threads
2) setting the maximum
a) Icreasing the maximum limit has no immediate effect on the current
   number of threads, it only allows the threadpool to spawn more
   threads when new jobs, that would otherwise end up queued, arrive.
b) Decreasing the maximum limit may affect the current number of
   threads, if the current number of threads is less than the new
   maximum limit. Since there may be some ongoing time-consuming jobs
   that would effectively block this API from killing any threads.
   Therefore, this API is asynchronous with best-effort execution,
   i.e. the necessary number of workers will be terminated once they
   finish their previous job, unless other workers had already
   terminated, decreasing the limit to the requested value.
3) setting priority workers
- both increase and decrease in count of these workers have an
  immediate impact on the current number of workers, new ones will be
  spawned or some of them get terminated respectively.

Signed-off-by: Erik Skultety 
---
 daemon/admin.c  | 43 +++
 daemon/admin_server.c   | 43 +++
 daemon/admin_server.h   |  5 +++
 include/libvirt/libvirt-admin.h |  5 +++
 src/admin/admin_protocol.x  | 13 ++-
 src/admin/admin_remote.c| 34 ++
 src/admin_protocol-structs  |  9 +
 src/libvirt-admin.c | 37 
 src/libvirt_admin_private.syms  |  1 +
 src/libvirt_admin_public.syms   |  1 +
 src/libvirt_private.syms|  1 +
 src/rpc/virnetserver.c  | 15 
 src/rpc/virnetserver.h  |  5 +++
 src/util/virthreadpool.c| 77 +++--
 src/util/virthreadpool.h|  5 +++
 15 files changed, 290 insertions(+), 4 deletions(-)

diff --git a/daemon/admin.c b/daemon/admin.c
index 530f6bf..eb961d3 100644
--- a/daemon/admin.c
+++ b/daemon/admin.c
@@ -178,4 +178,47 @@ adminDispatchServerGetThreadpoolParameters(virNetServerPtr 
server ATTRIBUTE_UNUS
 virObjectUnref(srv);
 return rv;
 }
+
+static int
+adminDispatchServerSetThreadpoolParameters(virNetServerPtr server 
ATTRIBUTE_UNUSED,
+   virNetServerClientPtr client,
+   virNetMessagePtr msg 
ATTRIBUTE_UNUSED,
+   virNetMessageErrorPtr rerr,
+   struct 
admin_server_set_threadpool_parameters_args *args)
+{
+int rv = -1;
+virNetServerPtr srv = NULL;
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+struct daemonAdmClientPrivate *priv =
+virNetServerClientGetPrivateData(client);
+
+if (!(srv = virNetDaemonGetServer(priv->dmn, args->server.name))) {
+virReportError(VIR_ERR_NO_SERVER,
+   _("no server with matching name '%s' found"),
+   args->server.name);
+goto cleanup;
+}
+
+if (virTypedParamsDeserialize((virTypedParameterRemotePtr) 
args->params.params_val,
+  args->params.params_len,
+  ADMIN_SERVER_THREADPOOL_PARAMETERS_MAX,
+  ,
+  ) < 0)
+goto cleanup;
+
+
+if (adminDaemonSetThreadPoolParameters(srv, params,
+   nparams, args->flags) < 0)
+goto cleanup;
+
+rv = 0;
+ cleanup:
+if (rv < 0)
+virNetMessageSaveError(rerr);
+
+virTypedParamsFree(params, nparams);
+virObjectUnref(srv);
+return rv;
+}
 #include "admin_dispatch.h"
diff --git a/daemon/admin_server.c b/daemon/admin_server.c
index e7d48b8..573558e 100644
--- a/daemon/admin_server.c
+++ b/daemon/admin_server.c
@@ -32,6 +32,7 @@
 #include "virnetserver.h"
 #include "virstring.h"
 #include "virthreadpool.h"
+#include "virtypedparam.h"
 
 #define VIR_FROM_THIS VIR_FROM_ADMIN
 
@@ -135,3 +136,45 @@ adminDaemonGetThreadPoolParameters(virNetServerPtr srv,
 virTypedParamsFree(tmpparams, *nparams);
 return ret;
 }
+
+int
+adminDaemonSetThreadPoolParameters(virNetServerPtr srv,
+   virTypedParameterPtr params,
+  

[libvirt] [PATCH v3 03/11] admin: Enable usage of typed parameters

2016-04-04 Thread Erik Skultety
Make all relevant changes to admin protocol, in order to achieve $(subj)

Signed-off-by: Erik Skultety 
---
 cfg.mk |  2 +-
 src/admin/admin_protocol.x | 24 
 src/admin_protocol-structs | 25 +
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/cfg.mk b/cfg.mk
index 8e8586f..61397e8 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1227,7 +1227,7 @@ 
exclude_file_name_regexp--sc_prohibit_include_public_headers_brackets = \
   
^(tools/|examples/|include/libvirt/(virterror|libvirt(-(admin|qemu|lxc))?)\.h$$)
 
 exclude_file_name_regexp--sc_prohibit_int_ijk = \
-  ^(src/remote_protocol-structs|src/remote/remote_protocol.x|cfg.mk|include/)$
+  
^(src/remote_protocol-structs|src/remote/remote_protocol.x|cfg.mk|include/|src/admin_protocol-structs|src/admin/admin_protocol.x)$
 
 exclude_file_name_regexp--sc_prohibit_getenv = \
   ^tests/.*\.[ch]$$
diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
index 6590980..57dbb6b 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -22,6 +22,7 @@
  * Author: Martin Kletzander 
  */
 
+%#include 
 %#include "virxdrdefs.h"
 
 /*- Data types. -*/
@@ -41,12 +42,35 @@ typedef string admin_nonnull_string;
 /* A long string, which may be NULL. */
 typedef admin_nonnull_string *admin_string;
 
+union admin_typed_param_value switch (int type) {
+ case VIR_TYPED_PARAM_INT:
+ int i;
+ case VIR_TYPED_PARAM_UINT:
+ unsigned int ui;
+ case VIR_TYPED_PARAM_LLONG:
+ hyper l;
+ case VIR_TYPED_PARAM_ULLONG:
+ unsigned hyper ul;
+ case VIR_TYPED_PARAM_DOUBLE:
+ double d;
+ case VIR_TYPED_PARAM_BOOLEAN:
+ int b;
+ case VIR_TYPED_PARAM_STRING:
+ admin_nonnull_string s;
+};
+
+struct admin_typed_param {
+admin_nonnull_string field;
+admin_typed_param_value value;
+};
+
 /* A server which may NOT be NULL */
 struct admin_nonnull_server {
 admin_nonnull_string name;
 };
 
 /*- Protocol. -*/
+
 struct admin_connect_open_args {
 unsigned int flags;
 };
diff --git a/src/admin_protocol-structs b/src/admin_protocol-structs
index d8aca06..26c8443 100644
--- a/src/admin_protocol-structs
+++ b/src/admin_protocol-structs
@@ -1,4 +1,29 @@
 /* -*- c -*- */
+enum {
+VIR_TYPED_PARAM_INT = 1,
+VIR_TYPED_PARAM_UINT = 2,
+VIR_TYPED_PARAM_LLONG = 3,
+VIR_TYPED_PARAM_ULLONG = 4,
+VIR_TYPED_PARAM_DOUBLE = 5,
+VIR_TYPED_PARAM_BOOLEAN = 6,
+VIR_TYPED_PARAM_STRING = 7,
+};
+struct admin_typed_param_value {
+inttype;
+union {
+inti;
+u_int  ui;
+int64_tl;
+uint64_t   ul;
+double d;
+intb;
+admin_nonnull_string s;
+} admin_typed_param_value_u;
+};
+struct admin_typed_param {
+admin_nonnull_string   field;
+admin_typed_param_valuevalue;
+};
 struct admin_nonnull_server {
 admin_nonnull_string   name;
 };
-- 
2.4.11

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


[libvirt] [PATCH v3 05/11] util: Report system error when virThreadCreateFull fails

2016-04-04 Thread Erik Skultety
Otherwise 'Unknown' error will be returned to client.

Signed-off-by: Erik Skultety 
---
 po/POTFILES.in   | 1 +
 src/util/virthreadpool.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5316d4f..6d720c0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -238,6 +238,7 @@ src/util/virstoragefile.c
 src/util/virstring.c
 src/util/virsysinfo.c
 src/util/virthreadjob.c
+src/util/virthreadpool.c
 src/util/virtime.c
 src/util/virtpm.c
 src/util/virtypedparam.c
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 8af4ec0..e2e9fe4 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -183,6 +183,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, 
bool priority)
 true,
 data) < 0) {
 VIR_FREE(data);
+virReportSystemError(errno, "%s", _("Failed to create thread"));
 goto error;
 }
 }
-- 
2.4.11

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


[libvirt] [PATCH v3 01/11] po: Fix record ordering in POTFILES.in

2016-04-04 Thread Erik Skultety
Commit a474371f broke ordering of the records. Now if a file required for
translation is missing, syntax-check (po-check) will fail and suggest a patch
to add the missing file. However, if the ordering is broken, the patch will
be understandably inapplicable (cleanly), since the diff isn't against the
actual POTFILES.in as is, but against POTFILES.in as it should look like
with the required file missing instead.

Signed-off-by: Erik Skultety 
---
 po/POTFILES.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0d7f9f9..5316d4f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,5 +1,5 @@
-daemon/admin_dispatch.h
 daemon/admin.c
+daemon/admin_dispatch.h
 daemon/libvirtd-config.c
 daemon/libvirtd.c
 daemon/qemu_dispatch.h
-- 
2.4.11

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


[libvirt] [PATCH v3 08/11] admin: Prepare admin protocol for future worker related procedures

2016-04-04 Thread Erik Skultety
Before any getter or setter methods can be introduced, first specify a set of
public attributes/flags that these methods will be compatible with.

Signed-off-by: Erik Skultety 
---
 include/libvirt/libvirt-admin.h | 60 +
 1 file changed, 60 insertions(+)

diff --git a/include/libvirt/libvirt-admin.h b/include/libvirt/libvirt-admin.h
index 25bcbf4..35849b1 100644
--- a/include/libvirt/libvirt-admin.h
+++ b/include/libvirt/libvirt-admin.h
@@ -110,6 +110,66 @@ virAdmServerPtr virAdmConnectLookupServer(virAdmConnectPtr 
conn,
   const char *name,
   unsigned int flags);
 
+/* Manage threadpool attributes */
+
+/**
+ * VIR_THREADPOOL_WORKERS_MIN:
+ * Macro for the threadpool minWorkers limit: represents the bottom limit to
+ * number of active workers in threadpool, as uint.
+ */
+
+# define VIR_THREADPOOL_WORKERS_MIN "minWorkers"
+
+/**
+ * VIR_THREADPOOL_WORKERS_MAX:
+ * Macro for the threadpool maxWorkers limit: represents the upper limit to
+ * number of active workers in threadpool, as uint. The value of this limit has
+ * to be greater than VIR_THREADPOOL_WORKERS_MIN at all times.
+ */
+
+# define VIR_THREADPOOL_WORKERS_MAX "maxWorkers"
+
+/**
+ * VIR_THREADPOOL_WORKERS_PRIORITY:
+ * Macro for the threadpool nPrioWorkers attribute: represents the current 
number
+ * of active priority workers in threadpool, as uint.
+ */
+
+# define VIR_THREADPOOL_WORKERS_PRIORITY "prioWorkers"
+
+/**
+ * VIR_THREADPOOL_WORKERS_FREE:
+ * Macro for the threadpool freeWorkers attribute: represents the current 
number
+ * of free workers available to accomplish a job, as uint.
+ *
+ * NOTE: This attribute is read-only and any attempt to set it will be denied
+ * by daemon
+ */
+
+# define VIR_THREADPOOL_WORKERS_FREE "freeWorkers"
+
+/**
+ * VIR_THREADPOOL_WORKERS_CURRENT:
+ * Macro for the threadpool nWorkers attribute: represents the current number
+ * of active ordinary workers in threadpool, as uint.
+ *
+ * NOTE: This attribute is read-only and any attempt to set it will be denied
+ * by daemon
+ */
+
+# define VIR_THREADPOOL_WORKERS_CURRENT "nWorkers"
+
+/**
+ * VIR_THREADPOOL_JOB_QUEUE_DEPTH:
+ * Macro for the threadpool jobQueueDepth attribute: represents the current
+ * number of jobs waiting in a queue to be processed, as uint.
+ *
+ * NOTE: This attribute is read-only and any attempt to set it will be denied
+ * by daemon
+ */
+
+# define VIR_THREADPOOL_JOB_QUEUE_DEPTH "jobQueueDepth"
+
 # ifdef __cplusplus
 }
 # endif
-- 
2.4.11

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


[libvirt] [PATCH v3 04/11] util: Refactor thread creation by introducing virThreadPoolExpand

2016-04-04 Thread Erik Skultety
When either creating a threadpool, or creating a new thread to accomplish a job
that had been placed into the jobqueue, every time thread-specific data need to
be allocated, threadpool needs to be (re)-allocated and thread count indicators
updated. Make the code clearer to read by compressing these operations into a
more complex one.

Signed-off-by: Erik Skultety 
---
 src/util/virthreadpool.c | 109 +++
 1 file changed, 44 insertions(+), 65 deletions(-)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index f640448..8af4ec0 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -157,6 +157,43 @@ static void virThreadPoolWorker(void *opaque)
 virMutexUnlock(>mutex);
 }
 
+static int
+virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
+{
+virThreadPtr workers = priority ? pool->prioWorkers : pool->workers;
+size_t *curWorkers = priority ? >nPrioWorkers : >nWorkers;
+size_t i = 0;
+struct virThreadPoolWorkerData *data = NULL;
+
+if (VIR_EXPAND_N(workers, *curWorkers, gain) < 0)
+return -1;
+
+for (i = 0; i < gain; i++) {
+if (VIR_ALLOC(data) < 0)
+goto error;
+
+data->pool = pool;
+data->cond = priority ? >prioCond : >cond;
+data->priority = priority;
+
+if (virThreadCreateFull([i],
+false,
+virThreadPoolWorker,
+pool->jobFuncName,
+true,
+data) < 0) {
+VIR_FREE(data);
+goto error;
+}
+}
+
+return 0;
+
+ error:
+*curWorkers -= gain - i;
+return -1;
+}
+
 virThreadPoolPtr
 virThreadPoolNewFull(size_t minWorkers,
  size_t maxWorkers,
@@ -166,8 +203,6 @@ virThreadPoolNewFull(size_t minWorkers,
  void *opaque)
 {
 virThreadPoolPtr pool;
-size_t i;
-struct virThreadPoolWorkerData *data = NULL;
 
 if (minWorkers > maxWorkers)
 minWorkers = maxWorkers;
@@ -188,58 +223,23 @@ virThreadPoolNewFull(size_t minWorkers,
 if (virCondInit(>quit_cond) < 0)
 goto error;
 
-if (VIR_ALLOC_N(pool->workers, minWorkers) < 0)
-goto error;
-
 pool->minWorkers = minWorkers;
 pool->maxWorkers = maxWorkers;
 
-for (i = 0; i < minWorkers; i++) {
-if (VIR_ALLOC(data) < 0)
-goto error;
-data->pool = pool;
-data->cond = >cond;
-
-if (virThreadCreateFull(>workers[i],
-false,
-virThreadPoolWorker,
-pool->jobFuncName,
-true,
-data) < 0) {
-goto error;
-}
-pool->nWorkers++;
-}
+if (virThreadPoolExpand(pool, minWorkers, false) < 0)
+goto error;
 
 if (prioWorkers) {
 if (virCondInit(>prioCond) < 0)
 goto error;
-if (VIR_ALLOC_N(pool->prioWorkers, prioWorkers) < 0)
-goto error;
 
-for (i = 0; i < prioWorkers; i++) {
-if (VIR_ALLOC(data) < 0)
-goto error;
-data->pool = pool;
-data->cond = >prioCond;
-data->priority = true;
-
-if (virThreadCreateFull(>prioWorkers[i],
-false,
-virThreadPoolWorker,
-pool->jobFuncName,
-true,
-data) < 0) {
-goto error;
-}
-pool->nPrioWorkers++;
-}
+if (virThreadPoolExpand(pool, prioWorkers, true) < 0)
+goto error;
 }
 
 return pool;
 
  error:
-VIR_FREE(data);
 virThreadPoolFree(pool);
 return NULL;
 
@@ -307,36 +307,15 @@ int virThreadPoolSendJob(virThreadPoolPtr pool,
  void *jobData)
 {
 virThreadPoolJobPtr job;
-struct virThreadPoolWorkerData *data = NULL;
 
 virMutexLock(>mutex);
 if (pool->quit)
 goto error;
 
 if (pool->freeWorkers - pool->jobQueueDepth <= 0 &&
-pool->nWorkers < pool->maxWorkers) {
-if (VIR_EXPAND_N(pool->workers, pool->nWorkers, 1) < 0)
-goto error;
-
-if (VIR_ALLOC(data) < 0) {
-pool->nWorkers--;
-goto error;
-}
-
-data->pool = pool;
-data->cond = >cond;
-
-if (virThreadCreateFull(>workers[pool->nWorkers - 1],
-false,
-virThreadPoolWorker,
-pool->jobFuncName,
-true,
-data) < 0) {
-VIR_FREE(data);
-pool->nWorkers--;
-goto 

[libvirt] [PATCH v3 11/11] virt-admin: Introduce srv-workertune command

2016-04-04 Thread Erik Skultety
Wire up the server threadpool tunable APIs to virt-admin client.

Signed-off-by: Erik Skultety 
---
 tools/virt-admin.c | 132 +
 1 file changed, 132 insertions(+)

diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index edb8690..dec1096 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -353,6 +353,127 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd 
ATTRIBUTE_UNUSED)
 return ret;
 }
 
+
+/* 
+ * Command srv-workertune
+ * 
+ */
+
+static const vshCmdInfo info_srv_workertune[] = {
+{.name = "help",
+ .data = N_("Get or set server workerpool parameters")
+},
+{.name = "desc",
+ .data = N_("Get or set server workerpool parameters. Some parameters are "
+"read-only, thus only \n"
+"a subset of all supported parameters can actually be "
+"set via OPTIONS.\n"
+"To retrieve workerpool parameters, use the command "
+"without any options: \n\n"
+"virt-admin # srv-workertune ")
+},
+{.name = NULL}
+};
+
+static const vshCmdOptDef opts_srv_workertune[] = {
+{.name = "server",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("Server to get threadpool parameters for."),
+},
+{.name = "min-workers",
+ .type = VSH_OT_INT,
+ .help = N_("Change the value of bottom limit to number of workers."),
+},
+{.name = "max-workers",
+ .type = VSH_OT_INT,
+ .help = N_("Change the value of top limit to number of workers."),
+},
+{.name = "priority-workers",
+ .type = VSH_OT_INT,
+ .help = N_("Change the current number of priority workers"),
+},
+{.name = NULL}
+};
+
+static bool
+cmdSrvWorkertune(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
+{
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+int maxparams = 0;
+unsigned int val;
+unsigned int min, max;
+int rv = 0;
+size_t i;
+bool ret = false;
+const char *srvname = NULL;
+virAdmServerPtr srv = NULL;
+vshAdmControlPtr priv = ctl->privData;
+
+if (vshCommandOptStringReq(ctl, cmd, "server", ) < 0)
+return false;
+
+#define PARSE_WORKERTUNE_PARAM(NAME, FIELD)  \
+if ((rv = vshCommandOptUInt(ctl, cmd, NAME, )) < 0) {\
+vshError(ctl, _("Unable to parse integer parameter '%s'"), NAME);\
+goto cleanup;\
+} else if (rv > 0) { \
+if (virTypedParamsAddUInt(, , , \
+  FIELD, val) < 0)   \
+goto save_error; \
+}
+
+PARSE_WORKERTUNE_PARAM("max-workers", VIR_THREADPOOL_WORKERS_MAX);
+PARSE_WORKERTUNE_PARAM("min-workers", VIR_THREADPOOL_WORKERS_MIN);
+PARSE_WORKERTUNE_PARAM("priority-workers", 
VIR_THREADPOOL_WORKERS_PRIORITY);
+
+#undef PARSE_WORKERTUNE_PARAM
+
+if (virTypedParamsGetUInt(params, nparams,
+  VIR_THREADPOOL_WORKERS_MAX, ) &&
+virTypedParamsGetUInt(params, nparams,
+  VIR_THREADPOOL_WORKERS_MIN, ) && min > max) {
+vshError(ctl, "%s", _("--min-workers must be less than 
--max-workers"));
+goto cleanup;
+}
+
+if (!(srv = virAdmConnectLookupServer(priv->conn, srvname, 0)))
+goto cleanup;
+
+/* set server threadpool parameters */
+if (nparams) {
+if (virAdmServerSetThreadPoolParameters(srv, params,
+nparams, 0) < 0)
+goto error;
+} else {
+if (virAdmServerGetThreadPoolParameters(srv, ,
+, 0) < 0) {
+vshError(ctl, "%s",
+ _("Unable to get server workerpool parameters"));
+goto cleanup;
+}
+
+for (i = 0; i < nparams; i++)
+vshPrint(ctl, "%-15s: %d\n", params[i].field, params[i].value.ui);
+}
+
+ret = true;
+
+ cleanup:
+virTypedParamsFree(params, nparams);
+if (srv)
+virAdmServerFree(srv);
+return ret;
+
+ save_error:
+vshSaveLibvirtError();
+
+ error:
+vshError(ctl, "%s", _("Unable to change server workerpool parameters"));
+goto cleanup;
+}
+
 static void *
 vshAdmConnectionHandler(vshControl *ctl)
 {
@@ -655,9 +776,20 @@ static const vshCmdDef monitoringCmds[] = {
 {.name = NULL}
 };
 
+static const vshCmdDef managementCmds[] = {
+{.name = "srv-workertune",
+ .handler = cmdSrvWorkertune,
+ .opts = opts_srv_workertune,
+ .info = info_srv_workertune,
+ .flags = 0
+},
+{.name = NULL}
+};
+
 static const vshCmdGrp cmdGroups[] = {
 {"Virt-admin itself", "virt-admin", 

[libvirt] [PATCH v3 02/11] libvirt-host: Move virTypedParam* to libvirt-common

2016-04-04 Thread Erik Skultety
Commits 0472cef6, 9afc115f, 8cd1d546 exported typed params handlers internally,
but a commit which would move the public definition from libvirt-host to
libvirt-common was missing.

Signed-off-by: Erik Skultety 
---
 include/libvirt/libvirt-common.h.in | 185 +++
 include/libvirt/libvirt-host.h  | 186 
 2 files changed, 185 insertions(+), 186 deletions(-)

diff --git a/include/libvirt/libvirt-common.h.in 
b/include/libvirt/libvirt-common.h.in
index efbb91b..772e40f 100644
--- a/include/libvirt/libvirt-common.h.in
+++ b/include/libvirt/libvirt-common.h.in
@@ -120,6 +120,191 @@ typedef enum {
 # endif
 } virConnectCloseReason;
 
+/**
+ * virTypedParameterType:
+ *
+ * Express the type of a virTypedParameter
+ */
+typedef enum {
+VIR_TYPED_PARAM_INT = 1, /* integer case */
+VIR_TYPED_PARAM_UINT= 2, /* unsigned integer case */
+VIR_TYPED_PARAM_LLONG   = 3, /* long long case */
+VIR_TYPED_PARAM_ULLONG  = 4, /* unsigned long long case */
+VIR_TYPED_PARAM_DOUBLE  = 5, /* double case */
+VIR_TYPED_PARAM_BOOLEAN = 6, /* boolean(character) case */
+VIR_TYPED_PARAM_STRING  = 7, /* string case */
+
+# ifdef VIR_ENUM_SENTINELS
+VIR_TYPED_PARAM_LAST
+# endif
+} virTypedParameterType;
+
+/**
+ * virTypedParameterFlags:
+ *
+ * Flags related to libvirt APIs that use virTypedParameter.
+ *
+ * These enums should not conflict with those of virDomainModificationImpact.
+ */
+typedef enum {
+/* 1 << 0 is reserved for virDomainModificationImpact */
+/* 1 << 1 is reserved for virDomainModificationImpact */
+
+/* Older servers lacked the ability to handle string typed
+ * parameters.  Attempts to set a string parameter with an older
+ * server will fail at the client, but attempts to retrieve
+ * parameters must not return strings from a new server to an
+ * older client, so this flag exists to identify newer clients to
+ * newer servers.  This flag is automatically set when needed, so
+ * the user does not have to worry about it; however, manually
+ * setting the flag can be used to reject servers that cannot
+ * return typed strings, even if no strings would be returned.
+ */
+VIR_TYPED_PARAM_STRING_OKAY = 1 << 2,
+
+} virTypedParameterFlags;
+
+/**
+ * VIR_TYPED_PARAM_FIELD_LENGTH:
+ *
+ * Macro providing the field length of virTypedParameter name
+ */
+# define VIR_TYPED_PARAM_FIELD_LENGTH 80
+
+/**
+ * virTypedParameter:
+ *
+ * A named parameter, including a type and value.
+ *
+ * The types virSchedParameter, virBlkioParameter, and
+ * virMemoryParameter are aliases of this type, for use when
+ * targeting libvirt earlier than 0.9.2.
+ */
+typedef struct _virTypedParameter virTypedParameter;
+
+struct _virTypedParameter {
+char field[VIR_TYPED_PARAM_FIELD_LENGTH];  /* parameter name */
+int type;   /* parameter type, virTypedParameterType */
+union {
+int i;  /* type is INT */
+unsigned int ui;/* type is UINT */
+long long int l;/* type is LLONG */
+unsigned long long int ul;  /* type is ULLONG */
+double d;   /* type is DOUBLE */
+char b; /* type is BOOLEAN */
+char *s;/* type is STRING, may not be NULL */
+} value; /* parameter value */
+};
+
+/**
+ * virTypedParameterPtr:
+ *
+ * a pointer to a virTypedParameter structure.
+ */
+typedef virTypedParameter *virTypedParameterPtr;
+
+
+virTypedParameterPtr
+virTypedParamsGet   (virTypedParameterPtr params,
+ int nparams,
+ const char *name);
+int
+virTypedParamsGetInt(virTypedParameterPtr params,
+ int nparams,
+ const char *name,
+ int *value);
+int
+virTypedParamsGetUInt   (virTypedParameterPtr params,
+ int nparams,
+ const char *name,
+ unsigned int *value);
+int
+virTypedParamsGetLLong  (virTypedParameterPtr params,
+ int nparams,
+ const char *name,
+ long long *value);
+int
+virTypedParamsGetULLong (virTypedParameterPtr params,
+ int nparams,
+ const char *name,
+ unsigned long long *value);
+int
+virTypedParamsGetDouble (virTypedParameterPtr params,
+ int nparams,
+ const char *name,
+ double *value);
+int
+virTypedParamsGetBoolean(virTypedParameterPtr params,
+ int nparams,
+ const char *name,
+ int *value);
+int
+virTypedParamsGetString (virTypedParameterPtr params,
+ int nparams,
+ 

[libvirt] [ 4/5] bridge network ignore peer address

2016-04-04 Thread Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov 
---
 src/network/bridge_driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 0d14e3a3..73236ffe1cd9 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1971,7 +1971,7 @@ networkAddAddrToBridge(virNetworkObjPtr network,
 }
 
 if (virNetDevSetIPAddress(network->def->bridge,
-  >address, prefix) < 0)
+  >address, NULL, prefix) < 0)
 return -1;
 
 return 0;
-- 
2.7.3

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


[libvirt] [ 3/5] lxc domain allow to set peer address

2016-04-04 Thread Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov 
---
 src/lxc/lxc_container.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 348bbfbc01fc..a1deb0c00d4c 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -520,7 +520,7 @@ static int 
lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef,
 
 VIR_DEBUG("Adding IP address '%s/%u' to '%s'",
   ipStr, ip->prefix, newname);
-if (virNetDevSetIPAddress(newname, >address, prefix) < 0) {
+if (virNetDevSetIPAddress(newname, >address, >peer, 
prefix) < 0) {
 virReportError(VIR_ERR_SYSTEM_ERROR,
_("Failed to set IP address '%s' on %s"),
ipStr, newname);
-- 
2.7.3

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


[libvirt] [ 2/5] libvirt domain xml allow to set peer address

2016-04-04 Thread Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov 
---
 docs/formatdomain.html.in | 12 +++-
 docs/schemas/domaincommon.rng |  5 +
 src/conf/domain_conf.c| 14 +-
 src/conf/domain_conf.h|  1 +
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 957b839eb745..a6c6b15aa8e4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4758,6 +4758,7 @@ qemu-kvm -net nic,model=? /dev/null
   source network='default'/
   target dev='vnet0'/
   ip address='192.168.122.5' prefix='24'/
+  ip address='192.168.122.5' prefix='24' peer='10.0.0.10'/
   route family='ipv4' address='192.168.122.0' prefix='24' 
gateway='192.168.122.1'/
   route family='ipv4' address='192.168.122.8' 
gateway='192.168.122.1'/
 /interface
@@ -4790,7 +4791,16 @@ qemu-kvm -net nic,model=? /dev/null
 to define the network routes to use for the network device. The attributes
 of this element are described in the documentation for the 
route
 element in network 
definitions.
-This is only used by the LXC driver.
+This is used by the LXC driver and Since 1.3.3 
by the QEMU
+driver.
+
+
+
+Since 1.3.3 ip elements can hold peer attribute 
to assign
+a point-to-point address for the network device. The attributes  of this 
element
+are described in the documentation for the ip element in
+network definitions.
+This is only used by the LXC and QEMU drivers.
 
 
 vhost-user interface
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 54c149dd5290..fa545261326d 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2393,6 +2393,11 @@
   
 
   
+  
+
+  
+
+  
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d4c78fdb9fbb..65d2b3eeef3b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5734,7 +5734,7 @@ virDomainNetIpParseXML(xmlNodePtr node)
 unsigned int prefixValue = 0;
 char *familyStr = NULL;
 int family = AF_UNSPEC;
-char *address = NULL;
+char *address = NULL, *peer = NULL;
 
 if (!(prefixStr = virXMLPropString(node, "prefix")) ||
 (virStrToLong_ui(prefixStr, NULL, 10, ) < 0)) {
@@ -5748,6 +5748,9 @@ virDomainNetIpParseXML(xmlNodePtr node)
 goto cleanup;
 }
 
+if ((peer = virXMLPropString(node, "peer")) == NULL)
+VIR_DEBUG("Peer is empty");
+
 familyStr = virXMLPropString(node, "family");
 if (familyStr && STREQ(familyStr, "ipv4"))
 family = AF_INET;
@@ -5765,6 +5768,14 @@ virDomainNetIpParseXML(xmlNodePtr node)
address);
 goto cleanup;
 }
+
+if ((peer != NULL) && (virSocketAddrParse(>peer, peer, family) < 0)) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _("Failed to parse IP address: '%s'"),
+   peer);
+goto cleanup;
+}
+
 ip->prefix = prefixValue;
 
 ret = ip;
@@ -5774,6 +5785,7 @@ virDomainNetIpParseXML(xmlNodePtr node)
 VIR_FREE(prefixStr);
 VIR_FREE(familyStr);
 VIR_FREE(address);
+VIR_FREE(peer);
 VIR_FREE(ip);
 return ret;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fe9faebff6d6..029eee3a5618 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -514,6 +514,7 @@ typedef struct _virDomainNetIpDef virDomainNetIpDef;
 typedef virDomainNetIpDef *virDomainNetIpDefPtr;
 struct _virDomainNetIpDef {
 virSocketAddr address;   /* ipv4 or ipv6 address */
+virSocketAddr peer;/* ipv4 or ipv6 address of peer */
 unsigned int prefix; /* number of 1 bits in the net mask */
 };
 
-- 
2.7.3

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


[libvirt] [ 5/5] qemu domain allow to set ip address, peer address and route

2016-04-04 Thread Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov 
---
 src/qemu/qemu_interface.c | 39 +++
 1 file changed, 39 insertions(+)

diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index 13a513152876..5729325fadb9 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -474,6 +474,45 @@ qemuInterfaceEthernetConnect(virDomainDefPtr def,
 if (virNetDevSetMAC(net->ifname, ) < 0)
 goto cleanup;
 
+for (j = 0; j < net->nips; j++) {
+virDomainNetIpDefPtr ip = net->ips[j];
+unsigned int prefix = (ip->prefix > 0) ? ip->prefix :
+VIR_SOCKET_ADDR_DEFAULT_PREFIX;
+char *ipStr = virSocketAddrFormat(>address);
+
+VIR_DEBUG("Adding IP address '%s/%u' to '%s'",
+  ipStr, ip->prefix, net->ifname);
+
+if (virNetDevSetIPAddress(net->ifname, >address, >peer, 
prefix) < 0) {
+virReportError(VIR_ERR_SYSTEM_ERROR,
+   _("Failed to set IP address '%s' on %s"),
+   ipStr, net->ifname);
+VIR_FREE(ipStr);
+goto cleanup;
+}
+VIR_FREE(ipStr);
+}
+
+if (net->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP ||
+net->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DEFAULT) {
+if (virNetDevSetOnline(net->ifname, true) < 0)
+goto cleanup;
+
+/* Set the routes */
+for (j = 0; j < net->nroutes; j++) {
+virNetworkRouteDefPtr route = net->routes[j];
+
+if (virNetDevAddRoute(net->ifname,
+  virNetworkRouteDefGetAddress(route),
+  virNetworkRouteDefGetPrefix(route),
+  virNetworkRouteDefGetGateway(route),
+  virNetworkRouteDefGetMetric(route)) < 0) {
+goto cleanup;
+}
+}
+}
+
+
 if (net->script &&
 qemuExecuteEthernetScript(net->ifname, net->script) < 0)
 goto cleanup;
-- 
2.7.3

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


[libvirt] [ 1/5] virnetdev allow to set peer address

2016-04-04 Thread Vasiliy Tolstov
Signed-off-by: Vasiliy Tolstov 
---
 src/util/virnetdev.c | 54 
 src/util/virnetdev.h |  1 +
 2 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index aed50f546263..6e32ebbf6cee 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1039,21 +1039,28 @@ virNetDevCreateNetlinkAddressMessage(int messageType,
  const char *ifname,
  virSocketAddr *addr,
  unsigned int prefix,
- virSocketAddr *broadcast)
+ virSocketAddr *broadcast,
+ virSocketAddr *peer)
 {
 struct nl_msg *nlmsg = NULL;
 struct ifaddrmsg ifa;
 unsigned int ifindex;
 void *addrData = NULL;
+void *peerData = NULL;
 void *broadcastData = NULL;
 size_t addrDataLen;
 
 if (virNetDevGetIPAddressBinary(addr, , ) < 0)
 return NULL;
 
-if (broadcast && virNetDevGetIPAddressBinary(broadcast, ,
- ) < 0)
-return NULL;
+if (peer && VIR_SOCKET_ADDR_VALID(peer)) {
+if (virNetDevGetIPAddressBinary(peer, , ) < 0)
+return NULL;
+} else if (broadcast) {
+if (virNetDevGetIPAddressBinary(broadcast, ,
+) < 0)
+return NULL;
+}
 
 /* Get the interface index */
 if ((ifindex = if_nametoindex(ifname)) == 0)
@@ -1078,12 +1085,15 @@ virNetDevCreateNetlinkAddressMessage(int messageType,
 if (nla_put(nlmsg, IFA_LOCAL, addrDataLen, addrData) < 0)
 goto buffer_too_small;
 
-if (nla_put(nlmsg, IFA_ADDRESS, addrDataLen, addrData) < 0)
-goto buffer_too_small;
+if (peerData) {
+if (nla_put(nlmsg, IFA_ADDRESS, addrDataLen, peerData) < 0)
+goto buffer_too_small;
+}
 
-if (broadcastData &&
-nla_put(nlmsg, IFA_BROADCAST, addrDataLen, broadcastData) < 0)
-goto buffer_too_small;
+if (broadcastData) {
+if (nla_put(nlmsg, IFA_BROADCAST, addrDataLen, broadcastData) < 0)
+goto buffer_too_small;
+}
 
 return nlmsg;
 
@@ -1098,6 +1108,7 @@ virNetDevCreateNetlinkAddressMessage(int messageType,
  * virNetDevSetIPAddress:
  * @ifname: the interface name
  * @addr: the IP address (IPv4 or IPv6)
+ * @peer: The IP address of peer (IPv4 or IPv6)
  * @prefix: number of 1 bits in the netmask
  *
  * Add an IP address to an interface. This function *does not* remove
@@ -1108,6 +1119,7 @@ virNetDevCreateNetlinkAddressMessage(int messageType,
  */
 int virNetDevSetIPAddress(const char *ifname,
   virSocketAddr *addr,
+  virSocketAddr *peer,
   unsigned int prefix)
 {
 virSocketAddr *broadcast = NULL;
@@ -1116,9 +1128,8 @@ int virNetDevSetIPAddress(const char *ifname,
 struct nlmsghdr *resp = NULL;
 unsigned int recvbuflen;
 
-
 /* The caller needs to provide a correct address */
-if (VIR_SOCKET_ADDR_FAMILY(addr) == AF_INET) {
+if (VIR_SOCKET_ADDR_FAMILY(addr) == AF_INET && 
!VIR_SOCKET_ADDR_VALID(peer)) {
 /* compute a broadcast address if this is IPv4 */
 if (VIR_ALLOC(broadcast) < 0)
 return -1;
@@ -1129,7 +1140,7 @@ int virNetDevSetIPAddress(const char *ifname,
 
 if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_NEWADDR, ifname,
addr, prefix,
-   broadcast)))
+   broadcast, peer)))
 goto cleanup;
 
 if (virNetlinkCommand(nlmsg, , , 0, 0,
@@ -1288,7 +1299,7 @@ int virNetDevClearIPAddress(const char *ifname,
 
 if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_DELADDR, ifname,
addr, prefix,
-   NULL)))
+   NULL, NULL)))
 goto cleanup;
 
 if (virNetlinkCommand(nlmsg, , , 0, 0,
@@ -1423,21 +1434,27 @@ virNetDevWaitDadFinish(virSocketAddrPtr *addrs, size_t 
count)
 
 int virNetDevSetIPAddress(const char *ifname,
   virSocketAddr *addr,
+  virSocketAddr *peer,
   unsigned int prefix)
 {
 virCommandPtr cmd = NULL;
-char *addrstr = NULL, *bcaststr = NULL;
+char *addrstr = NULL, *bcaststr = NULL, *peerstr = NULL;
 virSocketAddr broadcast;
 int ret = -1;
 
 if (!(addrstr = virSocketAddrFormat(addr)))
 goto cleanup;
+
+if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat()))
+goto cleanup;
+
 /* format up a broadcast address if this is IPv4 */
-if 

[libvirt] [ 0/5] netdev ethernet allow to set ip, route and peer address

2016-04-04 Thread Vasiliy Tolstov
Some minor improvements and patch split as suggested by Laine Stump

Vasiliy Tolstov (5):
  virnetdev allow to set peer address
  libvirt domain xml allow to set peer address
  lxc domain allow to set peer address
  bridge network ignore peer address
  qemu domain allow to set ip address, peer address and route

 docs/formatdomain.html.in | 12 +-
 docs/schemas/domaincommon.rng |  5 
 src/conf/domain_conf.c| 14 ++-
 src/conf/domain_conf.h|  1 +
 src/lxc/lxc_container.c   |  2 +-
 src/network/bridge_driver.c   |  2 +-
 src/qemu/qemu_interface.c | 39 +++
 src/util/virnetdev.c  | 54 ++-
 src/util/virnetdev.h  |  1 +
 9 files changed, 110 insertions(+), 20 deletions(-)

--
2.7.3

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


Re: [libvirt] [PATCH for 1.3.3 0/6] Fix a mis-merge

2016-04-04 Thread John Ferlan


On 04/04/2016 03:47 PM, Cole Robinson wrote:
> On 04/04/2016 03:36 PM, John Ferlan wrote:
>> Details in each patch... 
>>
>> Depending on whether I get a review before I close my eyes for the
>> night I can push or if reviewed after than and before a release is
>> made - I'm sure someone else can grab and push too...
>>
>> John Ferlan (6):
>>   qemu: Fix mis-merge of qemuBuildSmartcardCommandLine
>>   qemu: Fix mis-merge of qemuBuildSerialCommandLine
>>   qemu: Fix mis-merge of qemuBuildParallelsCommandLine
>>   qemu: Fix mis-merge of qemuBuildChannelsCommandLine
>>   qemu: Fix mis-merge of qemuBuildConsoleCommandLine
>>   qemu: Fix mis-merge of qemuBuildRedirdevCommandLine
>>
>>  src/qemu/qemu_command.c | 16 
>>  1 file changed, 8 insertions(+), 8 deletions(-)
>>
> 
> ACK series. Future todo item to find a way to test the logManager/-add-fd path
> which would have caught this
> 

Thanks - I just pushed, so hopefully there's nothing else that pops up
to stop 1.3.3...  and yes, I agree need a way to test this better.

John

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


Re: [libvirt] [PATCH] util: Create virsecret module adding virSecretGetSecretString

2016-04-04 Thread John Ferlan


On 04/04/2016 10:33 AM, Ján Tomko wrote:
> On Thu, Mar 31, 2016 at 11:05:07AM -0400, John Ferlan wrote:
>> Commit id 'fb2bd208' essentially copied the qemuGetSecretString
>> creating an libxlGetSecretString.  Rather than have multiple copies
>> of the same code, create virsecret.{c,h} files and place the common
>> function in there.
>>
>> Usage is from both qemu_command.c and libxl_conf.c
>>
>> Signed-off-by: John Ferlan 
>> ---
>> Not for 1.3.3, but I may as well get it "out there" now...
>>
>>  po/POTFILES.in   |   1 +
>>  src/Makefile.am  |   1 +
>>  src/libvirt_private.syms |   3 ++
>>  src/libxl/libxl_conf.c   |  82 +++-
>>  src/qemu/qemu_command.c  |  87 --
>>  src/util/virsecret.c | 120 
>> +++
>>  src/util/virsecret.h |  35 ++
>>  7 files changed, 174 insertions(+), 155 deletions(-)
>>  create mode 100644 src/util/virsecret.c
>>  create mode 100644 src/util/virsecret.h
>>
> 
>> diff --git a/src/util/virsecret.c b/src/util/virsecret.c
>> new file mode 100644
>> index 000..07c052a
>> --- /dev/null
>> +++ b/src/util/virsecret.c
>> @@ -0,0 +1,120 @@
>> +/*
>> + * virsecret.c: secret related utility functions
>> + *
>> + * Copyright (C) 2016 Red Hat, Inc.
>> + *
>> + * This library is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU Lesser General Public
>> + * License as published by the Free Software Foundation; either
>> + * version 2.1 of the License, or (at your option) any later version.
>> + *
>> + * This library is distributed in the hope that it will be useful,
>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> + * Lesser General Public License for more details.
>> + *
>> + * You should have received a copy of the GNU Lesser General Public
>> + * License along with this library.  If not, see
>> + * .
>> + *
>> + */
>> +
>> +#include 
>> +
>> +#include "virsecret.h"
>> +#include "viralloc.h"
>> +#include "virerror.h"
>> +#include "virlog.h"
>> +#include "virobject.h"
>> +#include "viruuid.h"
> 
> vir{error,object,uuid}.h are pulled in by datatypes.h
> 
>> +#include "base64.h"
>> +#include "datatypes.h"
>> +
> 
> datatypes.h contains internal definitions of public structs and should
> not be included in src/util/
> 

Hm. OK, I see.  Not the first abuser though... (virauth, virdnsmasq,
virerror, virnodesuspend, virstats)

Simple enough to remove from virsecret, virdnsmasq, virnodesuspend, and
virstats, but more involved from virauth and virerror.  Then of course
how to create a rule to enforce no further inclusion?

>> +#define VIR_FROM_THIS VIR_FROM_SECRET
>> +
>> +VIR_LOG_INIT("util.secret");
>> +
>> +
>> +/* virSecretGetSecretString:
>> + * @conn: Pointer to the connection driver to make secret driver call
>> + * @scheme: Unique enough string for error message to help determine cause
>> + * @encoded: Whether the returned secret needs to be base64 encoded
>> + * @authdef: Pointer to the disk storage authentication
>> + * @secretUsageType: Type of secret usage for authdef lookup
>> + *
>> + * Lookup the secret for the authdef usage type and return it either as
>> + * raw text or encoded based on the caller's need.
>> + *
>> + * Returns a pointer to memory that needs to be cleared and free'd after
>> + * usage or NULL on error.
>> + */
>> +char *
>> +virSecretGetSecretString(virConnectPtr conn,
>> + const char *scheme,
>> + bool encoded,
>> + virStorageAuthDefPtr authdef,
>> + virSecretUsageType secretUsageType)
>> +{
>> +size_t secret_size;
>> +virSecretPtr sec = NULL;
>> +char *secret = NULL;
>> +char uuidStr[VIR_UUID_STRING_BUFLEN];
>> +
>> +/* look up secret */
>> +switch (authdef->secretType) {
>> +case VIR_STORAGE_SECRET_TYPE_UUID:
>> +sec = virSecretLookupByUUID(conn, authdef->secret.uuid);
>> +virUUIDFormat(authdef->secret.uuid, uuidStr);
>> +break;
>> +case VIR_STORAGE_SECRET_TYPE_USAGE:
>> +sec = virSecretLookupByUsage(conn, secretUsageType,
>> + authdef->secret.usage);
>> +break;
>> +}
>> +
>> +if (!sec) {
>> +if (authdef->secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
>> +virReportError(VIR_ERR_NO_SECRET,
>> +   _("%s no secret matches uuid '%s'"),
>> +   scheme, uuidStr);
>> +} else {
>> +virReportError(VIR_ERR_NO_SECRET,
>> +   _("%s no secret matches usage value '%s'"),
>> +   scheme, authdef->secret.usage);
>> +}
>> +goto cleanup;
>> +}
>> +
>> +secret = (char 

Re: [libvirt] [PATCH for 1.3.3 0/6] Fix a mis-merge

2016-04-04 Thread Cole Robinson
On 04/04/2016 03:36 PM, John Ferlan wrote:
> Details in each patch... 
> 
> Depending on whether I get a review before I close my eyes for the
> night I can push or if reviewed after than and before a release is
> made - I'm sure someone else can grab and push too...
> 
> John Ferlan (6):
>   qemu: Fix mis-merge of qemuBuildSmartcardCommandLine
>   qemu: Fix mis-merge of qemuBuildSerialCommandLine
>   qemu: Fix mis-merge of qemuBuildParallelsCommandLine
>   qemu: Fix mis-merge of qemuBuildChannelsCommandLine
>   qemu: Fix mis-merge of qemuBuildConsoleCommandLine
>   qemu: Fix mis-merge of qemuBuildRedirdevCommandLine
> 
>  src/qemu/qemu_command.c | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 

ACK series. Future todo item to find a way to test the logManager/-add-fd path
which would have caught this

- Cole

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


[libvirt] [PATCH 2/6] qemu: Fix mis-merge of qemuBuildSerialCommandLine

2016-04-04 Thread John Ferlan
Commit id '5ab8640' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8236c9a..774ca37 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8388,12 +8388,12 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
 
 /* Use -chardev with -device if they are available */
 if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) {
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source,
   serial->info.alias,
   qemuCaps)))
 return -1;
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
-- 
2.5.5

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


[libvirt] [PATCH 3/6] qemu: Fix mis-merge of qemuBuildParallelsCommandLine

2016-04-04 Thread John Ferlan
Commit id '0e1e7ade' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 774ca37..d176526 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8436,12 +8436,12 @@ qemuBuildParallelsCommandLine(virLogManagerPtr 
logManager,
 /* Use -chardev with -device if they are available */
 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) &&
 virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source,
   parallel->info.alias,
   qemuCaps)))
 return -1;
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
-- 
2.5.5

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


[libvirt] [PATCH for 1.3.3 0/6] Fix a mis-merge

2016-04-04 Thread John Ferlan
Details in each patch... 

Depending on whether I get a review before I close my eyes for the
night I can push or if reviewed after than and before a release is
made - I'm sure someone else can grab and push too...

John Ferlan (6):
  qemu: Fix mis-merge of qemuBuildSmartcardCommandLine
  qemu: Fix mis-merge of qemuBuildSerialCommandLine
  qemu: Fix mis-merge of qemuBuildParallelsCommandLine
  qemu: Fix mis-merge of qemuBuildChannelsCommandLine
  qemu: Fix mis-merge of qemuBuildConsoleCommandLine
  qemu: Fix mis-merge of qemuBuildRedirdevCommandLine

 src/qemu/qemu_command.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
2.5.5

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


[libvirt] [PATCH 6/6] qemu: Fix mis-merge of qemuBuildRedirdevCommandLine

2016-04-04 Thread John Ferlan
Commit id '59e7ef3c' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 42eeef7..9001d06 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8723,7 +8723,6 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
 virDomainRedirdevDefPtr redirdev = def->redirdevs[i];
 char *devstr;
 
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source.chr,
   redirdev->info.alias,
@@ -8731,6 +8730,7 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,
 return -1;
 }
 
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
-- 
2.5.5

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


[libvirt] [PATCH 1/6] qemu: Fix mis-merge of qemuBuildSmartcardCommandLine

2016-04-04 Thread John Ferlan
Commit id '858bafeb' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2d0ca97..8236c9a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8198,7 +8198,6 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
 return -1;
 }
 
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >data.passthru,
   smartcard->info.alias,
@@ -8206,6 +8205,7 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
 virBufferFreeAndReset();
 return -1;
 }
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
-- 
2.5.5

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


[libvirt] [PATCH 5/6] qemu: Fix mis-merge of qemuBuildConsoleCommandLine

2016-04-04 Thread John Ferlan
Commit id 'e6944a52' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_command.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9754693..42eeef7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8575,12 +8575,12 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
 return -1;
 }
 
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source,
   console->info.alias,
   qemuCaps)))
 return -1;
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
@@ -8595,12 +8595,12 @@ qemuBuildConsoleCommandLine(virLogManagerPtr logManager,
 return -1;
 }
 
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source,
   console->info.alias,
   qemuCaps)))
 return -1;
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
-- 
2.5.5

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


[libvirt] [PATCH 4/6] qemu: Fix mis-merge of qemuBuildChannelsCommandLine

2016-04-04 Thread John Ferlan
Commit id '3cdcc910' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

Signed-off-by: John Ferlan 
---
 src/qemu/qemu_command.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d176526..9754693 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8483,12 +8483,12 @@ qemuBuildChannelsCommandLine(virLogManagerPtr 
logManager,
 return -1;
 }
 
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source,
   channel->info.alias,
   qemuCaps)))
 return -1;
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 
@@ -8528,12 +8528,12 @@ qemuBuildChannelsCommandLine(virLogManagerPtr 
logManager,
  * the newer -chardev interface.  */
 ;
 } else {
-virCommandAddArg(cmd, "-chardev");
 if (!(devstr = qemuBuildChrChardevStr(logManager, cmd, def,
   >source,
   channel->info.alias,
   qemuCaps)))
 return -1;
+virCommandAddArg(cmd, "-chardev");
 virCommandAddArg(cmd, devstr);
 VIR_FREE(devstr);
 }
-- 
2.5.5

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


Re: [libvirt] Entering freeze for libvirt-1.3.3

2016-04-04 Thread John Ferlan


On 03/29/2016 10:59 PM, Daniel Veillard wrote:
>   As suggested yesterday, I tagged RC1 in git and pushed signed tarball
> and rpms to the usual place:
> 
>   ftp://libvirt.org/libvirt/
> 
> 
>   Seems to work for me, but please give it some testing !
> I expect to have an rc2 on Friday, and do the final release on the week-end
> or on Monday if everything loks good,
> 
>   Please try it and report,
> 
>thanks,
> 
> Daniel
> 

Ouch - one more found this afternoon... Seems like a mismerge of 0192447
with the qemu_command split up... Sending patches shortly. It affects
the Smartcard, Serial, Parallels, Channels, Console, and Redirdev
command line building.

John

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


Re: [libvirt] Host device assignment driver name vfio/ kvm

2016-04-04 Thread Moshe Levi


From: sendmail [mailto:justsendmailnothinge...@gmail.com] On Behalf Of Laine 
Stump
Sent: Sunday, April 03, 2016 7:14 PM
To: Libvirt 
Cc: Moshe Levi ; Alex Williamson 

Subject: Re: [libvirt] Host device assignment driver name vfio/ kvm

(please configure your email client to properly quote earlier messages, and 
reply inline rather as a top-post; it makes it easier for others to determine 
the context of replies.)

On 04/03/2016 05:00 AM, Moshe Levi wrote:
Hi,

Ok, so here are the errors I get when using vfio/( kvm is working fine)

This is the Error [1] I am getting on resume when using vfio. And [2] is the ls 
output on the /dev/vfio/
Please note that I am trying to attach pci which is VF
My setup is:
Fedora 21
Libvirt 1.3.0
Qemu 2.5
Kernel  3.17.4-301.fc21.x86_64
OpenStack – master.

Let me know if you need more information.
[1] –
root@r-dcs78:/var/log/libvirt/qemu# cat ./instance-000e.log
2016-03-31 15:31:09.895+: starting up libvirt version: 1.3.0, package: 
1.fc21 (Unknown, 2016-02-25-10:56:09, r-ufm231.mtr.labs.mlnx), qemu version: 
2.5.0 (qemu-2.5.0-11.fc21)
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin 
QEMU_AUDIO_DRV=none /usr/bin/qemu-kvm -name instance-000e -S -machine 
pc-i440fx-2.5,accel=kvm,usb=off -m 2048 -realtime mlock=off -smp 
1,sockets=1,cores=1,threads=1 -uuid a809a3b5-ba75-41e6-889f-ffeebecfe54e 
-smbios 'type=1,manufacturer=OpenStack Foundation,product=OpenStack 
Nova,version=13.0.0,serial=533a28c3-7519-4e6d-8cdb-4b1f72649e71,uuid=a809a3b5-ba75-41e6-889f-ffeebecfe54e,family=Virtual
 Machine' -no-user-config -nodefaults -chardev 
socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-instance-000e/monitor.sock,server,nowait
 -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew 
-global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -boot strict=on 
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive 
file=/opt/stack/data/nova/instances/a809a3b5-ba75-41e6-889f-ffeebecfe54e/disk,if=none,id=drive-virtio-disk0,format=qcow2,cache=none
 -device 
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
 -drive 
file=/opt/stack/data/nova/instances/a809a3b5-ba75-41e6-889f-ffeebecfe54e/disk.config,if=none,id=drive-ide0-1-1,readonly=on,format=raw,cache=none
 -device ide-cd,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 -chardev 
file,id=charserial0,path=/opt/stack/data/nova/instances/a809a3b5-ba75-41e6-889f-ffeebecfe54e/console.log
 -device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1 
-device isa-serial,chardev=charserial1,id=serial1 -vnc 127.0.0.1:0 -k en-us 
-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -device 
vfio-pci,host=04:00.7,id=hostdev0,bus=pci.0,addr=0x4 -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on
char device redirected to /dev/pts/29 (label charserial1)
2016-03-31T15:31:46.775166Z qemu-system-x86_64: terminating on signal 15 from 
pid 6866
2016-03-31 15:32:07.547+: starting up libvirt version: 1.3.0, package: 
1.fc21 (Unknown, 2016-02-25-10:56:09, r-ufm231.mtr.labs.mlnx), qemu version: 
2.5.0 (qemu-2.5.0-11.fc21)
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin 
QEMU_AUDIO_DRV=none /usr/bin/qemu-kvm -name instance-000e -S -machine 
pc-i440fx-2.5,accel=kvm,usb=off -m 2048 -realtime mlock=off -smp 
1,sockets=1,cores=1,threads=1 -uuid a809a3b5-ba75-41e6-889f-ffeebecfe54e 
-smbios 'type=1,manufacturer=OpenStack Foundation,product=OpenStack 
Nova,version=13.0.0,serial=533a28c3-7519-4e6d-8cdb-4b1f72649e71,uuid=a809a3b5-ba75-41e6-889f-ffeebecfe54e,family=Virtual
 Machine' -no-user-config -nodefaults -chardev 
socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-instance-000e/monitor.sock,server,nowait
 -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc,driftfix=slew 
-global kvm-pit.lost_tick_policy=discard -no-hpet -no-shutdown -boot strict=on 
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -drive 
file=/opt/stack/data/nova/instances/a809a3b5-ba75-41e6-889f-ffeebecfe54e/disk,if=none,id=drive-virtio-disk0,format=qcow2,cache=none
 -device 
virtio-blk-pci,scsi=off,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
 -drive 
file=/opt/stack/data/nova/instances/a809a3b5-ba75-41e6-889f-ffeebecfe54e/disk.config,if=none,id=drive-ide0-1-1,readonly=on,format=raw,cache=none
 -device ide-cd,bus=ide.1,unit=1,drive=drive-ide0-1-1,id=ide0-1-1 -chardev 
file,id=charserial0,path=/opt/stack/data/nova/instances/a809a3b5-ba75-41e6-889f-ffeebecfe54e/console.log
 -device isa-serial,chardev=charserial0,id=serial0 -chardev pty,id=charserial1 
-device isa-serial,chardev=charserial1,id=serial1 -vnc 127.0.0.1:0 -k en-us 
-device cirrus-vga,id=video0,bus=pci.0,addr=0x2 -incoming defer -device 
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg timestamp=on
char device redirected to /dev/pts/29 

[libvirt] [PATCH 0/2] host-validate: Be more careful when checking for cgroups

2016-04-04 Thread Andrea Bolognani
Basically, the existing code was built around the assumption that
no cgroup name could appear as part of the name of another cgroup...

Unfortunately, valid cgroup names include 'cpu', 'cpuacct' and 'cpuset'.

This series removes the assumption.

Cheers.


Andrea Bolognani (2):
  host-validate: Be more careful when checking for cgroup support
  host-validate: Be more careful when checking for cgroup mounts

 tools/virt-host-validate-common.c | 67 +++
 1 file changed, 53 insertions(+), 14 deletions(-)

-- 
2.5.5

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


[libvirt] [PATCH 1/2] host-validate: Be more careful when checking for cgroup support

2016-04-04 Thread Andrea Bolognani
Simply checking whether the cgroup name appears somewhere inside
/proc/self/cgroup is enough most of the time, but there are some
corner cases that require a more mindful parsing.

As a bonus, after the rewrite 'line' is no longer leaked.
---
 tools/virt-host-validate-common.c | 49 +--
 1 file changed, 42 insertions(+), 7 deletions(-)

diff --git a/tools/virt-host-validate-common.c 
b/tools/virt-host-validate-common.c
index 8ebf73e..18b9f20 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -265,18 +265,53 @@ static int virHostValidateCGroupSupport(const char 
*hvname,
 goto error;
 
 while ((ret = getline(, , fp)) >= 0 && !matched) {
-char *tmp = strstr(line, cg_name);
-if (!tmp)
+char **cgroups;
+char *start;
+char *end;
+size_t ncgroups;
+size_t i;
+
+/* Each line in this file looks like
+ *
+ *   4:cpu,cpuacct:/machine.slice/machine-qemu\x2dtest.scope/emulator
+ *
+ * Since multiple cgroups can be part of the same line and some cgroup
+ * names can appear as part of other cgroup names (eg. 'cpu' is a
+ * prefix for both 'cpuacct' and 'cpuset'), it's not enough to simply
+ * check whether the cgroup name is present somewhere inside the file
+ */
+
+/* Look for the first colon.
+ * The part we're interested in starts right after it */
+if (!(start = strstr(line, ":"))) {
+VIR_FREE(line);
 continue;
+}
+start++;
 
-tmp += strlen(cg_name);
-if (*tmp != ',' &&
-*tmp != ':')
+/* Look for the second colon.
+ * The part we're interested in ends exactly there */
+if (!(end = strstr(start, ":"))) {
+VIR_FREE(line);
 continue;
+}
+*end = '\0';
 
-matched = true;
+if (!(cgroups = virStringSplitCount(start, ",", 0, ))) {
+VIR_FREE(line);
+continue;
+}
+
+/* Look for the matching cgroup */
+for (i = 0; i < ncgroups; i++) {
+if (STREQ(cgroups[i], cg_name))
+matched = true;
+}
+
+virStringFreeListCount(cgroups, ncgroups);
+VIR_FREE(line);
 }
-VIR_FREE(line);
+
 VIR_FORCE_FCLOSE(fp);
 if (!matched)
 goto error;
-- 
2.5.5

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


[libvirt] [PATCH 2/2] host-validate: Be more careful when checking for cgroup mounts

2016-04-04 Thread Andrea Bolognani
The existing code was built with the assumption that no cgroup
name could appear as part of another cgroup name. Rewrite it to
handle such cases correctly.
---
 tools/virt-host-validate-common.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/tools/virt-host-validate-common.c 
b/tools/virt-host-validate-common.c
index 18b9f20..ced29e3 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -340,16 +340,20 @@ static int virHostValidateCGroupMount(const char *hvname,
 goto error;
 
 while (getmntent_r(fp, , mntbuf, sizeof(mntbuf)) && !matched) {
-char *tmp = strstr(ent.mnt_opts, cg_name);
-if (!tmp)
-continue;
+char **opts;
+size_t nopts;
+size_t i;
 
-tmp += strlen(cg_name);
-if (*tmp != ',' &&
-*tmp != '\0')
+if (!(opts = virStringSplitCount(ent.mnt_opts, ",", 0, )))
 continue;
 
-matched = true;
+/* Look for a mount option matching the cgroup name */
+for (i = 0; i < nopts; i++) {
+if (STREQ(opts[i], cg_name))
+matched = true;
+}
+
+virStringFreeListCount(opts, nopts);
 }
 endmntent(fp);
 if (!matched)
-- 
2.5.5

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


Re: [libvirt] [PATCH 0/2] Adjust order of calls during qemuDomainRemoveHostDevice

2016-04-04 Thread Laine Stump

On 03/28/2016 05:17 PM, Laine Stump wrote:

On 03/28/2016 07:52 AM, John Ferlan wrote:

While reviewing patch:

http://www.redhat.com/archives/libvir-list/2016-March/msg00194.html

I noted that the order of operations during the code path was slightly
different and could cause issues if the reattachment code was called
first. It would seem that resetting the hostdev label and cgroup prior
to reattaching the device to the host would be a better corollary to
the attachment code path which detaches the devices from the host, then
sets the cgroup, then sets the hostdev label.


I've noticed similar issues at other places in the code (teardown not 
being the exact mirror image of setup) but didn't touch it because I 
didn't want to accidentally introduce regressions.


I wanted to test these patches to verify that the sequence change 
doesn't uncover some odd regression, but now I find that hotplug of 
type='hostdev' network devices is completely broken (even before 
applying your patches), so I'll have to figure out the cause of that 
first :-/



I was finally able to try this out (extensively, because I've been 
testing the fixes for the other problems I found on top of your 
patches). Everything checks out and the logic makes sense, so ACK.


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


Re: [libvirt] [PATCH] util: Create virsecret module adding virSecretGetSecretString

2016-04-04 Thread Ján Tomko
On Thu, Mar 31, 2016 at 11:05:07AM -0400, John Ferlan wrote:
> Commit id 'fb2bd208' essentially copied the qemuGetSecretString
> creating an libxlGetSecretString.  Rather than have multiple copies
> of the same code, create virsecret.{c,h} files and place the common
> function in there.
> 
> Usage is from both qemu_command.c and libxl_conf.c
> 
> Signed-off-by: John Ferlan 
> ---
> Not for 1.3.3, but I may as well get it "out there" now...
> 
>  po/POTFILES.in   |   1 +
>  src/Makefile.am  |   1 +
>  src/libvirt_private.syms |   3 ++
>  src/libxl/libxl_conf.c   |  82 +++-
>  src/qemu/qemu_command.c  |  87 --
>  src/util/virsecret.c | 120 
> +++
>  src/util/virsecret.h |  35 ++
>  7 files changed, 174 insertions(+), 155 deletions(-)
>  create mode 100644 src/util/virsecret.c
>  create mode 100644 src/util/virsecret.h
> 

> diff --git a/src/util/virsecret.c b/src/util/virsecret.c
> new file mode 100644
> index 000..07c052a
> --- /dev/null
> +++ b/src/util/virsecret.c
> @@ -0,0 +1,120 @@
> +/*
> + * virsecret.c: secret related utility functions
> + *
> + * Copyright (C) 2016 Red Hat, Inc.
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with this library.  If not, see
> + * .
> + *
> + */
> +
> +#include 
> +
> +#include "virsecret.h"
> +#include "viralloc.h"
> +#include "virerror.h"
> +#include "virlog.h"
> +#include "virobject.h"
> +#include "viruuid.h"

vir{error,object,uuid}.h are pulled in by datatypes.h

> +#include "base64.h"
> +#include "datatypes.h"
> +

datatypes.h contains internal definitions of public structs and should
not be included in src/util/

> +#define VIR_FROM_THIS VIR_FROM_SECRET
> +
> +VIR_LOG_INIT("util.secret");
> +
> +
> +/* virSecretGetSecretString:
> + * @conn: Pointer to the connection driver to make secret driver call
> + * @scheme: Unique enough string for error message to help determine cause
> + * @encoded: Whether the returned secret needs to be base64 encoded
> + * @authdef: Pointer to the disk storage authentication
> + * @secretUsageType: Type of secret usage for authdef lookup
> + *
> + * Lookup the secret for the authdef usage type and return it either as
> + * raw text or encoded based on the caller's need.
> + *
> + * Returns a pointer to memory that needs to be cleared and free'd after
> + * usage or NULL on error.
> + */
> +char *
> +virSecretGetSecretString(virConnectPtr conn,
> + const char *scheme,
> + bool encoded,
> + virStorageAuthDefPtr authdef,
> + virSecretUsageType secretUsageType)
> +{
> +size_t secret_size;
> +virSecretPtr sec = NULL;
> +char *secret = NULL;
> +char uuidStr[VIR_UUID_STRING_BUFLEN];
> +
> +/* look up secret */
> +switch (authdef->secretType) {
> +case VIR_STORAGE_SECRET_TYPE_UUID:
> +sec = virSecretLookupByUUID(conn, authdef->secret.uuid);
> +virUUIDFormat(authdef->secret.uuid, uuidStr);
> +break;
> +case VIR_STORAGE_SECRET_TYPE_USAGE:
> +sec = virSecretLookupByUsage(conn, secretUsageType,
> + authdef->secret.usage);
> +break;
> +}
> +
> +if (!sec) {
> +if (authdef->secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
> +virReportError(VIR_ERR_NO_SECRET,
> +   _("%s no secret matches uuid '%s'"),
> +   scheme, uuidStr);
> +} else {
> +virReportError(VIR_ERR_NO_SECRET,
> +   _("%s no secret matches usage value '%s'"),
> +   scheme, authdef->secret.usage);
> +}
> +goto cleanup;
> +}
> +
> +secret = (char *)conn->secretDriver->secretGetValue(sec, _size, 0,
> +
> VIR_SECRET_GET_VALUE_INTERNAL_CALL);

The secret driver should be calling functions from src/util, not the
other way around.

Could this function be moved into src/secret?

> +if (!secret) {
> +if (authdef->secretType == VIR_STORAGE_SECRET_TYPE_UUID) {
> +virReportError(VIR_ERR_INTERNAL_ERROR,
> +   _("could not get value of the secret for "
> +  

[libvirt] [PATCH 10/18] domain_conf: cleanup virDomainGraphicsGetListen

2016-04-04 Thread Pavel Hrdina
Removes the check for graphics type, it's not a public API and developer
know what he's doing and this check makes no sense.  It also removes
the ability to allocate a new array if there is none.  This was used by
the virDomainGraphicsListenAdd* functions and isn't used anymore.

This is now a simple getter with simple check for listens array presence
and whether the index in out of bounds.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c   | 29 -
 src/conf/domain_conf.h   |  2 ++
 src/libvirt_private.syms |  1 +
 3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index abe5d5a..1f6e9f4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23741,26 +23741,13 @@ 
virDomainNetGetActualTrustGuestRxFilters(virDomainNetDefPtr iface)
  * type, or NULL if this is an unsuitable type, or the index is out of
  * bounds. If force0 is TRUE, i == 0, and there is no listen array,
  * allocate one with a single item. */
-static virDomainGraphicsListenDefPtr
-virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i, bool force0)
+virDomainGraphicsListenDefPtr
+virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i)
 {
-if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
-def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
-
-if (!def->listens && (i == 0) && force0) {
-if (VIR_ALLOC(def->listens) >= 0)
-def->nListens = 1;
-}
-
-if (!def->listens || (def->nListens <= i))
-return NULL;
-
-return >listens[i];
-}
+if (!def->listens || (def->nListens <= i))
+return NULL;
 
-/* it's a type that has no listens array */
-return NULL;
+return >listens[i];
 }
 
 
@@ -23781,7 +23768,7 @@ int
 virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
 {
 virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, false);
+= virDomainGraphicsGetListen(def, i);
 
 if (!listenInfo)
 return VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE;
@@ -23793,7 +23780,7 @@ const char *
 virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i)
 {
 virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, false);
+= virDomainGraphicsGetListen(def, i);
 
 /* even a network can have a listen address */
 if (!listenInfo ||
@@ -23832,7 +23819,7 @@ const char *
 virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t i)
 {
 virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, false);
+= virDomainGraphicsGetListen(def, i);
 
 if (!listenInfo ||
 (listenInfo->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK))
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 96e2def..672d8dc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2811,6 +2811,8 @@ virDomainHostdevRemove(virDomainDefPtr def, size_t i);
 int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match,
  virDomainHostdevDefPtr *found);
 
+virDomainGraphicsListenDefPtr
+virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
 int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
 ATTRIBUTE_NONNULL(1);
 const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3c4abd7..b8a8ddc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -300,6 +300,7 @@ virDomainGetFilesystemForTarget;
 virDomainGraphicsAuthConnectedTypeFromString;
 virDomainGraphicsAuthConnectedTypeToString;
 virDomainGraphicsDefFree;
+virDomainGraphicsGetListen;
 virDomainGraphicsListenAddAddress;
 virDomainGraphicsListenAddNetwork;
 virDomainGraphicsListenGetAddress;
-- 
2.7.4

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


[libvirt] [PATCH 15/18] qemu_process: generate vnc unix socket in qemuProcessPrepareDomain

2016-04-04 Thread Pavel Hrdina
Move generation of vnc unix socket to qemuProcessPrepareDomain which is
the correct place to do those things.  Now we can also test it.

Signed-off-by: Pavel Hrdina 
---
 src/qemu/qemu_command.c| 20 -
 src/qemu/qemu_command.h|  3 +-
 src/qemu/qemu_process.c| 20 +++--
 ...qemuxml2argv-graphics-vnc-auto-unix-socket.args | 22 ++
 .../qemuxml2argv-graphics-vnc-auto-unix-socket.xml | 34 ++
 tests/qemuxml2argvtest.c   |  4 +++
 6 files changed, 84 insertions(+), 19 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9335f63..67d3336 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7219,8 +7219,7 @@ static int
 qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
 virCommandPtr cmd,
 virQEMUCapsPtr qemuCaps,
-virDomainGraphicsDefPtr graphics,
-const char *domainLibDir)
+virDomainGraphicsDefPtr graphics)
 {
 virBuffer opt = VIR_BUFFER_INITIALIZER;
 virDomainGraphicsListenDefPtr listen = NULL;
@@ -7235,14 +7234,8 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr 
cfg,
 goto error;
 }
 
-if (graphics->data.vnc.socket || cfg->vncAutoUnixSocket) {
-if (!graphics->data.vnc.socket &&
-virAsprintf(>data.vnc.socket,
-"%s/vnc.sock", domainLibDir) == -1)
-goto error;
-
+if (graphics->data.vnc.socket) {
 virBufferAsprintf(, "unix:%s", graphics->data.vnc.socket);
-
 } else {
 if (!graphics->data.vnc.autoport &&
 (graphics->data.vnc.port < 5900 ||
@@ -7613,8 +7606,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
  virCommandPtr cmd,
  virDomainDefPtr def,
  virQEMUCapsPtr qemuCaps,
- virDomainGraphicsDefPtr graphics,
- const char *domainLibDir)
+ virDomainGraphicsDefPtr graphics)
 {
 switch ((virDomainGraphicsType) graphics->type) {
 case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
@@ -7646,8 +7638,7 @@ qemuBuildGraphicsCommandLine(virQEMUDriverConfigPtr cfg,
 break;
 
 case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
-return qemuBuildGraphicsVNCCommandLine(cfg, cmd, qemuCaps,
-   graphics, domainLibDir);
+return qemuBuildGraphicsVNCCommandLine(cfg, cmd, qemuCaps, graphics);
 
 case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
 return qemuBuildGraphicsSPICECommandLine(cfg, cmd, qemuCaps, graphics);
@@ -9199,7 +9190,6 @@ qemuBuildCommandLine(virConnectPtr conn,
  virBitmapPtr nodeset,
  size_t *nnicindexes,
  int **nicindexes,
- const char *domainLibDir,
  const char *domainChannelTargetDir)
 {
 size_t i;
@@ -9360,7 +9350,7 @@ qemuBuildCommandLine(virConnectPtr conn,
 
 for (i = 0; i < def->ngraphics; ++i) {
 if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps,
- def->graphics[i], domainLibDir) < 0)
+ def->graphics[i]) < 0)
 goto error;
 }
 
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 7c13d45..677fc05 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -74,10 +74,9 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
virBitmapPtr nodeset,
size_t *nnicindexes,
int **nicindexes,
-   const char *domainLibDir,
const char *domainChannelTargetDir)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(11)
-ATTRIBUTE_NONNULL(17) ATTRIBUTE_NONNULL(18);
+ATTRIBUTE_NONNULL(17);
 
 /* Generate '-device' string for chardev device */
 int
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 6a4fb8c..cfd8a90 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4957,6 +4957,7 @@ qemuProcessPrepareDomain(virConnectPtr conn,
 size_t i;
 char *nodeset = NULL;
 qemuDomainObjPrivatePtr priv = vm->privateData;
+virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 virCapsPtr caps;
 
 if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -4996,6 +4997,22 @@ qemuProcessPrepareDomain(virConnectPtr conn,
 if 

[libvirt] [PATCH 14/18] domain_conf: call ...ListensParseXML only for appropriate graphics

2016-04-04 Thread Pavel Hrdina
Instead of calling the virDomainGraphicsListensParseXML function for all
graphics types and ignore the wrong ones move the call only to graphics
types where we supports listen elements.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index befbd4f..dc3bc22 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10696,13 +10696,6 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 
 ctxt->node = node;
 
-if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
-def->type != VIR_DOMAIN_GRAPHICS_TYPE_RDP &&
-def->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
-ret = 0;
-goto error;
-}
-
 /* parse the  subelements for graphics types that support it */
 nListens = virXPathNodeSet("./listen", ctxt, );
 if (nListens < 0)
@@ -10761,6 +10754,7 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 static int
 virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
 xmlNodePtr node,
+xmlXPathContextPtr ctxt,
 unsigned int flags)
 {
 char *port = virXMLPropString(node, "port");
@@ -10769,6 +10763,9 @@ virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr 
def,
 char *autoport = virXMLPropString(node, "autoport");
 int ret = -1;
 
+if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
+goto error;
+
 if (port) {
 if (virStrToLong_i(port, NULL, 10, >data.vnc.port) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -10869,6 +10866,7 @@ virDomainGraphicsDefParseXMLSdl(virDomainGraphicsDefPtr 
def,
 static int
 virDomainGraphicsDefParseXMLRdp(virDomainGraphicsDefPtr def,
 xmlNodePtr node,
+xmlXPathContextPtr ctxt,
 unsigned int flags)
 {
 char *port = virXMLPropString(node, "port");
@@ -10877,6 +10875,9 @@ virDomainGraphicsDefParseXMLRdp(virDomainGraphicsDefPtr 
def,
 char *multiUser = virXMLPropString(node, "multiUser");
 int ret = -1;
 
+if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
+goto error;
+
 if (port) {
 if (virStrToLong_i(port, NULL, 10, >data.rdp.port) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -10947,6 +10948,7 @@ 
virDomainGraphicsDefParseXMLDesktop(virDomainGraphicsDefPtr def,
 static int
 virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
   xmlNodePtr node,
+  xmlXPathContextPtr ctxt,
   unsigned int flags)
 {
 xmlNodePtr cur;
@@ -10957,6 +10959,9 @@ 
virDomainGraphicsDefParseXMLSpice(virDomainGraphicsDefPtr def,
 int defaultModeVal;
 int ret = -1;
 
+if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
+goto error;
+
 if (port) {
 if (virStrToLong_i(port, NULL, 10, >data.spice.port) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -11269,12 +11274,9 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 goto error;
 }
 
-if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
-goto error;
-
 switch (def->type) {
 case VIR_DOMAIN_GRAPHICS_TYPE_VNC:
-if (virDomainGraphicsDefParseXMLVnc(def, node, flags) < 0)
+if (virDomainGraphicsDefParseXMLVnc(def, node, ctxt, flags) < 0)
 goto error;
 break;
 case VIR_DOMAIN_GRAPHICS_TYPE_SDL:
@@ -11282,7 +11284,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 goto error;
 break;
 case VIR_DOMAIN_GRAPHICS_TYPE_RDP:
-if (virDomainGraphicsDefParseXMLRdp(def, node, flags) < 0)
+if (virDomainGraphicsDefParseXMLRdp(def, node, ctxt, flags) < 0)
 goto error;
 break;
 case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP:
@@ -11290,7 +11292,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 goto error;
 break;
 case VIR_DOMAIN_GRAPHICS_TYPE_SPICE:
-if (virDomainGraphicsDefParseXMLSpice(def, node, flags) < 0)
+if (virDomainGraphicsDefParseXMLSpice(def, node, ctxt, flags) < 0)
 goto error;
 break;
 }
-- 
2.7.4

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


[libvirt] [PATCH 13/18] domain_conf: remove unused virDomainGraphicsListenGet*

2016-04-04 Thread Pavel Hrdina
Those are the last two places that uses the getter functions.  Use a
direct access instead and remove those getters.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c   | 58 ++--
 src/conf/domain_conf.h   |  8 ---
 src/libvirt_private.syms |  3 ---
 3 files changed, 2 insertions(+), 67 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a5da4b3..befbd4f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21347,7 +21347,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
  VIR_DOMAIN_DEF_FORMAT_MIGRATABLE))
 continue;
 
-if ((listenAddr = virDomainGraphicsListenGetAddress(def, i)))
+if ((listenAddr = def->listens[i].address))
 break;
 }
 
@@ -21460,8 +21460,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
 }
 
 for (i = 0; i < def->nListens; i++) {
-if (virDomainGraphicsListenGetType(def, i)
-== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
+if (def->listens[i].type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE)
 continue;
 if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
 def->listens[i].fromConfig)
@@ -23756,46 +23755,6 @@ virDomainGraphicsGetListen(virDomainGraphicsDefPtr 
def, size_t i)
 }
 
 
-/* Access functions for the fields in a virDomainGraphicsDef's
- * "listens" array.
- *
- * NB: For simple backward compatibility with existing code, any of
- * the "Set" functions will auto-create listens[0] to store the new
- * setting, when necessary. Auto-creation beyond the first item is not
- * supported.
- *
- * Return values: All "Get" functions return the requested item, or
- * 0/NULL. (in the case of returned const char *, the caller should
- * make a copy if they want to keep it around). All "Set" functions
- * return 0 on success, -1 on failure. */
-
-int
-virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
-{
-virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i);
-
-if (!listenInfo)
-return VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE;
-return listenInfo->type;
-}
-
-
-const char *
-virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i)
-{
-virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i);
-
-/* even a network can have a listen address */
-if (!listenInfo ||
-!(listenInfo->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
-  listenInfo->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK))
-return NULL;
-return listenInfo->address;
-}
-
-
 int
 virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
   int pos,
@@ -23820,19 +23779,6 @@ 
virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
 }
 
 
-const char *
-virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t i)
-{
-virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i);
-
-if (!listenInfo ||
-(listenInfo->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK))
-return NULL;
-return listenInfo->network;
-}
-
-
 int
 virDomainGraphicsListenAddNetwork(virDomainGraphicsDefPtr def,
   int pos,
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 672d8dc..a96a130 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2813,18 +2813,10 @@ int virDomainHostdevFind(virDomainDefPtr def, 
virDomainHostdevDefPtr match,
 
 virDomainGraphicsListenDefPtr
 virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
-int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
-ATTRIBUTE_NONNULL(1);
-const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
-  size_t i)
-ATTRIBUTE_NONNULL(1);
 int virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
   int pos,
   const char *address)
 ATTRIBUTE_NONNULL(1);
-const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
-  size_t i)
-ATTRIBUTE_NONNULL(1);
 int virDomainGraphicsListenAddNetwork(virDomainGraphicsDefPtr def,
   int pos,
   const char *network)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b8a8ddc..f864f78 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -303,9 +303,6 @@ virDomainGraphicsDefFree;
 virDomainGraphicsGetListen;
 virDomainGraphicsListenAddAddress;
 virDomainGraphicsListenAddNetwork;
-virDomainGraphicsListenGetAddress;
-virDomainGraphicsListenGetNetwork;
-virDomainGraphicsListenGetType;
 virDomainGraphicsSpiceChannelModeTypeFromString;
 

[libvirt] [PATCH 11/18] use virDomainGraphicsGetListen instead of the other getters

2016-04-04 Thread Pavel Hrdina
There is no point the use two different getters on the same listen
structure few lines apart.

Signed-off-by: Pavel Hrdina 
---
 src/libxl/libxl_conf.c | 15 +++
 src/qemu/qemu_command.c| 98 --
 src/qemu/qemu_migration.c  |  9 +++--
 src/vbox/vbox_common.c | 11 +++---
 src/vmx/vmx.c  |  7 ++--
 src/vz/vz_sdk.c| 11 +++---
 src/xenconfig/xen_common.c | 16 
 src/xenconfig/xen_sxpr.c   | 16 
 src/xenconfig/xen_xl.c |  8 ++--
 9 files changed, 99 insertions(+), 92 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 82ba417..e1cf914 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1494,7 +1494,7 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports,
  libxl_device_vfb *x_vfb)
 {
 unsigned short port;
-const char *listenAddr;
+virDomainGraphicsListenDefPtr listen = NULL;
 
 libxl_device_vfb_init(x_vfb);
 
@@ -1521,11 +1521,11 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports,
 }
 x_vfb->vnc.display = l_vfb->data.vnc.port - LIBXL_VNC_PORT_MIN;
 
-listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0);
-if (listenAddr) {
+if ((listen = virDomainGraphicsGetListen(l_vfb, 0)) &&
+listen->address) {
 /* libxl_device_vfb_init() does VIR_STRDUP("127.0.0.1") */
 VIR_FREE(x_vfb->vnc.listen);
-if (VIR_STRDUP(x_vfb->vnc.listen, listenAddr) < 0)
+if (VIR_STRDUP(x_vfb->vnc.listen, listen->address) < 0)
 return -1;
 }
 if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd) < 0)
@@ -1609,7 +1609,7 @@ libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports,
 for (i = 0; i < def->ngraphics; i++) {
 virDomainGraphicsDefPtr l_vfb = def->graphics[i];
 unsigned short port;
-const char *listenAddr;
+virDomainGraphicsListenDefPtr listen = NULL;
 
 if (l_vfb->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE)
 continue;
@@ -1623,8 +1623,9 @@ libxlMakeBuildInfoVfb(virPortAllocatorPtr graphicsports,
 }
 b_info->u.hvm.spice.port = l_vfb->data.spice.port;
 
-listenAddr = virDomainGraphicsListenGetAddress(l_vfb, 0);
-if (VIR_STRDUP(b_info->u.hvm.spice.host, listenAddr) < 0)
+if ((listen = virDomainGraphicsGetListen(l_vfb, 0)) &&
+listen->address &&
+VIR_STRDUP(b_info->u.hvm.spice.host, listen->address) < 0)
 return -1;
 
 if (VIR_STRDUP(b_info->u.hvm.keymap, l_vfb->data.spice.keymap) < 0)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 140bf98..9335f63 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7223,7 +7223,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr 
cfg,
 const char *domainLibDir)
 {
 virBuffer opt = VIR_BUFFER_INITIALIZER;
-const char *listenNetwork;
+virDomainGraphicsListenDefPtr listen = NULL;
 const char *listenAddr = NULL;
 char *netAddr = NULL;
 bool escapeAddr;
@@ -7252,31 +7252,34 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr 
cfg,
 goto error;
 }
 
-switch (virDomainGraphicsListenGetType(graphics, 0)) {
-case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
-listenAddr = virDomainGraphicsListenGetAddress(graphics, 0);
-break;
+if ((listen = virDomainGraphicsGetListen(graphics, 0))) {
 
-case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
-listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0);
-if (!listenNetwork)
+switch (listen->type) {
+case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
+listenAddr = listen->address;
 break;
-ret = networkGetNetworkAddress(listenNetwork, );
-if (ret <= -2) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   "%s", _("network-based listen not possible, "
-   "network driver not present"));
-goto error;
-}
-if (ret < 0)
-goto error;
 
-listenAddr = netAddr;
-/* store the address we found in the  element so it
- * will show up in status. */
-if (VIR_STRDUP(graphics->listens[0].address, listenAddr) < 0)
-goto error;
-break;
+case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
+if (!listen->network)
+break;
+
+ret = networkGetNetworkAddress(listen->network, );
+if (ret <= -2) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   "%s", _("network-based listen not 

[libvirt] [PATCH 17/18] domain_conf: introduce virDomainGraphicsListenClear

2016-04-04 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c   | 16 
 src/conf/domain_conf.h   |  1 +
 src/libvirt_private.syms |  1 +
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dc3bc22..801dcf8 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1228,10 +1228,20 @@ 
virDomainGraphicsListenDefClear(virDomainGraphicsListenDefPtr def)
 }
 
 
-void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
+void
+virDomainGraphicsListenClear(virDomainGraphicsDefPtr def)
 {
 size_t i;
 
+for (i = 0; i < def->nListens; i++)
+virDomainGraphicsListenDefClear(>listens[i]);
+VIR_FREE(def->listens);
+def->nListens = 0;
+}
+
+
+void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
+{
 if (!def)
 return;
 
@@ -1263,9 +1273,7 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
 break;
 }
 
-for (i = 0; i < def->nListens; i++)
-virDomainGraphicsListenDefClear(>listens[i]);
-VIR_FREE(def->listens);
+virDomainGraphicsListenClear(def);
 
 VIR_FREE(def);
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a96a130..c5aa58d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2813,6 +2813,7 @@ int virDomainHostdevFind(virDomainDefPtr def, 
virDomainHostdevDefPtr match,
 
 virDomainGraphicsListenDefPtr
 virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i);
+void virDomainGraphicsListenClear(virDomainGraphicsDefPtr def);
 int virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
   int pos,
   const char *address)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f864f78..85f1e0a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -303,6 +303,7 @@ virDomainGraphicsDefFree;
 virDomainGraphicsGetListen;
 virDomainGraphicsListenAddAddress;
 virDomainGraphicsListenAddNetwork;
+virDomainGraphicsListenClear;
 virDomainGraphicsSpiceChannelModeTypeFromString;
 virDomainGraphicsSpiceChannelModeTypeToString;
 virDomainGraphicsSpiceChannelNameTypeFromString;
-- 
2.7.4

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


[libvirt] [PATCH 16/18] qemu_process: move listen code out of qemuProcessSetupGraphics

2016-04-04 Thread Pavel Hrdina
Move adding the config listen type=address if there is none in
qemuProcessPrepareDomain and move check for multiple listens to
qemuProcessStartValidate.

Signed-off-by: Pavel Hrdina 
---
 src/qemu/qemu_process.c | 48 
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index cfd8a90..8eb2b52 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4282,26 +4282,6 @@ qemuProcessSetupGraphics(virQEMUDriverPtr driver,
 if (qemuProcessSPICEAllocatePorts(driver, cfg, graphics, true) < 0)
 goto cleanup;
 }
-
-if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
-if (graphics->nListens == 0) {
-const char *listenAddr
-= graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
-cfg->vncListen : cfg->spiceListen;
-
-if (virDomainGraphicsListenAddAddress(graphics, 0,
-  listenAddr) < 0)
-goto cleanup;
-
-graphics->listens[0].fromConfig = true;
-} else if (graphics->nListens > 1) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("QEMU does not support multiple listen "
- "addresses for one graphics device."));
-goto cleanup;
-}
-}
 }
 
 ret = 0;
@@ -4531,6 +4511,19 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
 }
 }
 
+for (i = 0; i < vm->def->ngraphics; i++) {
+virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
+if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+if (graphics->nListens > 1) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("QEMU does not support multiple listen "
+ "addresses for one graphics device."));
+return -1;
+}
+}
+}
+
 return 0;
 }
 
@@ -5011,6 +5004,21 @@ qemuProcessPrepareDomain(virConnectPtr conn,
 continue;
 }
 }
+
+if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
+graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+if (graphics->nListens == 0) {
+const char *listenAddr
+= graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ?
+cfg->vncListen : cfg->spiceListen;
+
+if (virDomainGraphicsListenAddAddress(graphics, 0,
+  listenAddr) < 0)
+goto cleanup;
+
+graphics->listens[0].fromConfig = true;
+}
+}
 }
 
 /* "volume" type disk's source must be translated before
-- 
2.7.4

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


[libvirt] [PATCH 03/18] domain_conf: introduce virDomainGraphicsListensParseXML

2016-04-04 Thread Pavel Hrdina
Move code, that parses graphics listens, to it's own function.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 79 ++
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d4c78fd..a0ef3d9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10675,38 +10675,19 @@ 
virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
 }
 
 
-/* Parse the XML definition for a graphics device */
-static virDomainGraphicsDefPtr
-virDomainGraphicsDefParseXML(xmlNodePtr node,
- xmlXPathContextPtr ctxt,
- unsigned int flags)
+static int
+virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ unsigned int flags)
 {
-virDomainGraphicsDefPtr def;
-char *type = NULL;
 int nListens;
 xmlNodePtr *listenNodes = NULL;
 char *listenAddr = NULL;
 xmlNodePtr save = ctxt->node;
-
-if (VIR_ALLOC(def) < 0)
-return NULL;
+int ret = -1;
 
 ctxt->node = node;
-
-type = virXMLPropString(node, "type");
-
-if (!type) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   "%s", _("missing graphics device type"));
-goto error;
-}
-
-if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("unknown graphics device type '%s'"), type);
-goto error;
-}
-
 if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
 def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
 def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
@@ -10723,10 +10704,10 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 goto error;
 
 for (i = 0; i < nListens; i++) {
-int ret = virDomainGraphicsListenDefParseXML(>listens[i],
- listenNodes[i],
- flags);
-if (ret < 0)
+int rv = virDomainGraphicsListenDefParseXML(>listens[i],
+listenNodes[i],
+flags);
+if (rv < 0)
 goto error;
 def->nListens++;
 }
@@ -10780,6 +10761,43 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 }
 }
 
+ret = 0;
+ error:
+VIR_FREE(listenNodes);
+VIR_FREE(listenAddr);
+ctxt->node = save;
+return ret;
+}
+
+
+/* Parse the XML definition for a graphics device */
+static virDomainGraphicsDefPtr
+virDomainGraphicsDefParseXML(xmlNodePtr node,
+ xmlXPathContextPtr ctxt,
+ unsigned int flags)
+{
+virDomainGraphicsDefPtr def;
+char *type = NULL;
+
+if (VIR_ALLOC(def) < 0)
+return NULL;
+
+type = virXMLPropString(node, "type");
+if (!type) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   "%s", _("missing graphics device type"));
+goto error;
+}
+
+if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _("unknown graphics device type '%s'"), type);
+goto error;
+}
+
+if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
+goto error;
+
 if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
 char *port = virXMLPropString(node, "port");
 char *websocket = virXMLPropString(node, "websocket");
@@ -11230,10 +11248,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
 
  cleanup:
 VIR_FREE(type);
-VIR_FREE(listenNodes);
-VIR_FREE(listenAddr);
 
-ctxt->node = save;
 return def;
 
  error:
-- 
2.7.4

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


[libvirt] [PATCH 12/18] domain_conf: cleanup virDomainGraphicsListenDefParseXML

2016-04-04 Thread Pavel Hrdina
Use VIR_APPEND_ELEMENT_COPY_INPLACE to add listen elements into listens
array while parsing.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 1f6e9f4..a5da4b3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10606,7 +10606,7 @@ virDomainGraphicsAuthDefParseXML(xmlNodePtr node,
 }
 
 static int
-virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
+virDomainGraphicsListenDefParseXML(virDomainGraphicsDefPtr def,
xmlNodePtr node,
unsigned int flags)
 {
@@ -10616,6 +10616,9 @@ 
virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
 char *network  = virXMLPropString(node, "network");
 char *fromConfig = virXMLPropString(node, "fromConfig");
 int tmp;
+virDomainGraphicsListenDef listen;
+
+memset(, 0, sizeof(listen));
 
 if (!type) {
 virReportError(VIR_ERR_XML_ERROR, "%s",
@@ -10623,7 +10626,7 @@ 
virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
 goto error;
 }
 
-if ((def->type = virDomainGraphicsListenTypeFromString(type)) < 0) {
+if ((listen.type = virDomainGraphicsListenTypeFromString(type)) < 0) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown graphics listen type '%s'"), type);
 goto error;
@@ -10633,22 +10636,22 @@ 
virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
  * type='network' and we're looking at live XML (i.e. *not*
  * inactive). It is otherwise ignored. */
 if (address && address[0] &&
-(def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
- (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
+(listen.type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS ||
+ (listen.type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK &&
   !(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE {
-def->address = address;
+listen.address = address;
 address = NULL;
 }
 
 if (network && network[0]) {
-if (def->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) {
+if (listen.type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK) {
 /* network='xxx' never makes sense with anything except
  * type='network' */
 virReportError(VIR_ERR_XML_ERROR, "%s",
_("network attribute not allowed when listen type 
is not network"));
 goto error;
 }
-def->network = network;
+listen.network = network;
 network = NULL;
 }
 
@@ -10660,13 +10663,16 @@ 
virDomainGraphicsListenDefParseXML(virDomainGraphicsListenDefPtr def,
fromConfig);
 goto error;
 }
-def->fromConfig = tmp != 0;
+listen.fromConfig = tmp != 0;
 }
 
+if (VIR_APPEND_ELEMENT_COPY_INPLACE(def->listens, def->nListens, listen) < 
0)
+goto error;
+
 ret = 0;
  error:
 if (ret < 0)
-virDomainGraphicsListenDefClear(def);
+virDomainGraphicsListenDefClear();
 VIR_FREE(type);
 VIR_FREE(address);
 VIR_FREE(network);
@@ -10709,7 +10715,7 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 goto error;
 
 for (i = 0; i < nListens; i++) {
-if (virDomainGraphicsListenDefParseXML(>listens[i],
+if (virDomainGraphicsListenDefParseXML(def,
listenNodes[i],
flags) < 0)
 goto error;
@@ -10718,7 +10724,6 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 def->listens[i].type == 
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS)
 address = >listens[i];
 
-def->nListens++;
 }
 VIR_FREE(listenNodes);
 }
-- 
2.7.4

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


[libvirt] [PATCH 09/18] domain_conf: remove unused virDomainGraphicsListenSetType

2016-04-04 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c   | 16 
 src/conf/domain_conf.h   |  2 --
 src/libvirt_private.syms |  1 -
 3 files changed, 19 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a1a73ac..abe5d5a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23789,22 +23789,6 @@ virDomainGraphicsListenGetType(virDomainGraphicsDefPtr 
def, size_t i)
 }
 
 
-/* NB: This function assumes type has not previously been set. It
- * *will not* free any existing address or network based on a change
- * in value of type. */
-int
-virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int val)
-{
-virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, true);
-
-if (!listenInfo)
-return -1;
-listenInfo->type = val;
-return 0;
-}
-
-
 const char *
 virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i)
 {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c1b26dd..96e2def 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2813,8 +2813,6 @@ int virDomainHostdevFind(virDomainDefPtr def, 
virDomainHostdevDefPtr match,
 
 int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i)
 ATTRIBUTE_NONNULL(1);
-int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int 
val)
-ATTRIBUTE_NONNULL(1);
 const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
   size_t i)
 ATTRIBUTE_NONNULL(1);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 53eba5c..3c4abd7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -305,7 +305,6 @@ virDomainGraphicsListenAddNetwork;
 virDomainGraphicsListenGetAddress;
 virDomainGraphicsListenGetNetwork;
 virDomainGraphicsListenGetType;
-virDomainGraphicsListenSetType;
 virDomainGraphicsSpiceChannelModeTypeFromString;
 virDomainGraphicsSpiceChannelModeTypeToString;
 virDomainGraphicsSpiceChannelNameTypeFromString;
-- 
2.7.4

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


[libvirt] [PATCH 00/18] cleanup of graphics code

2016-04-04 Thread Pavel Hrdina
Pavel Hrdina (18):
  tests: remove unwanted VIR_FREE of spice and vnc default listen
  docs: rewrite graphics XML documentation
  domain_conf: introduce virDomainGraphicsListensParseXML
  domain_conf: cleanup virDomainGraphicsListensParseXML
  domain_conf: split graphics xml parser into multiple functions
  domain_conf: cleanup error paths for graphics parser
  domain_conf: introduce virDomainGraphicsListenAddAddress
  domain_conf: introduce virDomainGraphicsListenAddNetwork
  domain_conf: remove unused virDomainGraphicsListenSetType
  domain_conf: cleanup virDomainGraphicsGetListen
  use virDomainGraphicsGetListen instead of the other getters
  domain_conf: cleanup virDomainGraphicsListenDefParseXML
  domain_conf: remove unused virDomainGraphicsListenGet*
  domain_conf: call ...ListensParseXML only for appropriate graphics
  qemu_process: generate vnc unix socket in qemuProcessPrepareDomain
  qemu_process: move listen code out of qemuProcessSetupGraphics
  domain_conf: introduce virDomainGraphicsListenClear
  qemu_domain: remove all listens if vncAutoUnixSocket is enabled

 docs/formatdomain.html.in  |  351 +++---
 src/conf/domain_conf.c | 1163 ++--
 src/conf/domain_conf.h |   24 +-
 src/libvirt_private.syms   |   10 +-
 src/libxl/libxl_conf.c |   15 +-
 src/qemu/qemu_command.c|  120 +-
 src/qemu/qemu_command.h|3 +-
 src/qemu/qemu_domain.c |   10 +
 src/qemu/qemu_migration.c  |9 +-
 src/qemu/qemu_parse_command.c  |4 +-
 src/qemu/qemu_process.c|   69 +-
 src/vbox/vbox_common.c |   14 +-
 src/vmx/vmx.c  |9 +-
 src/vz/vz_sdk.c|   11 +-
 src/xenconfig/xen_common.c |   28 +-
 src/xenconfig/xen_sxpr.c   |   20 +-
 src/xenconfig/xen_xl.c |   12 +-
 .../qemuxml2argv-graphics-spice-timeout.args   |2 +-
 ...-graphics-vnc-auto-unix-socket-with-listen.args |   22 +
 ...v-graphics-vnc-auto-unix-socket-with-listen.xml |   36 +
 ...qemuxml2argv-graphics-vnc-auto-unix-socket.args |   22 +
 .../qemuxml2argv-graphics-vnc-auto-unix-socket.xml |   34 +
 tests/qemuxml2argvtest.c   |8 +-
 23 files changed, 1051 insertions(+), 945 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket.xml

-- 
2.7.4

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


[libvirt] [PATCH 04/18] domain_conf: cleanup virDomainGraphicsListensParseXML

2016-04-04 Thread Pavel Hrdina
Refactor the listen parser to use only one loop.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 117 +
 1 file changed, 50 insertions(+), 67 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a0ef3d9..9d48d07 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10681,86 +10681,69 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
  xmlXPathContextPtr ctxt,
  unsigned int flags)
 {
-int nListens;
 xmlNodePtr *listenNodes = NULL;
-char *listenAddr = NULL;
 xmlNodePtr save = ctxt->node;
+virDomainGraphicsListenDefPtr address = NULL;
+char *listenAddr = NULL;
+int nListens;
 int ret = -1;
 
 ctxt->node = node;
-if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC ||
-def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP ||
-def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
 
-/* parse the  subelements for graphics types that support it */
-nListens = virXPathNodeSet("./listen", ctxt, );
-if (nListens < 0)
-goto error;
+if (def->type != VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
+def->type != VIR_DOMAIN_GRAPHICS_TYPE_RDP &&
+def->type != VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
+ret = 0;
+goto error;
+}
 
-if (nListens > 0) {
-size_t i;
+/* parse the  subelements for graphics types that support it */
+nListens = virXPathNodeSet("./listen", ctxt, );
+if (nListens < 0)
+goto error;
+
+if (nListens > 0) {
+size_t i;
 
-if (VIR_ALLOC_N(def->listens, nListens) < 0)
+if (VIR_ALLOC_N(def->listens, nListens) < 0)
+goto error;
+
+for (i = 0; i < nListens; i++) {
+if (virDomainGraphicsListenDefParseXML(>listens[i],
+   listenNodes[i],
+   flags) < 0)
 goto error;
 
-for (i = 0; i < nListens; i++) {
-int rv = virDomainGraphicsListenDefParseXML(>listens[i],
-listenNodes[i],
-flags);
-if (rv < 0)
-goto error;
-def->nListens++;
-}
-VIR_FREE(listenNodes);
-}
-
-/* listen attribute of  is also supported by these,
- * but must match the 'address' attribute of the first listen
- * that is type='address' (if present) */
-listenAddr = virXMLPropString(node, "listen");
-if (listenAddr && !listenAddr[0])
-VIR_FREE(listenAddr);
-
-if (listenAddr) {
-if (def->nListens == 0) {
-/* There were no  elements, so we can just
- * directly set listenAddr as listens[0]->address */
-if (virDomainGraphicsListenSetAddress(def, 0, listenAddr,
-  -1, true) < 0)
-goto error;
-} else {
-/* There is at least 1 listen element, so we look for
- * the first listen of type='address', and make sure
- * its address matches the listen attribute from
- * graphics. */
-bool matched = false;
-const char *found = NULL;
-size_t i;
-
-for (i = 0; i < nListens; i++) {
-if (virDomainGraphicsListenGetType(def, i)
-== VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) {
-found = virDomainGraphicsListenGetAddress(def, i);
-if (STREQ_NULLABLE(found, listenAddr))
-matched = true;
-break;
-}
-}
-if (found && !matched) {
-virReportError(VIR_ERR_XML_ERROR,
-   _("graphics listen attribute %s must match 
address "
- "attribute of first listen element (found 
%s)"),
-   listenAddr, found);
-goto error;
-} else if (!found) {
-/* quietly ignore listen address if none of the listens
- * are of type address */
-VIR_FREE(listenAddr);
-}
-}
+if (!address &&
+def->listens[i].type == 
VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS)
+address = >listens[i];
+
+def->nListens++;
 }
+VIR_FREE(listenNodes);
 }
 
+/* listen attribute of  is also supported by these,
+ * but must match the 'address' attribute of the first listen
+ * 

[libvirt] [PATCH 07/18] domain_conf: introduce virDomainGraphicsListenAddAddress

2016-04-04 Thread Pavel Hrdina
This effectively removes virDomainGraphicsListenSetAddress which was
used only to change the address of listen structure and possible change
the listen type.  The new function will auto-expand the listens array
and add a new listen.

The old function was used on pre-allocated array of listens and in most
cases it only "add" a new listen.  The two remaining uses can access the
listen structure directly.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c| 34 +++---
 src/conf/domain_conf.h|  6 +++---
 src/libvirt_private.syms  |  2 +-
 src/qemu/qemu_command.c   |  6 ++
 src/qemu/qemu_parse_command.c |  4 +++-
 src/qemu/qemu_process.c   | 15 +++
 src/vbox/vbox_common.c|  3 +--
 src/vmx/vmx.c |  2 +-
 src/xenconfig/xen_common.c| 12 +---
 src/xenconfig/xen_sxpr.c  |  4 ++--
 src/xenconfig/xen_xl.c|  4 +---
 11 files changed, 41 insertions(+), 51 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 42050b0..c79a432 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10741,7 +10741,7 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 /* There were no  elements, so we can just
  * directly set listenAddr as listens[0]->address */
 if (listenAddr && def->nListens == 0 &&
-virDomainGraphicsListenSetAddress(def, 0, listenAddr, -1, true) < 0)
+virDomainGraphicsListenAddAddress(def, 0, listenAddr) < 0)
 goto error;
 
 ret = 0;
@@ -23820,31 +23820,27 @@ 
virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i)
 }
 
 
-/* Make a copy of up to len characters of address, and store it in
- * listens[i].address. If setType is true, set the listen's type
- * to 'address', otherwise leave type alone. */
 int
-virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
-  size_t i, const char *address,
-  int len, bool setType)
+virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
+  int pos,
+  const char *address)
 {
-virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, true);
+virDomainGraphicsListenDef listen;
 
-if (!listenInfo)
-return -1;
+memset(, 0, sizeof(listen));
 
-if (setType)
-listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
+listen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS;
 
-if (!address) {
-VIR_FREE(listenInfo->address);
-return 0;
-}
+if (VIR_STRDUP(listen.address, address) < 0)
+goto error;
+
+if (VIR_INSERT_ELEMENT_COPY(def->listens, pos, def->nListens, listen) < 0)
+goto error;
 
-if (VIR_STRNDUP(listenInfo->address, address, len) < 0)
-return -1;
 return 0;
+ error:
+VIR_FREE(listen.address);
+return -1;
 }
 
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fe9faeb..ed3d818 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2818,9 +2818,9 @@ int 
virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int va
 const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def,
   size_t i)
 ATTRIBUTE_NONNULL(1);
-int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def,
-  size_t i, const char *address,
-  int len, bool setType)
+int virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
+  int pos,
+  const char *address)
 ATTRIBUTE_NONNULL(1);
 const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
   size_t i)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 684f06c..cc1c969 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -300,10 +300,10 @@ virDomainGetFilesystemForTarget;
 virDomainGraphicsAuthConnectedTypeFromString;
 virDomainGraphicsAuthConnectedTypeToString;
 virDomainGraphicsDefFree;
+virDomainGraphicsListenAddAddress;
 virDomainGraphicsListenGetAddress;
 virDomainGraphicsListenGetNetwork;
 virDomainGraphicsListenGetType;
-virDomainGraphicsListenSetAddress;
 virDomainGraphicsListenSetNetwork;
 virDomainGraphicsListenSetType;
 virDomainGraphicsSpiceChannelModeTypeFromString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2d0ca97..140bf98 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7274,8 +7274,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr 
cfg,
 listenAddr = netAddr;
 /* store the address we found in the  element so it
  * will show up in status. */
-

[libvirt] [PATCH 02/18] docs: rewrite graphics XML documentation

2016-04-04 Thread Pavel Hrdina
This cleanups the documentation, reformat some of the paragraphs to use
 instead of  and rewrites the listen part to be more extendable.

Signed-off-by: Pavel Hrdina 
---
 docs/formatdomain.html.in | 351 ++
 1 file changed, 169 insertions(+), 182 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 957b839..c43c737 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -4933,108 +4933,113 @@ qemu-kvm -net nic,model=? /dev/null
 
 
   graphics
-  The graphics element has a mandatory type
-attribute which takes the value "sdl", "vnc", "spice", "rdp" or
-"desktop":
+  
+
+  The graphics element has a mandatory type
+  attribute which takes the value sdl, vnc,
+  spice, rdp or desktop:
+
 
   "sdl"
   
-This displays a window on the host desktop, it can take 3
-optional arguments: a display attribute for
-the display to use, an xauth attribute for
-the authentication identifier, and an
-optional fullscreen attribute accepting
-values 'yes' or 'no'.
+
+  This displays a window on the host desktop, it can take 3 
optional
+  arguments: a display attribute for the display to 
use,
+  an xauth attribute for the authentication 
identifier,
+  and an optional fullscreen attribute accepting 
values
+  yes or no.
+
   
   "vnc"
   
-Starts a VNC server. The port attribute
-specifies the TCP port number (with -1 as legacy syntax
-indicating that it should be
-auto-allocated). The autoport attribute is
-the new preferred syntax for indicating autoallocation of
-the TCP port to use.  The listen attribute is
-an IP address for the server to listen
-on. The passwd attribute provides a VNC
-password in clear text. The keymap attribute
-specifies the keymap to use. It is possible to set a limit
-on the validity of the password be giving an
-timestamp passwdValidTo='2010-04-09T15:51:00'
-assumed to be in UTC. The connected attribute
-allows control of connected client during password changes.
-VNC accepts keep value only.
-since 0.9.3
-NB, this may not be supported by all hypervisors.
-The optional sharePolicy attribute specifies vnc 
server
-display sharing policy. "allow-exclusive" allows clients to ask
-for exclusive access by dropping other connections. Connecting
-multiple clients in parallel requires all clients asking for a
-shared session (vncviewer: -Shared switch). This is the default
-value. "force-shared" disables exclusive client access, every
-connection has to specify -Shared switch for vncviewer. "ignore"
-welcomes every connection unconditionally
-since 1.0.6.  
-Rather than using listen/port, QEMU supports a
-socket attribute for listening on a unix
-domain socket path.Since 0.8.8
-
-For VNC WebSocket functionality, websocket
-attribute may be used to specify port to listen on (with
--1 meaning auto-allocation and autoport
-having no effect due to security reasons).
-Since 1.0.6
+
+  Starts a VNC server. The port attribute specifies
+  the TCP port number (with -1 as legacy syntax indicating that it
+  should be auto-allocated). The autoport attribute is
+  the new preferred syntax for indicating auto-allocation of the 
TCP
+  port to use. The listen attribute is an IP address
+  for the server to listen on. The passwd attribute
+  provides a VNC password in clear text. The keymap
+  attribute specifies the keymap to use. It is possible to set
+  a limit on the validity of the password by giving an timestamp
+  passwdValidTo='2010-04-09T15:51:00' assumed to be
+  in UTC. The connected attribute allows control of
+  connected client during password changes. VNC accepts
+  keep value only since 
0.9.3.
+  NB, this may not be supported by all hypervisors.
+
+
+  The optional sharePolicy attribute specifies vnc
+  server display sharing policy. allow-exclusive 
allows
+  clients to ask for exclusive access by dropping other 
connections.
+  Connecting multiple clients in parallel requires all clients 
asking
+  for a shared session (vncviewer: -Shared switch). This 

[libvirt] [PATCH 05/18] domain_conf: split graphics xml parser into multiple functions

2016-04-04 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 835 +++--
 1 file changed, 453 insertions(+), 382 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9d48d07..fd9316f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10753,480 +10753,551 @@ 
virDomainGraphicsListensParseXML(virDomainGraphicsDefPtr def,
 }
 
 
-/* Parse the XML definition for a graphics device */
-static virDomainGraphicsDefPtr
-virDomainGraphicsDefParseXML(xmlNodePtr node,
- xmlXPathContextPtr ctxt,
- unsigned int flags)
+static int
+virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
+xmlNodePtr node,
+unsigned int flags)
 {
-virDomainGraphicsDefPtr def;
-char *type = NULL;
-
-if (VIR_ALLOC(def) < 0)
-return NULL;
-
-type = virXMLPropString(node, "type");
-if (!type) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   "%s", _("missing graphics device type"));
-goto error;
-}
-
-if ((def->type = virDomainGraphicsTypeFromString(type)) < 0) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("unknown graphics device type '%s'"), type);
-goto error;
-}
-
-if (virDomainGraphicsListensParseXML(def, node, ctxt, flags) < 0)
-goto error;
-
-if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
-char *port = virXMLPropString(node, "port");
-char *websocket = virXMLPropString(node, "websocket");
-char *sharePolicy = virXMLPropString(node, "sharePolicy");
-char *autoport;
+char *port = virXMLPropString(node, "port");
+char *websocket = virXMLPropString(node, "websocket");
+char *sharePolicy = virXMLPropString(node, "sharePolicy");
+char *autoport;
+int ret = -1;
 
-if (port) {
-if (virStrToLong_i(port, NULL, 10, >data.vnc.port) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot parse vnc port %s"), port);
-VIR_FREE(port);
-goto error;
-}
+if (port) {
+if (virStrToLong_i(port, NULL, 10, >data.vnc.port) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse vnc port %s"), port);
 VIR_FREE(port);
-/* Legacy compat syntax, used -1 for auto-port */
-if (def->data.vnc.port == -1) {
-if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
-def->data.vnc.port = 0;
-def->data.vnc.autoport = true;
-}
-} else {
-def->data.vnc.port = 0;
+goto error;
+}
+VIR_FREE(port);
+/* Legacy compat syntax, used -1 for auto-port */
+if (def->data.vnc.port == -1) {
+if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
+def->data.vnc.port = 0;
 def->data.vnc.autoport = true;
 }
+} else {
+def->data.vnc.port = 0;
+def->data.vnc.autoport = true;
+}
 
-if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
-if (STREQ(autoport, "yes")) {
-if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
-def->data.vnc.port = 0;
-def->data.vnc.autoport = true;
-}
-VIR_FREE(autoport);
+if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
+if (STREQ(autoport, "yes")) {
+if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
+def->data.vnc.port = 0;
+def->data.vnc.autoport = true;
 }
+VIR_FREE(autoport);
+}
 
-if (websocket) {
-if (virStrToLong_i(websocket,
-   NULL, 10,
-   >data.vnc.websocket) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot parse vnc WebSocket port %s"), 
websocket);
-VIR_FREE(websocket);
-goto error;
-}
+if (websocket) {
+if (virStrToLong_i(websocket,
+   NULL, 10,
+   >data.vnc.websocket) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse vnc WebSocket port %s"), websocket);
 VIR_FREE(websocket);
+goto error;
 }
+VIR_FREE(websocket);
+}
 
-if (sharePolicy) {
-int policy =
-   virDomainGraphicsVNCSharePolicyTypeFromString(sharePolicy);
+if (sharePolicy) {
+int policy =
+   virDomainGraphicsVNCSharePolicyTypeFromString(sharePolicy);
 
-if (policy < 0) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   

[libvirt] [PATCH 08/18] domain_conf: introduce virDomainGraphicsListenAddNetwork

2016-04-04 Thread Pavel Hrdina
The same as for virDomainGraphicsListenAddAddress from previous commit
applies to this one too.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c   | 30 +++---
 src/conf/domain_conf.h   |  5 +++--
 src/libvirt_private.syms |  2 +-
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c79a432..a1a73ac 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23857,30 +23857,30 @@ 
virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t i)
 }
 
 
-/* Make a copy of up to len characters of address, and store it in
- * listens[i].network */
 int
-virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
-  size_t i, const char *network, int len)
+virDomainGraphicsListenAddNetwork(virDomainGraphicsDefPtr def,
+  int pos,
+  const char *network)
 {
-virDomainGraphicsListenDefPtr listenInfo
-= virDomainGraphicsGetListen(def, i, true);
+virDomainGraphicsListenDef listen;
 
-if (!listenInfo)
-return -1;
+memset(, 0, sizeof(listen));
 
-listenInfo->type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK;
+listen.type = VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK;
 
-if (!network) {
-VIR_FREE(listenInfo->network);
-return 0;
-}
+if (VIR_STRDUP(listen.network, network) < 0)
+goto error;
+
+if (VIR_INSERT_ELEMENT_COPY(def->listens, pos, def->nListens, listen) < 0)
+goto error;
 
-if (VIR_STRNDUP(listenInfo->network, network, len) < 0)
-return -1;
 return 0;
+ error:
+VIR_FREE(listen.network);
+return -1;
 }
 
+
 /**
  * virDomainNetFind:
  * @def: domain's def
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ed3d818..c1b26dd 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2825,8 +2825,9 @@ int 
virDomainGraphicsListenAddAddress(virDomainGraphicsDefPtr def,
 const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def,
   size_t i)
 ATTRIBUTE_NONNULL(1);
-int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def,
-  size_t i, const char *network, int len)
+int virDomainGraphicsListenAddNetwork(virDomainGraphicsDefPtr def,
+  int pos,
+  const char *network)
 ATTRIBUTE_NONNULL(1);
 
 int virDomainNetGetActualType(virDomainNetDefPtr iface);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index cc1c969..53eba5c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -301,10 +301,10 @@ virDomainGraphicsAuthConnectedTypeFromString;
 virDomainGraphicsAuthConnectedTypeToString;
 virDomainGraphicsDefFree;
 virDomainGraphicsListenAddAddress;
+virDomainGraphicsListenAddNetwork;
 virDomainGraphicsListenGetAddress;
 virDomainGraphicsListenGetNetwork;
 virDomainGraphicsListenGetType;
-virDomainGraphicsListenSetNetwork;
 virDomainGraphicsListenSetType;
 virDomainGraphicsSpiceChannelModeTypeFromString;
 virDomainGraphicsSpiceChannelModeTypeToString;
-- 
2.7.4

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


[libvirt] [PATCH 01/18] tests: remove unwanted VIR_FREE of spice and vnc default listen

2016-04-04 Thread Pavel Hrdina
After the test and qemu_process refactor now we can benefit from default
listen address for spice and vnc in tests.

Signed-off-by: Pavel Hrdina 
---
 tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args | 2 +-
 tests/qemuxml2argvtest.c| 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
index 8a29a7e..0950c1b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args
@@ -29,7 +29,7 @@ media=cdrom,id=drive-ide0-1-0 \
 -net tap,fd=3,vlan=0,name=hostnet0 \
 -serial pty \
 -device usb-tablet,id=input0 \
--spice port=5900 \
+-spice port=5900,addr=127.0.0.1 \
 -vga std \
 -device AC97,id=sound0,bus=pci.0,addr=0x3 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e9b8d64..f8d0f56 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -489,9 +489,6 @@ mymain(void)
 
 driver.privileged = true;
 
-VIR_FREE(driver.config->spiceListen);
-VIR_FREE(driver.config->vncListen);
-
 VIR_FREE(driver.config->vncTLSx509certdir);
 if (VIR_STRDUP_QUIET(driver.config->vncTLSx509certdir, 
"/etc/pki/libvirt-vnc") < 0)
 return EXIT_FAILURE;
-- 
2.7.4

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


[libvirt] [PATCH 06/18] domain_conf: cleanup error paths for graphics parser

2016-04-04 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 100 ++---
 1 file changed, 45 insertions(+), 55 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fd9316f..42050b0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10761,17 +10761,15 @@ 
virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
 char *port = virXMLPropString(node, "port");
 char *websocket = virXMLPropString(node, "websocket");
 char *sharePolicy = virXMLPropString(node, "sharePolicy");
-char *autoport;
+char *autoport = virXMLPropString(node, "autoport");
 int ret = -1;
 
 if (port) {
 if (virStrToLong_i(port, NULL, 10, >data.vnc.port) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse vnc port %s"), port);
-VIR_FREE(port);
 goto error;
 }
-VIR_FREE(port);
 /* Legacy compat syntax, used -1 for auto-port */
 if (def->data.vnc.port == -1) {
 if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
@@ -10783,13 +10781,12 @@ 
virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
 def->data.vnc.autoport = true;
 }
 
-if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
+if (autoport) {
 if (STREQ(autoport, "yes")) {
 if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
 def->data.vnc.port = 0;
 def->data.vnc.autoport = true;
 }
-VIR_FREE(autoport);
 }
 
 if (websocket) {
@@ -10798,10 +10795,8 @@ 
virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
>data.vnc.websocket) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse vnc WebSocket port %s"), websocket);
-VIR_FREE(websocket);
 goto error;
 }
-VIR_FREE(websocket);
 }
 
 if (sharePolicy) {
@@ -10810,13 +10805,12 @@ 
virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
 
 if (policy < 0) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _("unknown vnc display sharing policy '%s'"), 
sharePolicy);
-VIR_FREE(sharePolicy);
+   _("unknown vnc display sharing policy '%s'"),
+   sharePolicy);
 goto error;
 } else {
 def->data.vnc.sharePolicy = policy;
 }
-VIR_FREE(sharePolicy);
 }
 
 def->data.vnc.socket = virXMLPropString(node, "socket");
@@ -10828,6 +10822,10 @@ 
virDomainGraphicsDefParseXMLVnc(virDomainGraphicsDefPtr def,
 
 ret = 0;
  error:
+VIR_FREE(port);
+VIR_FREE(autoport);
+VIR_FREE(websocket);
+VIR_FREE(sharePolicy);
 return ret;
 }
 
@@ -10837,6 +10835,7 @@ virDomainGraphicsDefParseXMLSdl(virDomainGraphicsDefPtr 
def,
 xmlNodePtr node)
 {
 char *fullscreen = virXMLPropString(node, "fullscreen");
+int ret = -1;
 
 if (fullscreen != NULL) {
 if (STREQ(fullscreen, "yes")) {
@@ -10846,17 +10845,19 @@ 
virDomainGraphicsDefParseXMLSdl(virDomainGraphicsDefPtr def,
 } else {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("unknown fullscreen value '%s'"), fullscreen);
-VIR_FREE(fullscreen);
-return -1;
+goto error;
 }
-VIR_FREE(fullscreen);
 } else {
 def->data.sdl.fullscreen = false;
 }
+
 def->data.sdl.xauth = virXMLPropString(node, "xauth");
 def->data.sdl.display = virXMLPropString(node, "display");
 
-return 0;
+ret = 0;
+ error:
+VIR_FREE(fullscreen);
+return ret;
 }
 
 
@@ -10866,52 +10867,44 @@ 
virDomainGraphicsDefParseXMLRdp(virDomainGraphicsDefPtr def,
 unsigned int flags)
 {
 char *port = virXMLPropString(node, "port");
-char *autoport;
-char *replaceUser;
-char *multiUser;
+char *autoport = virXMLPropString(node, "autoport");
+char *replaceUser = virXMLPropString(node, "replaceUser");
+char *multiUser = virXMLPropString(node, "multiUser");
 int ret = -1;
 
 if (port) {
 if (virStrToLong_i(port, NULL, 10, >data.rdp.port) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot parse rdp port %s"), port);
-VIR_FREE(port);
 goto error;
 }
 /* Legacy compat syntax, used -1 for auto-port */
 if (def->data.rdp.port == -1)
 def->data.rdp.autoport = true;
 
-VIR_FREE(port);
 } else {
 def->data.rdp.port = 0;
 def->data.rdp.autoport = true;
 }
 
-if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
-if (STREQ(autoport, "yes"))
-def->data.rdp.autoport = true;
-
-VIR_FREE(autoport);
-  

[libvirt] [PATCH 18/18] qemu_domain: remove all listens if vncAutoUnixSocket is enabled

2016-04-04 Thread Pavel Hrdina
If in qemu.conf vncAutoUnixSocket is enabled remove all other listens
parsed from XML config.

Signed-off-by: Pavel Hrdina 
---
 src/qemu/qemu_domain.c | 10 ++
 ...-graphics-vnc-auto-unix-socket-with-listen.args | 22 +
 ...v-graphics-vnc-auto-unix-socket-with-listen.xml | 36 ++
 tests/qemuxml2argvtest.c   |  1 +
 4 files changed, 69 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.xml

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f38b0f3..65ab0f5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1418,6 +1418,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,
 virQEMUDriverPtr driver = opaque;
 virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 virQEMUCapsPtr qemuCaps = NULL;
+size_t i;
 int ret = -1;
 
 if (def->os.bootloader || def->os.bootloaderArgs) {
@@ -1446,6 +1447,15 @@ qemuDomainDefPostParse(virDomainDefPtr def,
 !(def->emulator = virDomainDefGetDefaultEmulator(def, caps)))
 return ret;
 
+for (i = 0; i < def->ngraphics; i++) {
+virDomainGraphicsDefPtr graphics = def->graphics[i];
+
+if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+if (cfg->vncAutoUnixSocket)
+virDomainGraphicsListenClear(graphics);
+}
+}
+
 if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
 def->emulator)))
 goto cleanup;
diff --git 
a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.args
 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.args
new file mode 100644
index 000..cfa63b1
--- /dev/null
+++ 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 214 \
+-smp 1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
+-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
+-vnc unix:/tmp/lib/domain--1-QEMUGuest1/vnc.sock \
+-vga cirrus
diff --git 
a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.xml
 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.xml
new file mode 100644
index 000..af8442e
--- /dev/null
+++ 
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc-auto-unix-socket-with-listen.xml
@@ -0,0 +1,36 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu
+
+  
+  
+  
+  
+
+
+
+
+
+
+
+  
+
+
+  
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 7afe5c3..475cb47 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -905,6 +905,7 @@ mymain(void)
 
 driver.config->vncAutoUnixSocket = true;
 DO_TEST("graphics-vnc-auto-unix-socket", QEMU_CAPS_VNC);
+DO_TEST("graphics-vnc-auto-unix-socket-with-listen", QEMU_CAPS_VNC);
 driver.config->vncAutoUnixSocket = false;
 
 DO_TEST("graphics-sdl", QEMU_CAPS_SDL);
-- 
2.7.4

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


Re: [libvirt] Availability of libvirt-1.3.3-rc2

2016-04-04 Thread Martin Kletzander

On Mon, Apr 04, 2016 at 07:38:27AM -0400, Laine Stump wrote:

On 04/01/2016 02:04 PM, Laine Stump wrote:


There is a different regression that I also found which I've just
posted patches for:

https://www.redhat.com/archives/libvir-list/2016-April/msg00067.html

Because the fix involves adding in a new function that may or may not
be compiled in depending on platform and options, I would appreciate
if people on odd systems would try applying the patches and doing a
build (since there won't be another release candidate). (of course it
shouldn't be too bad, as it's only called from qemu, so it shouldn't
cause headaches for bhve, for example, but I've been burned by this in
the past so I'm extra cautious).

I should be around as late as Monday AM (US EST) to push, but if it's
not ACKed by then, I'll be on a plane for the rest of Monday - if that
happens I would appreciate if the reviewer pushed it for me.



Michal ACKed this and I just pushed it. So this one isn't holding up
release any more.


My two fixes are in as well, so I guess from my POV we've got a "go" on
the release =)

Thanks Michal and Laine for helping take care of these issues and Daniel
for the patience!


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

Re: [libvirt] [PATCH for 1.3.3 0/5] Fix parsing our own XMLs

2016-04-04 Thread Martin Kletzander

On Mon, Apr 04, 2016 at 08:52:22AM +0200, Michal Privoznik wrote:

On 03.04.2016 21:27, Martin Kletzander wrote:

Laine found out that he can't do 'virsh nodedev-detach pci_dev'
because of some strange error message.  That was caused by my commit,
but also by all the previous ones that skipped adding tests and
parsing of new functions.  In order for this to work in 1.3.3, we need
either a) only the first patch or b) all of them.  I specifically
created the first one so that it has enough in itself to fix the
problem and we don't need to push more and more patches into the
release.  We can push the rest after release.  If someone wants to
have all in for 1.3.3, well, I hope I added enough tests for that ;)


Martin Kletzander (5):
  nodedev: Fix parsing of generated XMLs
  Change virPCIDeviceAddress to virDevicePCIAddress
  Move capability formatting together
  schemas: Update nodedev schema to match reality
  conf: Parse more of our nodedev XML

 docs/schemas/nodedev.rng   |  29 +++--
 src/conf/device_conf.h |  11 +-
 src/conf/node_device_conf.c| 121 ++---
 src/conf/node_device_conf.h|   6 +-
 src/libvirt_private.syms   |  10 +-
 src/network/bridge_driver.c|   4 +-
 src/node_device/node_device_linux_sysfs.c  |   6 +-
 src/util/virhostdev.c  |  12 +-
 src/util/virnetdev.c   |   4 +-
 src/util/virnetdev.h   |   2 +-
 src/util/virpci.c  |  80 +++---
 src/util/virpci.h  |  29 ++---
 .../pci__00_1c_0_header_type.xml   |   2 +-
 tests/nodedevschemadata/pci__02_10_7_sriov.xml |  23 
 .../pci__02_10_7_sriov_pf_vfs_all.xml  |  29 +
 ...i__02_10_7_sriov_pf_vfs_all_header_type.xml |  30 +
 .../pci__02_10_7_sriov_vfs.xml |  26 +
 .../pci__02_10_7_sriov_zero_vfs_max_count.xml  |  21 
 tests/nodedevxml2xmltest.c |   5 +
 19 files changed, 333 insertions(+), 117 deletions(-)
 create mode 100644 tests/nodedevschemadata/pci__02_10_7_sriov.xml
 create mode 100644 
tests/nodedevschemadata/pci__02_10_7_sriov_pf_vfs_all.xml
 create mode 100644 
tests/nodedevschemadata/pci__02_10_7_sriov_pf_vfs_all_header_type.xml
 create mode 100644 tests/nodedevschemadata/pci__02_10_7_sriov_vfs.xml
 create mode 100644 
tests/nodedevschemadata/pci__02_10_7_sriov_zero_vfs_max_count.xml



I like this. I really do. And if we were not in the freeze, I would ACK
this straight away. But since we are in the freeze, we should push only
(small) bug fixes. And I think the minimum needed here is 1/5, right?
Therefore, I'd suggest pushing that one and saving the rest for after
the release. Is that okay with you?



Yes, that's exactly what I wrote in the cover letter.  So I'm pushing
the first one now and we can talk about the naming and shed colours
after the release ;)

Thanks


Michal



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

Re: [libvirt] Availability of libvirt-1.3.3-rc2

2016-04-04 Thread Laine Stump

On 04/01/2016 02:04 PM, Laine Stump wrote:


There is a different regression that I also found which I've just 
posted patches for:


https://www.redhat.com/archives/libvir-list/2016-April/msg00067.html

Because the fix involves adding in a new function that may or may not 
be compiled in depending on platform and options, I would appreciate 
if people on odd systems would try applying the patches and doing a 
build (since there won't be another release candidate). (of course it 
shouldn't be too bad, as it's only called from qemu, so it shouldn't 
cause headaches for bhve, for example, but I've been burned by this in 
the past so I'm extra cautious).


I should be around as late as Monday AM (US EST) to push, but if it's 
not ACKed by then, I'll be on a plane for the rest of Monday - if that 
happens I would appreciate if the reviewer pushed it for me.




Michal ACKed this and I just pushed it. So this one isn't holding up 
release any more.


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


Re: [libvirt] [PATCH 1/5] nodedev: Fix parsing of generated XMLs

2016-04-04 Thread Laine Stump

On 04/03/2016 03:27 PM, Martin Kletzander wrote:

Commit d77ffb6876 added not only reporting of the PCI header type, but
also parsing of that information.  However, because there was no parsing
done for the other sub-PCI capabilities, if there was any other
capability then a valid header type name (like phys_function or
virt_functions) the parsing would fail.  This prevented passing node
device XMLs that we generated into our own functions when dealing with,
e.g. with SRIOV cards.

Instead of reworking the whole parsing, just fix this one occurence and
remove a test for it for the time being.  Future patches will deal with
the rest.

Signed-off-by: Martin Kletzander 
---
  src/conf/node_device_conf.c | 12 
  tests/nodedevxml2xmltest.c  |  2 --
  2 files changed, 14 deletions(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index f74b34de5cd2..a76f785eddc0 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1336,18 +1336,6 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt,
_("invalid NUMA node ID supplied for 
'%s'")) < 0)
  goto out;

-if ((tmp = virXPathString("string(./capability[1]/@type)", ctxt))) {
-int hdrType = virPCIHeaderTypeFromString(tmp);
-
-if (hdrType <= 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Unknown PCI header type '%s'"), tmp);
-goto out;
-}
-
-data->pci_dev.hdrType = hdrType;
-}
-


Yes, this makes nodedev-detach/nodedev-reattach work properly again.

ACK and safe for freeze.

Thanks for taking care of this!


  if ((pciExpress = virXPathNode("./pci-express[1]", ctxt))) {
  if (VIR_ALLOC(pci_express) < 0)
  goto out;
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c
index 246cec710178..96041f50b9cd 100644
--- a/tests/nodedevxml2xmltest.c
+++ b/tests/nodedevxml2xmltest.c
@@ -91,8 +91,6 @@ mymain(void)
  DO_TEST("usb_device_1d6b_1__00_1d_0");
  DO_TEST("pci_8086_4238_pcie_wireless");
  DO_TEST("pci_8086_0c0c_snd_hda_intel");
-DO_TEST("pci__00_02_0_header_type");
-DO_TEST("pci__00_1c_0_header_type");
  DO_TEST("scsi_target0_0_0");

  return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;


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


Re: [libvirt] [PATCH 0/3] fix regression wrt

2016-04-04 Thread Laine Stump

On 04/04/2016 05:27 AM, Michal Privoznik wrote:

On 01.04.2016 19:54, Laine Stump wrote:

The full description of the problem fixed by these patches is in patch
3/3. Basically, a recent patch changed the ordering of things during
startup such that hostdev interfaces are given an alias named "netN"
rather than the expected "hostdevN". That caused a problem when
subsequently trying to hotplug another interface of any kind.

This is solved by adding a new function that lets us learn the type of
any interface prior to setting it up, then using that function to
change the behavior when assigning aliases.

This *really* should be pushed before 1.3.3 is released.

Laine Stump (3):
   network: new function networkGetActualType
   qemu: change args to qemuAssignDeviceHostdevAlias()
   qemu: fix alias name for 

  src/network/bridge_driver.c | 72 +
  src/network/bridge_driver.h |  6 +++-
  src/qemu/qemu_alias.c   | 60 +
  src/qemu/qemu_alias.h   |  2 +-
  src/qemu/qemu_hotplug.c | 10 +++
  5 files changed, 118 insertions(+), 32 deletions(-)


ACK series and safe for freeze.



Thanks, I just pushed it.

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


[libvirt] [PATCH v2] Use virGetLastErrorMessage() rather than open code it

2016-04-04 Thread Hui Yiqun
getting err using virGetLastError() and then retrieving
message from err asks developers to test the value
of err and err->message and default to self-defined
unkown error message.

It's better to avoid it and use uniform
virGetLastErrorMessage
---
 daemon/libvirtd.c   |  8 +---
 examples/object-events/event-test.c |  9 ++---
 src/bhyve/bhyve_driver.c|  3 +-
 src/libvirt.c   |  3 +-
 src/libxl/libxl_domain.c|  3 +-
 src/libxl/libxl_driver.c|  3 +-
 src/locking/lock_daemon.c   |  8 +---
 src/logging/log_daemon.c|  8 +---
 src/lxc/lxc_container.c |  8 +---
 src/lxc/lxc_controller.c|  8 +---
 src/lxc/lxc_domain.c|  3 +-
 src/lxc/lxc_process.c   |  6 +--
 src/network/bridge_driver.c |  3 +-
 src/node_device/node_device_hal.c   |  3 +-
 src/rpc/virnettlscontext.c  |  3 +-
 src/secret/secret_driver.c  |  6 +--
 src/storage/storage_driver.c| 16 ++--
 src/uml/uml_driver.c|  3 +-
 src/util/iohelper.c | 10 +
 src/util/virhook.c  |  3 +-
 src/util/virhostdev.c   | 20 -
 tests/commandtest.c | 81 +
 tests/libvirtdconftest.c|  3 +-
 tests/openvzutilstest.c |  7 +---
 tests/securityselinuxlabeltest.c|  9 ++---
 tests/securityselinuxtest.c |  6 +--
 tests/virnettlscontexttest.c|  3 +-
 27 files changed, 77 insertions(+), 169 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 3d38a46..e526e55 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -1273,12 +1273,8 @@ int main(int argc, char **argv) {
 /* Read the config file if it exists*/
 if (remote_config_file &&
 daemonConfigLoadFile(config, remote_config_file, implicit_conf) < 0) {
-virErrorPtr err = virGetLastError();
-if (err && err->message)
-VIR_ERROR(_("Can't load config file: %s: %s"),
-  err->message, remote_config_file);
-else
-VIR_ERROR(_("Can't load config file: %s"), remote_config_file);
+VIR_ERROR(_("Can't load config file: %s: %s"),
+  virGetLastErrorMessage(), remote_config_file);
 exit(EXIT_FAILURE);
 }
 
diff --git a/examples/object-events/event-test.c 
b/examples/object-events/event-test.c
index 7be1d21..4a4ef86 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -654,9 +654,8 @@ int main(int argc, char **argv)
 }
 
 if (virEventRegisterDefaultImpl() < 0) {
-virErrorPtr err = virGetLastError();
 fprintf(stderr, "Failed to register event implementation: %s\n",
-err && err->message ? err->message: "Unknown error");
+virGetLastErrorMessage());
 goto cleanup;
 }
 
@@ -794,17 +793,15 @@ int main(int argc, char **argv)
 goto cleanup;
 
 if (virConnectSetKeepAlive(dconn, 5, 3) < 0) {
-virErrorPtr err = virGetLastError();
 fprintf(stderr, "Failed to start keepalive protocol: %s\n",
-err && err->message ? err->message : "Unknown error");
+virGetLastErrorMessage());
 run = 0;
 }
 
 while (run) {
 if (virEventRunDefaultImpl() < 0) {
-virErrorPtr err = virGetLastError();
 fprintf(stderr, "Failed to run event loop: %s\n",
-err && err->message ? err->message : "Unknown error");
+virGetLastErrorMessage());
 }
 }
 
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 9219890..6f2423c 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -88,9 +88,8 @@ bhyveAutostartDomain(virDomainObjPtr vm, void *opaque)
 ret = virBhyveProcessStart(data->conn, data->driver, vm,
VIR_DOMAIN_RUNNING_BOOTED, 0);
 if (ret < 0) {
-virErrorPtr err = virGetLastError();
 VIR_ERROR(_("Failed to autostart VM '%s': %s"),
-  vm->def->name, err ? err->message : _("unknown error"));
+  vm->def->name, virGetLastErrorMessage());
 }
 }
 virObjectUnlock(vm);
diff --git a/src/libvirt.c b/src/libvirt.c
index dd58e9c..99b1c47 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -777,10 +777,9 @@ virStateInitialize(bool privileged,
 if (virStateDriverTab[i]->stateInitialize(privileged,
   callback,
   opaque) < 0) {
-virErrorPtr err = virGetLastError();
 VIR_ERROR(_("Initialization of %s state driver failed: %s"),
   virStateDriverTab[i]->name,
-  err && err->message ? err->message : _("Unknown 

Re: [libvirt] [PATCH v2 3/4] qemu: Create domain master key

2016-04-04 Thread Daniel P. Berrange
On Tue, Mar 29, 2016 at 07:11:35PM -0400, John Ferlan wrote:
> Add a masterKey and masterKeyLen to _qemuDomainObjPrivate to store a
> random domain master key and its length in order to support the ability
> to encrypt/decrypt sensitive data shared between libvirt and qemu. The
> key will be base64 encoded and written to a file to be used by the
> command line building code to share with qemu.
> 
> New API's from this patch:
> 
>   qemuDomainGetMasterKeyFilePath:
> Return a path to where the key is located
> 
>   qemuDomainWriteMasterKeyFile: (private)
> Open (create/trunc) the masterKey path and write the masterKey
> 
>   qemuDomainMasterKeyReadFile:
> Using the master key path, open/read the file, and store the
> masterKey and masterKeyLen. Expected use only from qemuProcessReconnect
> 
>   qemuDomainGenerateRandomKey: (private)
> Generate a random key using available algorithms
> 
> The key is generated either from the gnutls_rnd function if it
> exists or a less cryptographically strong mechanism using
> virGenerateRandomBytes
> 
>qemuDomainMasterKeyRemove:
> Remove traces of the master key, remove the *KeyFilePath
> 
>   qemuDomainMasterKeyCreate:
> Generate the domain master key and save the key in the location
> returned by qemuDomainGetMasterKeyFilePath.
> 
> This API will first ensure the QEMU_CAPS_OBJECT_SECRET is set
> in the capabilities. If not, then there's no need to generate
> the secret or file.
> 
> The creation of the key will be attempted from qemuProcessPrepareHost
> once the libDir directory structure exists.
> 
> The removal of the key will handled from qemuProcessStop just prior
> to deleting the libDir tree.
> 
> Since the key will not be written out to the domain object XML file,
> the qemuProcessReconnect will read the saved file and restore the
> masterKey and masterKeyLen.
> 
> Signed-off-by: John Ferlan 
> ---
>  src/qemu/qemu_domain.c  | 252 
> 
>  src/qemu/qemu_domain.h  |  15 +++
>  src/qemu/qemu_process.c |  11 +++
>  3 files changed, 278 insertions(+)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 53cb2b6..99a91d2 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -44,6 +44,12 @@
>  #include "virthreadjob.h"
>  #include "viratomic.h"
>  #include "virprocess.h"
> +#include "virrandom.h"
> +#include "base64.h"
> +#include 
> +#if HAVE_GNUTLS_CRYPTO_H
> +# include 
> +#endif
>  #include "logging/log_manager.h"
>  
>  #include "storage/storage_driver.h"
> @@ -465,6 +471,252 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
>  }
>  
>  
> +/* qemuDomainGetMasterKeyFilePath:
> + * @libDir: Directory path to domain lib files
> + *
> + * Generate a path to the domain master key file for libDir.
> + * It's up to the caller to handle checking if path exists.
> + *
> + * Returns path to memory containing the name of the file. It is up to the
> + * caller to free; otherwise, NULL on failure.
> + */
> +char *
> +qemuDomainGetMasterKeyFilePath(const char *libDir)
> +{
> +if (!libDir) {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("invalid path for master key file"));
> +return NULL;
> +}
> +return virFileBuildPath(libDir, "master-key.aes", NULL);
> +}
> +
> +
> +/* qemuDomainWriteMasterKeyFile:
> + * @priv: pointer to domain private object
> + *
> + * Get the desired path to the masterKey file and store it in the path.
> + *
> + * Returns 0 on success, -1 on failure with error message indicating failure
> + */
> +static int
> +qemuDomainWriteMasterKeyFile(qemuDomainObjPrivatePtr priv)
> +{
> +char *path;
> +int fd = -1;
> +int ret = -1;
> +
> +if (!(path = qemuDomainGetMasterKeyFilePath(priv->libDir)))
> +return -1;
> +
> +if ((fd = open(path, O_WRONLY|O_TRUNC|O_CREAT, 0600)) < 0) {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("failed to open domain master key file for write"));
> +goto cleanup;
> +}
> +
> +if (safewrite(fd, priv->masterKey, priv->masterKeyLen) < 0) {
> +virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +   _("failed to write master key file for domain"));
> +goto cleanup;
> +}
> +
> +ret = 0;
> +
> + cleanup:
> +VIR_FORCE_CLOSE(fd);
> +VIR_FREE(path);
> +
> +return ret;
> +}
> +
> +
> +/* qemuDomainMasterKeyReadFile:
> + * @priv: pointer to domain private object
> + *
> + * Expected to be called during qemuProcessReconnect once the domain
> + * libDir has been generated through qemuStateInitialize calling
> + * virDomainObjListLoadAllConfigs which will restore the libDir path
> + * to the domain private object.
> + *
> + * This function will get the path to the master key file and if it
> + * exists, it will read the contents of the file saving it in 
> priv->masterKey.
> + *
> + * Once the 

Re: [libvirt] [PATCH v2 4/4] qemu: Introduce qemuBuildMasterKeyCommandLine

2016-04-04 Thread Daniel P. Berrange
On Tue, Mar 29, 2016 at 07:11:36PM -0400, John Ferlan wrote:
> If the -object secret capability exists, then get the path to the
> masterKey file and provide that to qemu. Checking for the existence
> of the file before passing to qemu could be done, but causes issues
> in mock test environment.
> 
> Since the qemuDomainObjPrivate is not available when building the
> command line, the qemuBuildHasMasterKey API will have to suffice
> as the primary arbiter for whether the capability exists in order
> to find/return the path to the master key for usage.
> 
> Created the qemuDomainGetMasterKeyAlias API which will be used by
> later patches to define the 'keyid' (eg, masterKey) to be used by
> other secrets to provide the id to qemu for the master key.
> 
> Signed-off-by: John Ferlan 
> ---
>  src/qemu/qemu_alias.c  | 17 ++
>  src/qemu/qemu_alias.h  |  3 +
>  src/qemu/qemu_command.c| 68 
> ++
>  .../qemuxml2argvdata/qemuxml2argv-master-key.args  | 23 
>  tests/qemuxml2argvdata/qemuxml2argv-master-key.xml | 30 ++
>  tests/qemuxml2argvtest.c   |  2 +
>  6 files changed, 143 insertions(+)
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-master-key.args
>  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-master-key.xml

ACK


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

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


Re: [libvirt] [libvirt-perl][PATCH 0/3] Adapt to new virDomain{Get, Set}PerfEvents API

2016-04-04 Thread Michal Privoznik
On 04.04.2016 10:29, Daniel P. Berrange wrote:
> On Sat, Apr 02, 2016 at 04:45:21PM +0200, Michal Privoznik wrote:
>> It would be nice to have these in before the release.
>>
>> Michal Privoznik (3):
>>   Adapt to new virDomain{Get,Set}PerfEvents()
>>   gitignore: Add more files to ignore & reorder
>>   Add myself to AUTHORS
>>
>>  .gitignore | 17 ++---
>>  AUTHORS|  1 +
>>  Changes|  1 +
>>  Virt.xs| 38 ++
>>  lib/Sys/Virt/Domain.pm | 32 
>>  lib/Sys/Virt/Error.pm  |  4 
>>  6 files changed, 86 insertions(+), 7 deletions(-)
> 
> FYI I already posted this fix on friday but forgot to push it
> 
> 

Oh, should have checked the list before starting work on this. My bad.
But what's good is that my code looks just the same as yours. Cool!

I've pushed the other two patches then.

Michal

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


Re: [libvirt] [PATCH v2 2/4] util: Introduce virGenerateRandomBytes

2016-04-04 Thread Daniel P. Berrange
On Tue, Mar 29, 2016 at 07:11:34PM -0400, John Ferlan wrote:
> Using the existing virUUIDGenerateRandomBytes, move API to virutil.c
> and add it to libvirt_private.syms.
> 
> This will be used as a fallback for generating a domain master key.
> 
> Signed-off-by: John Ferlan 
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virutil.c   | 36 
>  src/util/virutil.h   |  3 +++
>  src/util/viruuid.c   | 30 +-
>  4 files changed, 41 insertions(+), 29 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 7c44047..3d54c39 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -2422,6 +2422,7 @@ virEnumToString;
>  virFindFCHostCapableVport;
>  virFindSCSIHostByPCI;
>  virFormatIntDecimal;
> +virGenerateRandomBytes;
>  virGetDeviceID;
>  virGetDeviceUnprivSGIO;
>  virGetEnvAllowSUID;
> diff --git a/src/util/virutil.c b/src/util/virutil.c
> index b401f8d..c55f6f6 100644
> --- a/src/util/virutil.c
> +++ b/src/util/virutil.c
> @@ -2669,3 +2669,39 @@ virMemoryMaxValue(bool capped)
>  else
>  return LLONG_MAX;
>  }
> +
> +
> +/**
> + * virGenerateRandomBytes
> + * @buf: Pointer to location to store bytes
> + * @buflen: Number of bytes to store
> + *
> + * Generate a stream of random bytes into @buf of size @buflen
> + */
> +int
> +virGenerateRandomBytes(unsigned char *buf,
> +   size_t buflen)
> +{
> +int fd;
> +
> +if ((fd = open("/dev/urandom", O_RDONLY)) < 0)
> +return errno;
> +
> +while (buflen > 0) {
> +ssize_t n;
> +
> +if ((n = read(fd, buf, buflen)) <= 0) {
> +if (errno == EINTR)
> +continue;
> +VIR_FORCE_CLOSE(fd);
> +return n < 0 ? errno : ENODATA;
> +}
> +
> +buf += n;
> +buflen -= n;
> +}
> +
> +VIR_FORCE_CLOSE(fd);
> +
> +return 0;
> +}
> diff --git a/src/util/virutil.h b/src/util/virutil.h
> index b121de0..a398b38 100644
> --- a/src/util/virutil.h
> +++ b/src/util/virutil.h
> @@ -254,6 +254,9 @@ unsigned long long virMemoryLimitTruncate(unsigned long 
> long value);
>  bool virMemoryLimitIsSet(unsigned long long value);
>  unsigned long long virMemoryMaxValue(bool ulong);
>  
> +int virGenerateRandomBytes(unsigned char *buf, size_t buflen)
> +ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
> +

Please call this   virRandomBytes() and put it in virrandom.{c,h}

ACK if you make that change before applying.

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

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


Re: [libvirt] [PATCH v2 1/4] qemu: Add capability bit for qemu secret object

2016-04-04 Thread Daniel P. Berrange
On Tue, Mar 29, 2016 at 07:11:33PM -0400, John Ferlan wrote:
> Add a capability bit for the qemu secret object.
> 
> Adjust the 2.6.0-1 caps/replies to add the secret object. For the
> .replies it's take from the '{"execute":"qom-list-types"}' output.
> 
> Signed-off-by: John Ferlan 
> ---
>  src/qemu/qemu_capabilities.c| 2 ++
>  src/qemu/qemu_capabilities.h| 1 +
>  tests/qemucapabilitiesdata/caps_2.6.0-1.caps| 1 +
>  tests/qemucapabilitiesdata/caps_2.6.0-1.replies | 3 +++
>  4 files changed, 7 insertions(+)

ACK


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

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


Re: [libvirt] [PATCH for 1.3.3 0/3] qemu: Regenerate per-domain paths on restart

2016-04-04 Thread Guido Günther
On Sun, Apr 03, 2016 at 10:23:20PM +0200, Martin Kletzander wrote:
> We forgot to clean up after the domain is torn down.  And because they
> are kept, we don't regenerate them upn another start and because of
> that they contain old IDs in them.
> 
> Again, the series is structured as with the previous one [1].  The
> smallest part (firs patch only) is enough to fix it for the release,
> others can be pushed before or after release.  That depends on the
> reviewer.
> 
> [1] https://www.redhat.com/archives/libvir-list/2016-April/msg00081.html
> 
> 
> Martin Kletzander (3):
>   qemu: Clear generated private paths
>   qemu: Simplify calls to qemuDomainSetPrivatePaths
>   qemu: Add qemuDomainClearPrivatePaths and use it
> 
>  src/qemu/qemu_domain.c  | 40 
>  src/qemu/qemu_domain.h  | 10 --
>  src/qemu/qemu_process.c |  9 +++--
>  3 files changed, 35 insertions(+), 24 deletions(-)
> 

ACK.
 -- Guido

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


Re: [libvirt] [PATCH 0/3] fix regression wrt

2016-04-04 Thread Michal Privoznik
On 01.04.2016 19:54, Laine Stump wrote:
> The full description of the problem fixed by these patches is in patch
> 3/3. Basically, a recent patch changed the ordering of things during
> startup such that hostdev interfaces are given an alias named "netN"
> rather than the expected "hostdevN". That caused a problem when
> subsequently trying to hotplug another interface of any kind.
> 
> This is solved by adding a new function that lets us learn the type of
> any interface prior to setting it up, then using that function to
> change the behavior when assigning aliases.
> 
> This *really* should be pushed before 1.3.3 is released.
> 
> Laine Stump (3):
>   network: new function networkGetActualType
>   qemu: change args to qemuAssignDeviceHostdevAlias()
>   qemu: fix alias name for 
> 
>  src/network/bridge_driver.c | 72 
> +
>  src/network/bridge_driver.h |  6 +++-
>  src/qemu/qemu_alias.c   | 60 +
>  src/qemu/qemu_alias.h   |  2 +-
>  src/qemu/qemu_hotplug.c | 10 +++
>  5 files changed, 118 insertions(+), 32 deletions(-)
> 

ACK series and safe for freeze.

Michal

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


Re: [libvirt] [libvirt-perl][PATCH 3/3] Add myself to AUTHORS

2016-04-04 Thread Daniel P. Berrange
On Sat, Apr 02, 2016 at 04:45:24PM +0200, Michal Privoznik wrote:
> Signed-off-by: Michal Privoznik 
> ---
>  AUTHORS | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/AUTHORS b/AUTHORS
> index c2af49a..cb96cdc 100644
> --- a/AUTHORS
> +++ b/AUTHORS
> @@ -13,5 +13,6 @@ Patches contributed by:
> Ludwig Nussel 
> Zhe Peng  
> Osier Yang
> +   Michal Privoznik  

ACK

Guess we ought to make this auto-generated at some point.

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

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


Re: [libvirt] [libvirt-perl][PATCH 2/3] gitignore: Add more files to ignore & reorder

2016-04-04 Thread Daniel P. Berrange
On Sat, Apr 02, 2016 at 04:45:23PM +0200, Michal Privoznik wrote:
> For instance, on my system not just META.yml is produced by
> MYMETA.yml and MYMETA.json too. Also, if you happen to generate
> tags or use vim to edit the source code, you'll find some files
> useless to track in git.
> 
> Signed-off-by: Michal Privoznik 
> ---
>  .gitignore | 17 ++---
>  1 file changed, 10 insertions(+), 7 deletions(-)

ACK


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

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


Re: [libvirt] [libvirt-perl][PATCH 0/3] Adapt to new virDomain{Get, Set}PerfEvents API

2016-04-04 Thread Daniel P. Berrange
On Sat, Apr 02, 2016 at 04:45:21PM +0200, Michal Privoznik wrote:
> It would be nice to have these in before the release.
> 
> Michal Privoznik (3):
>   Adapt to new virDomain{Get,Set}PerfEvents()
>   gitignore: Add more files to ignore & reorder
>   Add myself to AUTHORS
> 
>  .gitignore | 17 ++---
>  AUTHORS|  1 +
>  Changes|  1 +
>  Virt.xs| 38 ++
>  lib/Sys/Virt/Domain.pm | 32 
>  lib/Sys/Virt/Error.pm  |  4 
>  6 files changed, 86 insertions(+), 7 deletions(-)

FYI I already posted this fix on friday but forgot to push it


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

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


Re: [libvirt] [PATCH for 1.3.3 0/5] Fix parsing our own XMLs

2016-04-04 Thread Michal Privoznik
On 03.04.2016 21:27, Martin Kletzander wrote:
> Laine found out that he can't do 'virsh nodedev-detach pci_dev'
> because of some strange error message.  That was caused by my commit,
> but also by all the previous ones that skipped adding tests and
> parsing of new functions.  In order for this to work in 1.3.3, we need
> either a) only the first patch or b) all of them.  I specifically
> created the first one so that it has enough in itself to fix the
> problem and we don't need to push more and more patches into the
> release.  We can push the rest after release.  If someone wants to
> have all in for 1.3.3, well, I hope I added enough tests for that ;)
> 
> 
> Martin Kletzander (5):
>   nodedev: Fix parsing of generated XMLs
>   Change virPCIDeviceAddress to virDevicePCIAddress
>   Move capability formatting together
>   schemas: Update nodedev schema to match reality
>   conf: Parse more of our nodedev XML
> 
>  docs/schemas/nodedev.rng   |  29 +++--
>  src/conf/device_conf.h |  11 +-
>  src/conf/node_device_conf.c| 121 
> ++---
>  src/conf/node_device_conf.h|   6 +-
>  src/libvirt_private.syms   |  10 +-
>  src/network/bridge_driver.c|   4 +-
>  src/node_device/node_device_linux_sysfs.c  |   6 +-
>  src/util/virhostdev.c  |  12 +-
>  src/util/virnetdev.c   |   4 +-
>  src/util/virnetdev.h   |   2 +-
>  src/util/virpci.c  |  80 +++---
>  src/util/virpci.h  |  29 ++---
>  .../pci__00_1c_0_header_type.xml   |   2 +-
>  tests/nodedevschemadata/pci__02_10_7_sriov.xml |  23 
>  .../pci__02_10_7_sriov_pf_vfs_all.xml  |  29 +
>  ...i__02_10_7_sriov_pf_vfs_all_header_type.xml |  30 +
>  .../pci__02_10_7_sriov_vfs.xml |  26 +
>  .../pci__02_10_7_sriov_zero_vfs_max_count.xml  |  21 
>  tests/nodedevxml2xmltest.c |   5 +
>  19 files changed, 333 insertions(+), 117 deletions(-)
>  create mode 100644 tests/nodedevschemadata/pci__02_10_7_sriov.xml
>  create mode 100644 
> tests/nodedevschemadata/pci__02_10_7_sriov_pf_vfs_all.xml
>  create mode 100644 
> tests/nodedevschemadata/pci__02_10_7_sriov_pf_vfs_all_header_type.xml
>  create mode 100644 tests/nodedevschemadata/pci__02_10_7_sriov_vfs.xml
>  create mode 100644 
> tests/nodedevschemadata/pci__02_10_7_sriov_zero_vfs_max_count.xml
> 

I like this. I really do. And if we were not in the freeze, I would ACK
this straight away. But since we are in the freeze, we should push only
(small) bug fixes. And I think the minimum needed here is 1/5, right?
Therefore, I'd suggest pushing that one and saving the rest for after
the release. Is that okay with you?

Michal

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


Re: [libvirt] [PATCH 3/3] qemu: Add qemuDomainClearPrivatePaths and use it

2016-04-04 Thread Martin Kletzander

On Mon, Apr 04, 2016 at 07:12:50AM +0200, Michal Privoznik wrote:

On 03.04.2016 22:23, Martin Kletzander wrote:

It's the counterpart of qemuDomainSetPrivatePaths().

Signed-off-by: Martin Kletzander 
---
 src/qemu/qemu_domain.c  | 10 ++
 src/qemu/qemu_domain.h  |  1 +
 src/qemu/qemu_process.c |  3 +--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6102f7983f58..f38b0f381030 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -562,6 +562,16 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
 }


+void
+qemuDomainClearPrivatePaths(virDomainObjPtr vm)
+{
+qemuDomainObjPrivatePtr priv = vm->privateData;
+
+VIR_FREE(priv->libDir);
+VIR_FREE(priv->channelTargetDir);
+}
+
+
 static void *
 qemuDomainObjPrivateAlloc(void)
 {
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 918a77dabd29..54d7bd74f3be 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -554,6 +554,7 @@ int qemuDomainNetVLAN(virDomainNetDefPtr def);
 int qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
   virDomainObjPtr vm);

+void qemuDomainClearPrivatePaths(virDomainObjPtr vm);

 virDomainDiskDefPtr qemuDomainDiskByName(virDomainDefPtr def, const char 
*name);

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 02c13bcfbb38..d9dca7485387 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5832,8 +5832,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
 virFileDeleteTree(priv->libDir);
 virFileDeleteTree(priv->channelTargetDir);

-VIR_FREE(priv->libDir);
-VIR_FREE(priv->channelTargetDir);
+qemuDomainClearPrivatePaths(vm);

 ignore_value(virDomainChrDefForeach(vm->def,
 false,



I think this can be merged with 1/3.



Yes, I forgot to mention that if we decide to put all commits in
together, then I'll just make it two commits so it makes more sense.


Michal


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