Re: [libvirt] [PATCHv3 11/12] qemu: Implement memory device hotplug

2015-03-23 Thread Peter Krempa
On Thu, Mar 19, 2015 at 18:40:36 -0400, John Ferlan wrote:
 
 
 On 03/17/2015 10:20 AM, Peter Krempa wrote:
  Add code to hot-add memory devices to running qemu instances.
  ---
  
  Notes:
  Version 3:
  - added comment to clarify that @mem is always consumed by 
  qemuDomainAttachMemory
  Version 2:
  - no change
  
  Version 2:
  - no change
  
   src/qemu/qemu_command.c |  4 +--
   src/qemu/qemu_command.h | 15 
   src/qemu/qemu_driver.c  |  5 ++-
   src/qemu/qemu_hotplug.c | 95 
  +
   src/qemu/qemu_hotplug.h |  3 ++
   5 files changed, 119 insertions(+), 3 deletions(-)
  
  @@ -1672,6 +1672,101 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,

...

   }
  
  
  +/**
  + * qemuDomainAttachMemory:
  + * @driver: qemu driver data
  + * @vm: VM object
  + * @mem: Definition of the memory device to be attached. @mem is always 
  consumed
  + *
  + * Attaches memory device described by @mem to domain @vm.
  + *
  + * Returns 0 on success -1 on error.
  + */
  +int
  +qemuDomainAttachMemory(virQEMUDriverPtr driver,
  +   virDomainObjPtr vm,
  +   virDomainMemoryDefPtr mem)
  +{
  +qemuDomainObjPrivatePtr priv = vm-privateData;
  +virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
  +char *devstr = NULL;
  +char *objalias = NULL;
  +const char *backendType;
  +virJSONValuePtr props = NULL;
  +int id;
  +int ret = -1;
  +
  +if (virAsprintf(mem-info.alias, dimm%zu, vm-def-nmems)  0)
  +goto cleanup;
  +
  +if (virAsprintf(objalias, mem%s, mem-info.alias)  0)
  +goto cleanup;
  +
  +if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv-qemuCaps)))
  +goto cleanup;
  +
  +qemuDomainMemoryDeviceAlignSize(mem);
  +
  +if (qemuBuildMemoryBackendStr(mem-size, mem-pagesize,
  +  mem-targetNode, mem-sourceNodes, NULL,
  +  vm-def, priv-qemuCaps, cfg,
  +  backendType, props, true)  0)
 
 Coverity determines that qemuBuildMemoryBackendStr can return props here
 with a -1 return and thus leak props
 
 That's because qemuBuildMemoryBackendStr sets the returned *backendProps
 and sets the local props to NULL before the (!hugepages) code which if
 it fails won't cause 'props' to be free'd properly
 
 Adding the virJSONValueFree(props); makes Coverity happy again.

I'll fix qemuBuildMemoryBackendStr separately rather than adding a
pseudo-hack that would violate the style we are using for functions that
return via argument.

Peter


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

Re: [libvirt] [PATCH] qemu: Don't return memory device config on error in qemuBuildMemoryBackendStr

2015-03-23 Thread John Ferlan


On 03/23/2015 09:23 AM, Peter Krempa wrote:
 In the last section if the function determines that the config is
 invalid when QEMU doesn't support the memory device the JSON config
 object would be returned even if it doesn't make sense.
 
 Assign the object to be returned only on success.
 ---
  src/qemu/qemu_command.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)
 

ACK

John

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


[libvirt] [PATCH 3/8] Force usage of virThreadCreate

2015-03-23 Thread Jiri Denemark
We want all threads to be set as workers or to have a job assigned to
them, which can easily be achieved in virThreadCreate wrapper to
pthread_create. Let's make sure we always use the wrapper.

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 cfg.mk  |  9 +
 src/nwfilter/nwfilter_learnipaddr.c | 15 ++-
 src/nwfilter/nwfilter_learnipaddr.h |  1 -
 3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 6885f9e..661 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -999,6 +999,12 @@ sc_prohibit_sysconf_pagesize:
halt='use virGetSystemPageSize[KB] instead of sysconf(_SC_PAGESIZE)' \
  $(_sc_search_regexp)
 
+sc_prohibit_pthread_create:
+   @prohibit='\bpthread_create\b' \
+   exclude='sc_prohibit_pthread_create' \
+   halt=avoid using 'pthread_create', use 'virThreadCreate' instead \
+ $(_sc_search_regexp)
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
@@ -1192,3 +1198,6 @@ exclude_file_name_regexp--sc_prohibit_virXXXFree = \
 
 exclude_file_name_regexp--sc_prohibit_sysconf_pagesize = \
   ^(cfg\.mk|src/util/virutil\.c)$$
+
+exclude_file_name_regexp--sc_prohibit_pthread_create = \
+  ^(cfg\.mk|src/util/virthread\.c|tests/.*)$$
diff --git a/src/nwfilter/nwfilter_learnipaddr.c 
b/src/nwfilter/nwfilter_learnipaddr.c
index 1b875c3..5b55055 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -374,7 +374,7 @@ procDHCPOpts(struct dhcp *dhcp, int dhcp_opts_len,
  * will require that the IP address was taken from an ARP packet or an IPv4
  * packet. Both flags can be set at the same time.
  */
-static void *
+static void
 learnIPAddressThread(void *arg)
 {
 char errbuf[PCAP_ERRBUF_SIZE] = {0};
@@ -638,8 +638,6 @@ learnIPAddressThread(void *arg)
 techdriver-applyDropAllRules(req-ifname);
 }
 
-memset(req-thread, 0x0, sizeof(req-thread));
-
 VIR_DEBUG(pcap thread terminating for interface %s\n, req-ifname);
 
 virNWFilterUnlockIface(req-ifname);
@@ -648,8 +646,6 @@ learnIPAddressThread(void *arg)
 virNWFilterDeregisterLearnReq(req-ifindex);
 
 virNWFilterIPAddrLearnReqFree(req);
-
-return 0;
 }
 
 
@@ -686,6 +682,7 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr 
techdriver,
   enum howDetect howDetect)
 {
 int rc;
+virThread thread;
 virNWFilterIPAddrLearnReqPtr req = NULL;
 virNWFilterHashTablePtr ht = NULL;
 
@@ -742,10 +739,10 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr 
techdriver,
 if (rc  0)
 goto err_free_req;
 
-if (pthread_create(req-thread,
-   NULL,
-   learnIPAddressThread,
-   req) != 0)
+if (virThreadCreate(thread,
+false,
+learnIPAddressThread,
+req) != 0)
 goto err_dereg_req;
 
 return 0;
diff --git a/src/nwfilter/nwfilter_learnipaddr.h 
b/src/nwfilter/nwfilter_learnipaddr.h
index 1cc881a..b93ed38 100644
--- a/src/nwfilter/nwfilter_learnipaddr.h
+++ b/src/nwfilter/nwfilter_learnipaddr.h
@@ -49,7 +49,6 @@ struct _virNWFilterIPAddrLearnReq {
 enum howDetect howDetect;
 
 int status;
-pthread_t thread;
 volatile bool terminate;
 };
 
-- 
2.3.3

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


[libvirt] [PATCH 4/8] virThread: Set thread job

2015-03-23 Thread Jiri Denemark
Automatically assign a job to every thread created by virThreadCreate.
The name of the virThreadFunc function passed to virThreadCreate is used
as the job or worker name in case no name is explicitly passed.

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 src/libvirt_private.syms |  2 +-
 src/util/virthread.c | 25 +
 src/util/virthread.h | 13 +
 3 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f5756a7..4980305 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2174,7 +2174,7 @@ virRWLockRead;
 virRWLockUnlock;
 virRWLockWrite;
 virThreadCancel;
-virThreadCreate;
+virThreadCreateFull;
 virThreadID;
 virThreadInitialize;
 virThreadIsSelf;
diff --git a/src/util/virthread.c b/src/util/virthread.c
index 7e841d1..c2a9e7f 100644
--- a/src/util/virthread.c
+++ b/src/util/virthread.c
@@ -30,6 +30,7 @@
 #endif
 
 #include viralloc.h
+#include virthreadjob.h
 
 
 /* Nothing special required for pthreads */
@@ -184,6 +185,8 @@ void virCondBroadcast(virCondPtr c)
 
 struct virThreadArgs {
 virThreadFunc func;
+const char *funcName;
+bool worker;
 void *opaque;
 };
 
@@ -194,14 +197,26 @@ static void *virThreadHelper(void *data)
 
 /* Free args early, rather than tying it up during the entire thread.  */
 VIR_FREE(args);
+
+if (local.worker)
+virThreadJobSetWorker(local.funcName);
+else
+virThreadJobSet(local.funcName);
+
 local.func(local.opaque);
+
+if (!local.worker)
+virThreadJobClear(0);
+
 return NULL;
 }
 
-int virThreadCreate(virThreadPtr thread,
-bool joinable,
-virThreadFunc func,
-void *opaque)
+int virThreadCreateFull(virThreadPtr thread,
+bool joinable,
+virThreadFunc func,
+const char *funcName,
+bool worker,
+void *opaque)
 {
 struct virThreadArgs *args;
 pthread_attr_t attr;
@@ -216,6 +231,8 @@ int virThreadCreate(virThreadPtr thread,
 }
 
 args-func = func;
+args-funcName = funcName;
+args-worker = worker;
 args-opaque = opaque;
 
 if (!joinable)
diff --git a/src/util/virthread.h b/src/util/virthread.h
index 7146f0f..e466d9b 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -88,10 +88,15 @@ void virThreadOnExit(void);
 
 typedef void (*virThreadFunc)(void *opaque);
 
-int virThreadCreate(virThreadPtr thread,
-bool joinable,
-virThreadFunc func,
-void *opaque) ATTRIBUTE_RETURN_CHECK;
+# define virThreadCreate(thread, joinable, func, opaque) \
+virThreadCreateFull(thread, joinable, func, #func, false, opaque)
+
+int virThreadCreateFull(virThreadPtr thread,
+bool joinable,
+virThreadFunc func,
+const char *funcName,
+bool worker,
+void *opaque) ATTRIBUTE_RETURN_CHECK;
 void virThreadSelf(virThreadPtr thread);
 bool virThreadIsSelf(virThreadPtr thread);
 void virThreadJoin(virThreadPtr thread);
-- 
2.3.3

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


[libvirt] [PATCH 8/8] qemu: Add timing to domain jobs

2015-03-23 Thread Jiri Denemark
Whenever we fail to acquire a job, we can report how long ago it was
locked by another API.

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

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 src/qemu/qemu_domain.c | 20 ++--
 src/qemu/qemu_domain.h |  2 ++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index dc55016..72b1b84 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -154,6 +154,7 @@ qemuDomainObjResetJob(qemuDomainObjPrivatePtr priv)
 job-active = QEMU_JOB_NONE;
 job-owner = 0;
 job-ownerAPI = NULL;
+job-started = 0;
 }
 
 static void
@@ -164,6 +165,7 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
 job-asyncJob = QEMU_ASYNC_JOB_NONE;
 job-asyncOwner = 0;
 job-asyncOwnerAPI = NULL;
+job-asyncStarted = 0;
 job-phase = 0;
 job-mask = QEMU_JOB_DEFAULT_MASK;
 job-dump_memory_only = false;
@@ -1326,6 +1328,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
 const char *blocker = NULL;
 int ret = -1;
+unsigned long long duration = 0;
+unsigned long long asyncDuration = 0;
 
 VIR_DEBUG(Starting %s: %s (async=%s vm=%p name=%s),
   job == QEMU_JOB_ASYNC ? async job : job,
@@ -1366,6 +1370,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 
 qemuDomainObjResetJob(priv);
 
+ignore_value(virTimeMillisNow(now));
+
 if (job != QEMU_JOB_ASYNC) {
 VIR_DEBUG(Started job: %s (async=%s vm=%p name=%s),
qemuDomainJobTypeToString(job),
@@ -1374,6 +1380,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 priv-job.active = job;
 priv-job.owner = virThreadSelfID();
 priv-job.ownerAPI = virThreadJobGet();
+priv-job.started = now;
 } else {
 VIR_DEBUG(Started async job: %s (vm=%p name=%s),
   qemuDomainAsyncJobTypeToString(asyncJob),
@@ -1384,6 +1391,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 priv-job.asyncJob = asyncJob;
 priv-job.asyncOwner = virThreadSelfID();
 priv-job.asyncOwnerAPI = virThreadJobGet();
+priv-job.asyncStarted = now;
 priv-job.current-started = now;
 }
 
@@ -1394,15 +1402,23 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 return 0;
 
  error:
+ignore_value(virTimeMillisNow(now));
+if (priv-job.active  priv-job.started)
+duration = now - priv-job.started;
+if (priv-job.asyncJob  priv-job.asyncStarted)
+asyncDuration = now - priv-job.asyncStarted;
+
 VIR_WARN(Cannot start job (%s, %s) for domain %s; 
- current job is (%s, %s) owned by (%llu %s, %llu %s),
+ current job is (%s, %s) owned by (%llu %s, %llu %s) 
+ for (%llus, %llus),
  qemuDomainJobTypeToString(job),
  qemuDomainAsyncJobTypeToString(asyncJob),
  obj-def-name,
  qemuDomainJobTypeToString(priv-job.active),
  qemuDomainAsyncJobTypeToString(priv-job.asyncJob),
  priv-job.owner, NULLSTR(priv-job.ownerAPI),
- priv-job.asyncOwner, NULLSTR(priv-job.asyncOwnerAPI));
+ priv-job.asyncOwner, NULLSTR(priv-job.asyncOwnerAPI),
+ duration / 1000, asyncDuration / 1000);
 
 if (nested || qemuDomainNestedJobAllowed(priv, job))
 blocker = priv-job.ownerAPI;
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index a468982..9da80ca 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -118,11 +118,13 @@ struct qemuDomainJobObj {
 qemuDomainJob active;   /* Currently running job */
 unsigned long long owner;   /* Thread id which set current job */
 const char *ownerAPI;   /* The API which owns the job */
+unsigned long long started; /* When the current job started */
 
 virCond asyncCond;  /* Use to coordinate with async jobs */
 qemuDomainAsyncJob asyncJob;/* Currently active async job */
 unsigned long long asyncOwner;  /* Thread which set current async job 
*/
 const char *asyncOwnerAPI;  /* The API which owns the async job */
+unsigned long long asyncStarted;/* When the current async job started 
*/
 int phase;  /* Job phase (mainly for migrations) */
 unsigned long long mask;/* Jobs allowed during async job */
 bool dump_memory_only;  /* use dump-guest-memory to do dump */
-- 
2.3.3

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


[libvirt] [PATCH 1/8] POTFILES.in: Sort

2015-03-23 Thread Jiri Denemark
Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 po/POTFILES.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index fd8bf33..ab6ae3b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -178,6 +178,8 @@ src/util/virconf.c
 src/util/vircrypto.c
 src/util/virdbus.c
 src/util/virdnsmasq.c
+src/util/virerror.c
+src/util/virerror.h
 src/util/vireventpoll.c
 src/util/virfile.c
 src/util/virfirewall.c
@@ -218,8 +220,6 @@ src/util/virstorageencryption.c
 src/util/virstoragefile.c
 src/util/virstring.c
 src/util/virsysinfo.c
-src/util/virerror.c
-src/util/virerror.h
 src/util/virtime.c
 src/util/virtpm.c
 src/util/virtypedparam.c
-- 
2.3.3

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


[libvirt] [PATCH 7/8] qemu: Track the API which started the current job

2015-03-23 Thread Jiri Denemark
This is very helpful when we want to log and report why we could not
acquire a state change lock. Reporting what job keeps it locked helps
with understanding the issue. Moreover, after calling
virDomainGetControlInfo, it's possible to tell whether libvirt is just
stuck somewhere within the API (or it just forgot to cleanup the job) or
whether libvirt is waiting for QEMU to reply.

The error message will look like the following:

# virsh resume cd
error: Failed to resume domain cd
error: Timed out during operation: cannot acquire state change lock
(held by remoteDispatchDomainSuspend)

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

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 src/qemu/qemu_domain.c | 43 +--
 src/qemu/qemu_domain.h |  2 ++
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 559400c..dc55016 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -153,6 +153,7 @@ qemuDomainObjResetJob(qemuDomainObjPrivatePtr priv)
 
 job-active = QEMU_JOB_NONE;
 job-owner = 0;
+job-ownerAPI = NULL;
 }
 
 static void
@@ -162,6 +163,7 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv)
 
 job-asyncJob = QEMU_ASYNC_JOB_NONE;
 job-asyncOwner = 0;
+job-asyncOwnerAPI = NULL;
 job-phase = 0;
 job-mask = QEMU_JOB_DEFAULT_MASK;
 job-dump_memory_only = false;
@@ -1322,6 +1324,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 unsigned long long then;
 bool nested = job == QEMU_JOB_ASYNC_NESTED;
 virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+const char *blocker = NULL;
 int ret = -1;
 
 VIR_DEBUG(Starting %s: %s (async=%s vm=%p name=%s),
@@ -1370,6 +1373,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
   obj, obj-def-name);
 priv-job.active = job;
 priv-job.owner = virThreadSelfID();
+priv-job.ownerAPI = virThreadJobGet();
 } else {
 VIR_DEBUG(Started async job: %s (vm=%p name=%s),
   qemuDomainAsyncJobTypeToString(asyncJob),
@@ -1379,6 +1383,7 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 goto cleanup;
 priv-job.asyncJob = asyncJob;
 priv-job.asyncOwner = virThreadSelfID();
+priv-job.asyncOwnerAPI = virThreadJobGet();
 priv-job.current-started = now;
 }
 
@@ -1389,29 +1394,47 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver,
 return 0;
 
  error:
-VIR_WARN(Cannot start job (%s, %s) for domain %s;
-  current job is (%s, %s) owned by (%llu, %llu),
+VIR_WARN(Cannot start job (%s, %s) for domain %s; 
+ current job is (%s, %s) owned by (%llu %s, %llu %s),
  qemuDomainJobTypeToString(job),
  qemuDomainAsyncJobTypeToString(asyncJob),
  obj-def-name,
  qemuDomainJobTypeToString(priv-job.active),
  qemuDomainAsyncJobTypeToString(priv-job.asyncJob),
- priv-job.owner, priv-job.asyncOwner);
+ priv-job.owner, NULLSTR(priv-job.ownerAPI),
+ priv-job.asyncOwner, NULLSTR(priv-job.asyncOwnerAPI));
+
+if (nested || qemuDomainNestedJobAllowed(priv, job))
+blocker = priv-job.ownerAPI;
+else
+blocker = priv-job.asyncOwnerAPI;
 
 ret = -1;
 if (errno == ETIMEDOUT) {
-virReportError(VIR_ERR_OPERATION_TIMEOUT,
-   %s, _(cannot acquire state change lock));
+if (blocker) {
+virReportError(VIR_ERR_OPERATION_TIMEOUT,
+   _(cannot acquire state change lock (held by %s)),
+   blocker);
+} else {
+virReportError(VIR_ERR_OPERATION_TIMEOUT, %s,
+   _(cannot acquire state change lock));
+}
 ret = -2;
 } else if (cfg-maxQueuedJobs 
priv-jobs_queued  cfg-maxQueuedJobs) {
-virReportError(VIR_ERR_OPERATION_FAILED,
-   %s, _(cannot acquire state change lock 
-   due to max_queued limit));
+if (blocker) {
+virReportError(VIR_ERR_OPERATION_FAILED,
+   _(cannot acquire state change lock (held by %s) 
+ due to max_queued limit),
+   blocker);
+} else {
+virReportError(VIR_ERR_OPERATION_FAILED, %s,
+   _(cannot acquire state change lock 
+ due to max_queued limit));
+}
 ret = -2;
 } else {
-virReportSystemError(errno,
- %s, _(cannot acquire job mutex));
+virReportSystemError(errno, %s, _(cannot acquire job mutex));
 }
 
  cleanup:
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index ba8d398..a468982 100644
--- a/src/qemu/qemu_domain.h
+++ 

[libvirt] [PATCH 2/8] Add support for tracking thread jobs

2015-03-23 Thread Jiri Denemark
Each thread can use a thread local variable to keep the name of a job
which is currently running in the job.

The virThreadJobSetWorker API is supposed to be called once by any
thread which is used as a worker, i.e., it is waiting in a pool, woken
up to do a job, and returned back to the pool.

The virThreadJobSet/virThreadJobClear APIs are to be called at the
beginning/end of each job.

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 include/libvirt/virterror.h |   1 +
 po/POTFILES.in  |   1 +
 src/Makefile.am |   2 +
 src/libvirt_private.syms|   7 +++
 src/util/virerror.c |   1 +
 src/util/virthreadjob.c | 126 
 src/util/virthreadjob.h |  33 
 7 files changed, 171 insertions(+)
 create mode 100644 src/util/virthreadjob.c
 create mode 100644 src/util/virthreadjob.h

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 5dc99dc..9c5b069 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -125,6 +125,7 @@ typedef enum {
 VIR_FROM_FIREWALL = 59, /* Error from firewall */
 
 VIR_FROM_POLKIT = 60,   /* Error from polkit code */
+VIR_FROM_THREAD = 61,   /* Error from thread utils */
 
 # ifdef VIR_ENUM_SENTINELS
 VIR_ERR_DOMAIN_LAST
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ab6ae3b..dd06ab3 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -220,6 +220,7 @@ src/util/virstorageencryption.c
 src/util/virstoragefile.c
 src/util/virstring.c
 src/util/virsysinfo.c
+src/util/virthreadjob.c
 src/util/virtime.c
 src/util/virtpm.c
 src/util/virtypedparam.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 00b47e7..ec62ab4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,6 +160,7 @@ UTIL_SOURCES =  
\
util/virsysinfo.c util/virsysinfo.h \
util/virsystemd.c util/virsystemd.h \
util/virthread.c util/virthread.h   \
+   util/virthreadjob.c utils/virthreadjob.h\
util/virthreadpool.c util/virthreadpool.h   \
util/virtime.h util/virtime.c   \
util/virtpm.h util/virtpm.c \
@@ -2147,6 +2148,7 @@ libvirt_setuid_rpc_client_la_SOURCES =\
util/virstring.c\
util/virtime.c  \
util/virthread.c\
+   util/virthreadjob.c \
util/virtypedparam.c\
util/viruri.c   \
util/virutil.c  \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8141eba..f5756a7 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2183,6 +2183,13 @@ virThreadSelf;
 virThreadSelfID;
 
 
+# util/virthreadjob.h
+virThreadJobClear;
+virThreadJobGet;
+virThreadJobSet;
+virThreadJobSetWorker;
+
+
 # util/virthreadpool.h
 virThreadPoolFree;
 virThreadPoolGetMaxWorkers;
diff --git a/src/util/virerror.c b/src/util/virerror.c
index 9635c82..c4e84e7 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -132,6 +132,7 @@ VIR_ENUM_IMPL(virErrorDomain, VIR_ERR_DOMAIN_LAST,
   Firewall,
 
   Polkit, /* 60 */
+  Thread jobs,
 )
 
 
diff --git a/src/util/virthreadjob.c b/src/util/virthreadjob.c
new file mode 100644
index 000..2f483f9
--- /dev/null
+++ b/src/util/virthreadjob.c
@@ -0,0 +1,126 @@
+/*
+ * virthreadjob.c: code for tracking job associated with current thread
+ *
+ * Copyright (C) 2013-2015 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
+ * http://www.gnu.org/licenses/.
+ *
+ * Author: Jiri Denemark jdene...@redhat.com
+ */
+
+#include config.h
+
+#include internal.h
+#include virerror.h
+#include virlog.h
+#include virthread.h
+#include virthreadjob.h
+
+#define VIR_FROM_THIS VIR_FROM_THREAD
+VIR_LOG_INIT(util.threadjob);
+
+virThreadLocal virThreadJobWorker;
+virThreadLocal virThreadJobName;
+
+
+static int
+virThreadJobOnceInit(void)
+{
+if (virThreadLocalInit(virThreadJobWorker, NULL)  0 ||
+virThreadLocalInit(virThreadJobName, NULL)  0)
+return -1;
+return 0;
+}
+

[libvirt] [PATCH 6/8] Set thread job for every RPC call

2015-03-23 Thread Jiri Denemark
Since all APIs are also RPC calls, we automatically get all APIs covered
with thread jobs.

Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 daemon/remote.c| 1 +
 src/locking/lock_daemon_dispatch.c | 1 +
 src/qemu/qemu_domain.c | 1 +
 src/rpc/gendispatch.pl | 6 +-
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 62a4728..ea7ae94 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -51,6 +51,7 @@
 #include viraccessapicheck.h
 #include viraccessapicheckqemu.h
 #include virpolkit.h
+#include virthreadjob.h
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
diff --git a/src/locking/lock_daemon_dispatch.c 
b/src/locking/lock_daemon_dispatch.c
index 168a6af..a7cee9d 100644
--- a/src/locking/lock_daemon_dispatch.c
+++ b/src/locking/lock_daemon_dispatch.c
@@ -29,6 +29,7 @@
 #include lock_daemon.h
 #include lock_protocol.h
 #include virerror.h
+#include virthreadjob.h
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 949bf8b..559400c 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -39,6 +39,7 @@
 #include virtime.h
 #include virstoragefile.h
 #include virstring.h
+#include virthreadjob.h
 
 #include storage/storage_driver.h
 
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 8b488eb..aa73d0c 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -428,8 +428,10 @@ elsif ($mode eq server) {
 print void *args$argann,\n;
 print void *ret$retann)\n;
 print {\n;
+print   int rv;\n;
+print   virThreadJobSet(\$name\);\n;
 print   VIR_DEBUG(\server=%p client=%p msg=%p rerr=%p args=%p 
ret=%p\, server, client, msg, rerr, args, ret);\n;
-print   return $name(server, client, msg, rerr;
+print   rv = $name(server, client, msg, rerr;
 if ($argtype ne void) {
 print , args;
 }
@@ -437,6 +439,8 @@ elsif ($mode eq server) {
 print , ret;
 }
 print );\n;
+print   virThreadJobClear(rv);\n;
+print   return rv;\n;
 print }\n;
 
 # Finally we print out the dispatcher method body impl
-- 
2.3.3

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


Re: [libvirt] [PATCH] Fix typo in error message

2015-03-23 Thread Eric Blake
On 03/23/2015 06:12 AM, Pavel Hrdina wrote:
 On Mon, Mar 23, 2015 at 12:29:42PM +0100, Ján Tomko wrote:
 
 Just a question: where is the typo mentioned in $subject?
 
 by rewriting it completely from:
 error: unsupported configuration: virtio only support device address
 type 'PCI'

'support' should have been 'supports'

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



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

[libvirt] [PATCH] qemu: Don't return memory device config on error in qemuBuildMemoryBackendStr

2015-03-23 Thread Peter Krempa
In the last section if the function determines that the config is
invalid when QEMU doesn't support the memory device the JSON config
object would be returned even if it doesn't make sense.

Assign the object to be returned only on success.
---
 src/qemu/qemu_command.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 63d43d4..04e7bcc 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4750,9 +4750,6 @@ qemuBuildMemoryBackendStr(unsigned long long size,
 goto cleanup;
 }

-*backendProps = props;
-props = NULL;
-
 if (!hugepage) {
 bool nodeSpecified = virDomainNumatuneNodeSpecified(def-numa, 
guestNode);

@@ -4767,11 +4764,15 @@ qemuBuildMemoryBackendStr(unsigned long long size,
 /* report back that using the new backend is not necessary to achieve
  * the desired configuration */
 if (!userNodeset  !nodeSpecified) {
+*backendProps = props;
+props = NULL;
 ret = 1;
 goto cleanup;
 }
 }

+*backendProps = props;
+props = NULL;
 ret = 0;

  cleanup:
-- 
2.2.2

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


Re: [libvirt] lifecycle: shutdown: should it have timeout when using qemu-agent?

2015-03-23 Thread Michal Privoznik
On 23.03.2015 10:31, zhang bo wrote:
 The problem we encountered is:
 1) use qemu-agent to shutdown a domain.
 2) libvirt will block in qemuAgentShutdown(), if the domain itself got 
 stucked when it powers-off.
 
 It's the *guest domain*'s fault that it stucks when shutdown. However, we 
 could not handle the domain in libvirt anymore, except for the jobs such as 
 DESTROY or QUERY.
 
 So, here comes the question:
 What's the normal solution to this problem? shall we:
 1) use DESTROY to forcelly poweroff the domain, in openstack or other 
 applications that uses libvirt.

Yes, this is preferred way. Even for other APIs that talk either to a
monitor or a guest agent.

Michal

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


Re: [libvirt] [PATCH] qemu: Set default SCSI controller model for S390 arch

2015-03-23 Thread Michal Privoznik
On 20.03.2015 16:01, Boris Fiuczynski wrote:
 When no model is specified in the domain definition for
 a scsi controller and the architectur is s390 than virtio-scsi
 is set as default model.
 
 Signed-off-by: Boris Fiuczynski fiu...@linux.vnet.ibm.com
 Reviewed-by: Daniel Hansel daniel.han...@linux.vnet.ibm.com
 Reviewed-by: Stefan Zimmermann s...@linux.vnet.ibm.com
 ---
  src/qemu/qemu_domain.c | 7 +++
  1 file changed, 7 insertions(+)
 
 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
 index 41d1263..949bf8b 100644
 --- a/src/qemu/qemu_domain.c
 +++ b/src/qemu/qemu_domain.c
 @@ -1148,6 +1148,13 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
  ARCH_IS_S390(def-os.arch))
  dev-data.controller-model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE;
  
 +/* set the default SCSI controller model for S390 arches */
 +if (dev-type == VIR_DOMAIN_DEVICE_CONTROLLER 
 +dev-data.controller-type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI 
 +dev-data.controller-model == -1 
 +ARCH_IS_S390(def-os.arch))
 +dev-data.controller-model = 
 VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI;
 +
  /* auto generate unix socket path */
  if (dev-type == VIR_DOMAIN_DEVICE_CHR 
  dev-data.chr-deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL 
 

ACKed and pushed.

Michal

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


[libvirt] [PATCH] Fix typo in error message

2015-03-23 Thread Ján Tomko
by rewriting it completely from:
error: unsupported configuration: virtio only support device address
type 'PCI'

to:

error: unsupported configuration: virtio disk cannot have an address of type
drive

Since we now support CCW addresses as well.
---
 src/qemu/qemu_command.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 63d43d4..a747eb4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2423,8 +2423,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
 continue;
 
 if (def-disks[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(virtio only support device address type 'PCI'));
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(virtio disk cannot have an address of type %s),
+   
virDomainDeviceAddressTypeToString(def-disks[i]-info.type));
 goto error;
 }
 
-- 
2.0.5

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


Re: [libvirt] [PATCH] conf: fix running vm numa settings disappear after restart libvirtd

2015-03-23 Thread Luyao Huang


On 03/23/2015 06:10 PM, Peter Krempa wrote:

On Thu, Mar 19, 2015 at 18:13:04 +0800, Luyao Huang wrote:

5bba61f introduce a issue : when start a vm with numa settings and
restart libvirtd, numa settings will disappear. Because when parse the
vm states file, there is no node in /domain/cpu/numa this place.

Change to use ./cpu/numa instead of /domain/cpu/numa.

Signed-off-by: Luyao Huang lhu...@redhat.com
---
  src/conf/numa_conf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Indeed the status XML wraps the  domain element with another container
element.


Yes, i just didn't know how to describe it in a right way when i wrote 
this :)



diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
index b92cb44..c34ba5f 100644
--- a/src/conf/numa_conf.c
+++ b/src/conf/numa_conf.c
@@ -663,10 +663,10 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
  int ret = -1;
  
  /* check if NUMA definition is present */

-if (!virXPathNode(/domain/cpu/numa[1], ctxt))
+if (!virXPathNode(./cpu/numa[1], ctxt))
  return 0;
  
-if ((n = virXPathNodeSet(/domain/cpu/numa[1]/cell, ctxt, nodes)) = 0) {

+if ((n = virXPathNodeSet(./cpu/numa[1]/cell, ctxt, nodes)) = 0) {
  virReportError(VIR_ERR_XML_ERROR, %s,
 _(NUMA topology defined without NUMA cells));
  goto cleanup;
--

ACK, I'll push your patch after I figure out how to add tests for
problems like this.


Thanks for your review.



Peter


Luyao

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


Re: [libvirt] [PATCH 8/9] libxl: pass cmdline to HVM guests

2015-03-23 Thread Ian Campbell
On Fri, 2015-03-20 at 22:13 +0100, Marek Marczykowski-Górecki wrote:
 I'll definitely do. But above raises a question - how can I set extra
 arguments for qemu? In case of qemu in dom0, it's not a problem because
 I can create some wrapper script. But in case of qemu in stubdom, the
 only way is to set b_info-extra_hvm. Some additional attributes for
 emulator tag?

There are several components, please can you be precise about which you
want to pass something to.

1. qemu process command line in dom0 (used e.g. for pv backends)
2. command line of the stubdom pv kernel itself
3. qemu process command line in stubdom
4. kernel command line in dom0

It's possible that libxl doesn't fully expose all 4 of those. I'm not
sure if #2 is actually useful but it seems like we would certainly want
to be able to expose the other 3 if possible.

b_info-cmdline should be #4, I'm pretty sure.

We also have b_info-extra, -extra_pv and -extra_hvm, but I'm not
entirely sure how these map onto #1 and #3.

I'm reasonably sure that -extra maps to _both_ #1 and #3. It would seem
logical enough if -extra_hvm mapped to #3 and -extra_pv mapped to #1,
but I don't know if it actually works that way. It would probably be
quickest to confirm empirically.

With that I'll leave the mapping into livirt xml to others ;-)

Ian.


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

Re: [libvirt] [PATCH] Fix typo in error message

2015-03-23 Thread Pavel Hrdina
On Mon, Mar 23, 2015 at 12:29:42PM +0100, Ján Tomko wrote:

Just a question: where is the typo mentioned in $subject?

 by rewriting it completely from:
 error: unsupported configuration: virtio only support device address
 type 'PCI'
 
 to:
 
 error: unsupported configuration: virtio disk cannot have an address of type
 drive
 
 Since we now support CCW addresses as well.
 ---
  src/qemu/qemu_command.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 63d43d4..a747eb4 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -2423,8 +2423,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
  continue;
  
  if (def-disks[i]-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) 
 {
 -virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 -   _(virtio only support device address type 
 'PCI'));
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   _(virtio disk cannot have an address of type 
 %s),

I would wrap the %s with single quote '.

 +   
 virDomainDeviceAddressTypeToString(def-disks[i]-info.type));
  goto error;
  }
  
 -- 
 2.0.5
 

ACK

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

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

[libvirt] lifecycle: shutdown: should it have timeout when using qemu-agent?

2015-03-23 Thread zhang bo
The problem we encountered is:
1) use qemu-agent to shutdown a domain.
2) libvirt will block in qemuAgentShutdown(), if the domain itself got 
stucked when it powers-off.

It's the *guest domain*'s fault that it stucks when shutdown. However, we could 
not handle the domain in libvirt anymore, except for the jobs such as DESTROY 
or QUERY.

So, here comes the question:
What's the normal solution to this problem? shall we:
1) use DESTROY to forcelly poweroff the domain, in openstack or other 
applications that uses libvirt.
or
2) leave it to the administrator users, if they find this problem, let them 
manually DESTROY the domain.
or
3) let SHUTDOWN timeout in libvirt when the guest domain got stucked.

Looking forward to your reply, thanks in advance.

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


Re: [libvirt] [PATCH] qemu: skip precreation of network disks

2015-03-23 Thread Michal Privoznik
On 13.03.2015 01:34, Michael Chapman wrote:
 Commit cf54c60699833b3791a5d0eb3eb5a1948c267f6b introduced the ability
 to create missing storage volumes during migration. For network disks,
 however, we may not necessarily be able to detect whether they already
 exist -- there is no straight-forward way to map the disk to a storage
 volume, and even if there were it's possible no configured storage pool
 actually contains the disk.
 
 It is better to assume the network disk exists in this case, rather than
 aborting the migration completely. If the volume really is missing, QEMU
 will generate an appropriate error later in the migration.
 
 Signed-off-by: Michael Chapman m...@very.puzzling.org
 ---
  src/qemu/qemu_migration.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)
 
 diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
 index 83be435..ebe8af5 100644
 --- a/src/qemu/qemu_migration.c
 +++ b/src/qemu/qemu_migration.c
 @@ -1507,9 +1507,13 @@ qemuMigrationPrecreateDisk(virConnectPtr conn,
  flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
  break;
  
 +case VIR_STORAGE_TYPE_NETWORK:
 +VIR_DEBUG(Skipping creation of network disk '%s',
 +  disk-dst);
 +return 0;
 +
  case VIR_STORAGE_TYPE_BLOCK:
  case VIR_STORAGE_TYPE_DIR:
 -case VIR_STORAGE_TYPE_NETWORK:
  case VIR_STORAGE_TYPE_NONE:
  case VIR_STORAGE_TYPE_LAST:
  virReportError(VIR_ERR_INTERNAL_ERROR,
 

Yeah, I don't see a better way of handling network disks right now.
ACKed and pushed.

Michal

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


[libvirt] [PATCH] hostdev: fix two bugs in virHostdevReAttachPCIDevices

2015-03-23 Thread Huanle Han
Bug 1: The the next element in the pcidevs is skipped after we
virPCIDeviceListDel the previous element.

Bug 2: virHostdevNetConfigRestore is called for store the hostdevs
which may be used by other domain.

Signed-off-by: Huanle Han hanxue...@gmail.com
---
 src/util/virhostdev.c | 25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c
index 9678e2b..ecbe5d8 100644
--- a/src/util/virhostdev.c
+++ b/src/util/virhostdev.c
@@ -785,7 +785,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr
hostdev_mgr,
  * them and reset all the devices before re-attach.
  * Attach mac and port profile parameters to devices
  */
-for (i = 0; i  virPCIDeviceListCount(pcidevs); i++) {
+for (i = 0; i  virPCIDeviceListCount(pcidevs);) {
 virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
 virPCIDevicePtr activeDev = NULL;

@@ -806,6 +806,7 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr
hostdev_mgr,
 }

 virPCIDeviceListDel(hostdev_mgr-activePCIHostdevs, dev);
+i++;
 }

 /* At this point, any device that had been used by the guest is in
@@ -816,9 +817,25 @@ virHostdevReAttachPCIDevices(virHostdevManagerPtr
hostdev_mgr,
  * For SRIOV net host devices, unset mac and port profile before
  * reset and reattach device
  */
-for (i = 0; i  nhostdevs; i++)
-virHostdevNetConfigRestore(hostdevs[i], hostdev_mgr-stateDir,
-   oldStateDir);
+for (i = 0; i  nhostdevs; i++) {
+virPCIDevicePtr dev;
+virDomainHostdevDefPtr hostdev = hostdevs[i];
+virDomainHostdevSubsysPCIPtr pcisrc =
hostdev-source.subsys.u.pci;
+
+if (hostdev-mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
+hostdev-source.subsys.type !=
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI ||
+hostdev-parent.type != VIR_DOMAIN_DEVICE_NET ||
+!hostdev-parent.data.net)
+continue;
+
+dev = virPCIDeviceNew(pcisrc-addr.domain, pcisrc-addr.bus,
+  pcisrc-addr.slot, pcisrc-addr.function);
+if (virPCIDeviceListFind(pcidevs, dev)) {
+virHostdevNetConfigRestore(hostdev, hostdev_mgr-stateDir,
+   oldStateDir);
+}
+virPCIDeviceFree(dev);
+   }

 for (i = 0; i  virPCIDeviceListCount(pcidevs); i++) {
 virPCIDevicePtr dev = virPCIDeviceListGet(pcidevs, i);
-- 
2.1.0
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: Don't return memory device config on error in qemuBuildMemoryBackendStr

2015-03-23 Thread Peter Krempa
On Mon, Mar 23, 2015 at 09:41:23 -0400, John Ferlan wrote:
 
 
 On 03/23/2015 09:23 AM, Peter Krempa wrote:
  In the last section if the function determines that the config is
  invalid when QEMU doesn't support the memory device the JSON config
  object would be returned even if it doesn't make sense.
  
  Assign the object to be returned only on success.
  ---
   src/qemu/qemu_command.c | 7 ---
   1 file changed, 4 insertions(+), 3 deletions(-)
  
 
 ACK

Pushed; Thanks.

Peter


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

Re: [libvirt] [PATCHv3 10/12] qemu: conf: Add support for memory device cold(un)plug

2015-03-23 Thread Peter Krempa
On Fri, Mar 20, 2015 at 07:40:21 -0400, John Ferlan wrote:
 
  I have tested your series with our qemu memory hot remove patch series,
  here would be a possible error.
 
  When hotplug a memory device, its size has been aligned. So the
  compare for
  size here would fail possiblely.
 
  hmm.. Not sure that's necessary - although Peter can make the final
  determination... Commit id '57b215a' doesn't modify each def-mems[i]
  entry in qemuDomainAlignMemorySizes, rather it gets a value from
  virDomainDefSetMemoryInitial and then does the rounding.
 
  If the stored def-mems[i]-size value is/was modified, then I'd agree,
  but it doesn't appear to be that way.
 
  If there is a rounding of the value - then please just point it out
  
  Yes, the stored def-mems[i]-size value was modified.
  If you assign the size 524287 KiB, the stored value will be 524288.
  
  Thanks,
  Zhu
  
 
 Ah - found it - patch 9 has:
 
 +/* Align memory module sizes */
 +for (i = 0; i  def-nmems; i++)
 +qemuDomainMemoryDeviceAlignSize(def-mems[i]);
 +
 
 Which I missed on my first foray through this. Once I cscope'd on
 VIR_ROUND_UP() instead of -size, it became apparent
 
 So yes, it seems the to be compared size needs a likewise adjustment.

Indeed, but the size needs to be aligned only for the active definition
as we only align that one, thus it belongs to patch 12/12.

I'll be adding the following diff to 12/12:

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 40041d5..9b8d11b 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -4189,6 +4189,8 @@ qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
 return -1;
 }

+qemuDomainMemoryDeviceAlignSize(memdef);
+
 if ((idx = virDomainMemoryFindByDef(vm-def, memdef))  0) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
_(device not present in domain configuration));

Peter



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

Re: [libvirt] [PATCHv3 00/12] Add support for memory hotplug

2015-03-23 Thread Peter Krempa
On Thu, Mar 19, 2015 at 18:41:31 -0400, John Ferlan wrote:
 
 
 On 03/17/2015 10:19 AM, Peter Krempa wrote:
  This version includes review feedback changes from John and also fixes the
  memory element documentation and code that calculates it to support 
  possible 
  non-NUMA configs with memory hotplug if any hypervisor would support that 
  in the
  future.
  
  Peter Krempa (12):
qemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject
libxl: Refactor logic in domain post parse callback
conf: Add support for parsing and formatting max memory and slot count
qemu: Implement setup of memory hotplug parameters
conf: Add device address type for dimm devices
conf: Add interface to parse and format memory device information
qemu: memdev: Add infrastructure to load memory device information
qemu: migration: Forbid migration with memory modules lacking info
qemu: add support for memory devices
qemu: conf: Add support for memory device cold(un)plug
qemu: Implement memory device hotplug
qemu: Implement memory device hotunplug

...

  
   38 files changed, 1747 insertions(+), 31 deletions(-)
   create mode 100644 tests/domainschemadata/maxMemory.xml
   create mode 100644 
  tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.args
   create mode 100644 
  tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml
   create mode 100644 
  tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
   create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.args
   create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.xml
  
 
 ACK series with adjustments noted in patches 9  11 and of course the
 assurance about patch 10.

I've fixed all the points and pushed the series.

Thanks for reviewing these unpleasant amounts of code.

Peter


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

Re: [libvirt] [Xen-devel] [PATCH] libxl: fix dom0 balloon logic

2015-03-23 Thread Ian Campbell
(just ccing the other tools maintainers, in particular Stefano who knows
what this stuff is supposed to do...)

On Fri, 2015-03-20 at 17:10 -0600, Jim Fehlig wrote:
 Recent testing on large memory systems revealed a bug in the Xen xl
 tool's freemem() function.  When autoballooning is enabled, freemem()
 is used to ensure enough memory is available to start a domain,
 ballooning dom0 if necessary.  When ballooning large amounts of memory
 from dom0, freemem() would exceed its self-imposed wait time and
 return an error.  Meanwhile, dom0 continued to balloon.  Starting the
 domain later, after sufficient memory was ballooned from dom0, would
 succeed.  The libvirt implementation in libxlDomainFreeMem() suffers
 the same bug since it is modeled after freemem().
 
 In the end, the best place to fix the bug on the Xen side was to
 slightly change the behavior of libxl_wait_for_memory_target().
 Instead of failing after caller-provided wait_sec, the function now
 blocks as long as dom0 memory ballooning is progressing.  It will return
 failure only when more memory is needed to reach the target and wait_sec
 have expired with no progress being made.  See xen.git commit fd3aa246.
 There was a dicussion on how this would affect other libxl apps like
 libvirt
 
 http://lists.xen.org/archives/html/xen-devel/2015-03/msg00739.html
 
 If libvirt containing this patch was build against a Xen containing
 the old libxl_wait_for_memory_target() behavior, libxlDomainFreeMem()
 will fail after 30 sec and domain creation will be terminated.
 Without this patch and with old libxl_wait_for_memory_target() behavior,
 libxlDomainFreeMem() does not succeed after 30 sec, but returns success
 anyway.  Domain creation continues resulting in all sorts of fun stuff
 like cpu soft lockups in the guest OS.  It was decided to properly fix
 libxl_wait_for_memory_target(), and if anything improve the default
 behavior of apps using the freemem reference impl in xl.
 
 xl was patched to accommodate the change in libxl_wait_for_memory_target()
 with xen.git commit 883b30a0.  This patch does the same in the libxl
 driver.  While at it, I changed the logic to essentially match
 freemem() in $xensrc/tools/libxl/xl_cmdimpl.c.  It was a bit cleaner
 IMO and will make it easier to spot future, potentially interesting
 divergences.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_domain.c | 57 
 
  1 file changed, 28 insertions(+), 29 deletions(-)
 
 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
 index 407a9bd..ff78133 100644
 --- a/src/libxl/libxl_domain.c
 +++ b/src/libxl/libxl_domain.c
 @@ -1121,38 +1121,41 @@ libxlDomainFreeMem(libxlDomainObjPrivatePtr priv, 
 libxl_domain_config *d_config)
  {
  uint32_t needed_mem;
  uint32_t free_mem;
 -size_t i;
 -int ret = -1;
 +int ret;
  int tries = 3;
  int wait_secs = 10;
  
 -if ((ret = libxl_domain_need_memory(priv-ctx, d_config-b_info,
 -needed_mem)) = 0) {
 -for (i = 0; i  tries; ++i) {
 -if ((ret = libxl_get_free_memory(priv-ctx, free_mem))  0)
 -break;
 +ret = libxl_domain_need_memory(priv-ctx, d_config-b_info,
 +   needed_mem);
 +if (ret  0)
 +goto error;
  
 -if (free_mem = needed_mem) {
 -ret = 0;
 -break;
 -}
 +do {
 +ret = libxl_get_free_memory(priv-ctx, free_mem);
 +if (ret  0)
 +goto error;
  
 -if ((ret = libxl_set_memory_target(priv-ctx, 0,
 -   free_mem - needed_mem,
 -   /* relative */ 1, 0))  0)
 -break;
 +if (free_mem = needed_mem)
 +return 0;
  
 -ret = libxl_wait_for_free_memory(priv-ctx, 0, needed_mem,
 - wait_secs);
 -if (ret == 0 || ret != ERROR_NOMEM)
 -break;
 +ret = libxl_set_memory_target(priv-ctx, 0,
 +  free_mem - needed_mem,
 +  /* relative */ 1, 0);
 +if (ret  0)
 +goto error;
  
 -if ((ret = libxl_wait_for_memory_target(priv-ctx, 0, 1))  0)
 -break;
 -}
 -}
 +ret = libxl_wait_for_free_memory(priv-ctx, 0, needed_mem,
 + wait_secs);
 +if (ret  0)
 +goto error;
  
 -return ret;
 +tries--;
 +} while (tries  0);
 +
 + error:
 +virReportSystemError(ret, %s,
 + _(Failed to balloon domain0 memory));
 +return -1;
  }
  
  static void
 @@ -1271,12 +1274,8 @@ libxlDomainStart(libxlDriverPrivatePtr driver, 
 virDomainObjPtr vm,
 priv-ctx, d_config)  0)
  

Re: [libvirt] [PATCHv2 3/5] Allocate virtio-serial addresses when starting a domain

2015-03-23 Thread John Ferlan


On 03/17/2015 07:41 AM, Ján Tomko wrote:
 Instead of always using controller 0 and incrementing port number,
 respect the maximum port numbers of controllers and use all of them.
 
 Ports for virtio consoles are quietly reserved, but not formatted
 (neither in XML nor on QEMU command line).
 
 Also rejects duplicate virtio-serial addresses.
 https://bugzilla.redhat.com/show_bug.cgi?id=890606
 https://bugzilla.redhat.com/show_bug.cgi?id=1076708
 ---
  src/conf/domain_conf.c | 29 --
  src/qemu/qemu_command.c| 63 
 ++
  src/qemu/qemu_domain.c |  1 +
  src/qemu/qemu_domain.h |  1 +
  src/qemu/qemu_process.c|  2 +
  .../qemuxml2argv-channel-virtio-auto.args  |  8 +--
  .../qemuxml2argv-channel-virtio-autoassign.args| 10 ++--
  .../qemuxml2xmlout-channel-virtio-auto.xml | 10 ++--
  8 files changed, 81 insertions(+), 43 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index c75b543..89357d2 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -3402,21 +3402,6 @@ 
 virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
  
  chr-target.port = maxport + 1;
  }
 -
 -if (chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
 -chr-info.addr.vioserial.port == 0) {
 -int maxport = 0;
 -
 -for (i = 0; i  cnt; i++) {
 -const virDomainChrDef *thischr = arrPtr[i];
 -if (thischr-info.type == 
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
 -thischr-info.addr.vioserial.controller == 
 chr-info.addr.vioserial.controller 
 -thischr-info.addr.vioserial.bus == 
 chr-info.addr.vioserial.bus 
 -(int)thischr-info.addr.vioserial.port  maxport)
 -maxport = thischr-info.addr.vioserial.port;
 -}
 -chr-info.addr.vioserial.port = maxport + 1;
 -}
  }
  
  /* set default path for virtio-rng random backend to /dev/random */
 @@ -14526,20 +14511,6 @@ virDomainDefParseXML(xmlDocPtr xml,
  chr-targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO 
  chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
  chr-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL;
 -
 -if (chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
 -chr-info.addr.vioserial.port == 0) {
 -int maxport = 0;
 -for (j = 0; j  i; j++) {
 -virDomainChrDefPtr thischr = def-channels[j];
 -if (thischr-info.type == 
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
 -thischr-info.addr.vioserial.controller == 
 chr-info.addr.vioserial.controller 
 -thischr-info.addr.vioserial.bus == 
 chr-info.addr.vioserial.bus 
 -(int)thischr-info.addr.vioserial.port  maxport)
 -maxport = thischr-info.addr.vioserial.port;
 -}
 -chr-info.addr.vioserial.port = maxport + 1;
 -}
  }
  VIR_FREE(nodes);
  
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 02105c3..e7f86e1 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -1399,6 +1399,65 @@ qemuAssignSpaprVIOAddress(virDomainDefPtr def, 
 virDomainDeviceInfoPtr info,
  return 0;
  }
  
 +
 +static int
 +qemuDomainAssignVirtioSerialAddresses(virDomainDefPtr def,
 +  virDomainObjPtr obj)
 +{
 +int ret = -1;
 +size_t i;
 +virDomainVirtioSerialAddrSetPtr addrs = NULL;
 +qemuDomainObjPrivatePtr priv = NULL;
 +
 +if (!(addrs = virDomainVirtioSerialAddrSetCreate()))
 +goto cleanup;

Coverity determines addrs != NULL, but

 +
 +if (virDomainVirtioSerialAddrSetAddControllers(addrs, def)  0)
 +goto cleanup;
 +
 +if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve,
 +   addrs)  0)
 +goto cleanup;
 +
 +VIR_DEBUG(Finished reserving existing ports);
 +
 +for (i = 0; i  def-nconsoles; i++) {
 +virDomainChrDefPtr chr = def-consoles[i];
 +if (chr-deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE 
 +chr-targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
 +if (virDomainVirtioSerialAddrAssign(addrs, chr-info, true)  0)
 +goto cleanup;
 +}
 +}
 +
 +for (i = 0; i  def-nchannels; i++) {
 +virDomainChrDefPtr chr = def-channels[i];
 +if (chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
 +chr-info.addr.vioserial.port == 0 
 +virDomainVirtioSerialAddrAssign(addrs, chr-info, false)  0)
 +goto cleanup;
 +}
 +
 +if (obj  obj-privateData) {
 

[libvirt] [PATCH 0/4] util: use netlink to create bridge devices

2015-03-23 Thread Laine Stump
This patch series comes out of a comment in:

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

that pointed out that sioctl(SIOCBRDELBR) won't delete a bridge
interface if it is IFF_UP, but the netlink RTM_DELLINK message doesn't
care - it will delete it anyway. In these patches we switch to using
RTM_DELLINK to avoid failures caused by a bridge interface that is
IFF_UP.

Laine Stump (4):
  util: netlink function to delete any network device
  util: replace body of virNetDevMacVLanDelete() with
virNetlinkDelLink()
  util: use netlink to delete bridge devices
  util: use netlink to create bridge devices

 src/libvirt_private.syms|  1 +
 src/util/virnetdevbridge.c  | 90 +++--
 src/util/virnetdevmacvlan.c | 67 +
 src/util/virnetlink.c   | 89 
 src/util/virnetlink.h   |  3 +-
 5 files changed, 181 insertions(+), 69 deletions(-)

-- 
2.1.0

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


[libvirt] [PATCH 1/4] util: netlink function to delete any network device

2015-03-23 Thread Laine Stump
libvirt has always used the netlink RTM_DELLINK message to delete
macvtap/macvlan devices, but it can actually be used to delete other
types of network devices, such as bonds and bridges. This patch makes
virNetDevMacVLanDelete() available as a generic function so it can
intelligibly be called to delete these other types of interfaces.
---
 src/libvirt_private.syms |  1 +
 src/util/virnetlink.c| 89 
 src/util/virnetlink.h|  3 +-
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ca3520d..631edf3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1805,6 +1805,7 @@ virNetDevVPortProfileOpTypeToString;
 
 # util/virnetlink.h
 virNetlinkCommand;
+virNetlinkDelLink;
 virNetlinkEventAddClient;
 virNetlinkEventRemoveClient;
 virNetlinkEventServiceIsRunning;
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index d52f66a..86c9c9c 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -277,6 +277,87 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
 }
 
 
+/**
+ * virNetlinkDelLink:
+ *
+ * @ifname: Name of the link
+ *
+ * delete a network link (aka interface aka device) with the given
+ * name. This works for many different types of network devices,
+ * including macvtap and bridges.
+ *
+ * Returns 0 on success, -1 on fatal error.
+ */
+int
+virNetlinkDelLink(const char *ifname)
+{
+int rc = -1;
+struct nlmsghdr *resp = NULL;
+struct nlmsgerr *err;
+struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
+unsigned int recvbuflen;
+struct nl_msg *nl_msg;
+
+nl_msg = nlmsg_alloc_simple(RTM_DELLINK,
+NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
+if (!nl_msg) {
+virReportOOMError();
+return -1;
+}
+
+if (nlmsg_append(nl_msg,  ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO)  0)
+goto buffer_too_small;
+
+if (nla_put(nl_msg, IFLA_IFNAME, strlen(ifname)+1, ifname)  0)
+goto buffer_too_small;
+
+if (virNetlinkCommand(nl_msg, resp, recvbuflen, 0, 0,
+  NETLINK_ROUTE, 0)  0) {
+goto cleanup;
+}
+
+if (recvbuflen  NLMSG_LENGTH(0) || resp == NULL)
+goto malformed_resp;
+
+switch (resp-nlmsg_type) {
+case NLMSG_ERROR:
+err = (struct nlmsgerr *)NLMSG_DATA(resp);
+if (resp-nlmsg_len  NLMSG_LENGTH(sizeof(*err)))
+goto malformed_resp;
+
+if (err-error) {
+virReportSystemError(-err-error,
+ _(error destroying network device %s),
+ ifname);
+goto cleanup;
+}
+break;
+
+case NLMSG_DONE:
+break;
+
+default:
+goto malformed_resp;
+}
+
+rc = 0;
+ cleanup:
+nlmsg_free(nl_msg);
+VIR_FREE(resp);
+return rc;
+
+ malformed_resp:
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(malformed netlink response message));
+goto cleanup;
+
+ buffer_too_small:
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(allocated netlink buffer is too small));
+goto cleanup;
+}
+
+
 int
 virNetlinkGetErrorCode(struct nlmsghdr *resp, unsigned int recvbuflen)
 {
@@ -803,6 +884,14 @@ int virNetlinkCommand(struct nl_msg *nl_msg 
ATTRIBUTE_UNUSED,
 return -1;
 }
 
+
+int
+virNetlinkDelLink(const char *ifname ATTRIBUTE_UNSUPPORTED)
+{
+virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(unsupported));
+return -1;
+}
+
 /**
  * stopNetlinkEventServer: stop the monitor to receive netlink
  * messages for libvirtd
diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h
index 1a3e06d..06c3cd0 100644
--- a/src/util/virnetlink.h
+++ b/src/util/virnetlink.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-2013, 2015 Red Hat, Inc.
  * Copyright (C) 2010-2012 IBM Corporation
  *
  * This library is free software; you can redistribute it and/or
@@ -51,6 +51,7 @@ int virNetlinkCommand(struct nl_msg *nl_msg,
   struct nlmsghdr **resp, unsigned int *respbuflen,
   uint32_t src_pid, uint32_t dst_pid,
   unsigned int protocol, unsigned int groups);
+int virNetlinkDelLink(const char *ifname);
 
 int virNetlinkGetErrorCode(struct nlmsghdr *resp, unsigned int recvbuflen);
 
-- 
2.1.0

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


[libvirt] [PATCH 4/4] util: use netlink to create bridge devices

2015-03-23 Thread Laine Stump
Just as it is possible to delete a bridge device with the netlink
RTM_DELLINK message, one can be created with the RTM_NEWLINK
message. Because of differences in the format of the message, it's not
as straightforward as with virNetlinkDelLink() to create a single
utility function that can be used to create any type of interface, so
the new netlink version of virNetDevBridgeCreate() does its own
construction of the netlink message and calls virNetlinkCommand()
itself.

This doesn't provide any extra functionality, just provides symmetry
with the previous commit.

NB: We *could* alter the API of virNetDevBridgeCreate() to take a MAC
address, and directly program that mac address into the bridge (by
adding an IFLA_ADDRESS attribute, as is done in
virNetDevMacVLanCreate()) rather than separately creating the dummy
tap (e.g. virbr0-nic) to maintain a fixed mac address on the bridge,
but the commit history of virnetdevbridge.c shows that the presence of
this dummy tap is essential in some older versions of the kernel
(between 2.6.39 and 3.1 or 3.2, possibly?) to proper operation of IPv6
DAD, and I don't want to take the chance of breaking something that I
don't have the time/setup to test (my RHEL6 box is at kernel
2.6.32-544, and the next lowest kernel I have is 3.17)
---
 src/util/virnetdevbridge.c | 78 +-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 2bad40a..6be8aa3 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -395,7 +395,83 @@ virNetDevBridgePortSetUnicastFlood(const char *brname 
ATTRIBUTE_UNUSED,
  *
  * Returns 0 in case of success or -1 on failure
  */
-#if defined(HAVE_STRUCT_IFREQ)  defined(SIOCBRADDBR)
+#if defined(__linux__)  defined(HAVE_LIBNL)
+int virNetDevBridgeCreate(const char *brname)
+{
+/* use a netlink RTM_NEWLINK message to create the bridge */
+const char *type = bridge;
+int rc = -1;
+struct nlmsghdr *resp = NULL;
+struct nlmsgerr *err;
+struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
+unsigned int recvbuflen;
+struct nl_msg *nl_msg;
+struct nlattr *linkinfo;
+
+nl_msg = nlmsg_alloc_simple(RTM_NEWLINK,
+NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
+if (!nl_msg) {
+virReportOOMError();
+return -1;
+}
+
+if (nlmsg_append(nl_msg,  ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO)  0)
+goto buffer_too_small;
+if (nla_put(nl_msg, IFLA_IFNAME, strlen(brname)+1, brname)  0)
+goto buffer_too_small;
+if (!(linkinfo = nla_nest_start(nl_msg, IFLA_LINKINFO)))
+goto buffer_too_small;
+if (nla_put(nl_msg, IFLA_INFO_KIND, strlen(type), type)  0)
+goto buffer_too_small;
+nla_nest_end(nl_msg, linkinfo);
+
+if (virNetlinkCommand(nl_msg, resp, recvbuflen, 0, 0,
+  NETLINK_ROUTE, 0)  0) {
+goto cleanup;
+}
+
+if (recvbuflen  NLMSG_LENGTH(0) || resp == NULL)
+goto malformed_resp;
+
+switch (resp-nlmsg_type) {
+case NLMSG_ERROR:
+err = (struct nlmsgerr *)NLMSG_DATA(resp);
+if (resp-nlmsg_len  NLMSG_LENGTH(sizeof(*err)))
+goto malformed_resp;
+
+switch (err-error) {
+case 0:
+break;
+default:
+virReportSystemError(-err-error,
+ _(error creating bridge interface %s),
+ brname);
+goto cleanup;
+}
+break;
+
+case NLMSG_DONE:
+break;
+default:
+goto malformed_resp;
+}
+
+rc = 0;
+ cleanup:
+nlmsg_free(nl_msg);
+VIR_FREE(resp);
+return rc;
+
+ malformed_resp:
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(malformed netlink response message));
+goto cleanup;
+ buffer_too_small:
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(allocated netlink buffer is too small));
+goto cleanup;
+}
+#elif defined(HAVE_STRUCT_IFREQ)  defined(SIOCBRADDBR)
 int virNetDevBridgeCreate(const char *brname)
 {
 int fd = -1;
-- 
2.1.0

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


[libvirt] [PATCH 3/4] util: use netlink to delete bridge devices

2015-03-23 Thread Laine Stump
https://bugzilla.redhat.com/show_bug.cgi?id=1125755

reported that a stray bridge device was left on the system when a
libvirt network failed to start due to an illegal iptables rule caused
by bad config. Apparently the reason this was happening was that
NetworkManager was noticing immediately when the bridge device was
created and automatically setting it IFF_UP. libvirt would then try to
setup the iptables rules, get an error back, and since libvirt had
never IFF_UPed the bridge, it didn't expect that it needed to set it
~IFF_UP before deleting it during the cleanup process. But the
ioctl(SIOCBRDELBR) ioctl will fail to delete a bridge if it is IFF_UP.

Since that bug was reported, NetworkManager has gotten a bit more
polite in this respect, but just in case something similar happens in
the future, this patch switches to using the netlink RTM_DELLINK
message to delete the bridge - unlike SIOCBRDELBR, it will delete the
requested bridge no matter what the setting of IFF_UP.
---
 src/util/virnetdevbridge.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index d9dcc39..2bad40a 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2014 Red Hat, Inc.
+ * Copyright (C) 2007-2015 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
@@ -457,7 +457,15 @@ int virNetDevBridgeCreate(const char *brname)
  *
  * Returns 0 in case of success or an errno code in case of failure.
  */
-#if defined(HAVE_STRUCT_IFREQ)  defined(SIOCBRDELBR)
+#if defined(__linux__)  defined(HAVE_LIBNL)
+int virNetDevBridgeDelete(const char *brname)
+{
+/* If netlink is available, use it, as it is successful at
+ * deleting a bridge even if it is currently IFF_UP.
+ */
+return virNetlinkDelLink(brname);
+}
+#elif defined(HAVE_STRUCT_IFREQ)  defined(SIOCBRDELBR)
 int virNetDevBridgeDelete(const char *brname)
 {
 int fd = -1;
-- 
2.1.0

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


[libvirt] [PATCH 2/4] util: replace body of virNetDevMacVLanDelete() with virNetlinkDelLink()

2015-03-23 Thread Laine Stump
These two functions are identical, so no sense in having the
duplication. I resisted the temptation to replace calls to
virNetDevMacVLanDelete() with calls to virNetlinkDelLink() just in
case some mythical future platform has macvtap devices that aren't
managed with netlink (or in case we some day need to do more than just
tell the kernel to delete the device).
---
 src/util/virnetdevmacvlan.c | 67 ++---
 1 file changed, 2 insertions(+), 65 deletions(-)

diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index ec959a9..5fd2097 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2014 Red Hat, Inc.
+ * Copyright (C) 2010-2015 Red Hat, Inc.
  * Copyright (C) 2010-2012 IBM Corporation
  *
  * This library is free software; you can redistribute it and/or
@@ -220,70 +220,7 @@ virNetDevMacVLanCreate(const char *ifname,
  */
 int virNetDevMacVLanDelete(const char *ifname)
 {
-int rc = -1;
-struct nlmsghdr *resp = NULL;
-struct nlmsgerr *err;
-struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
-unsigned int recvbuflen;
-struct nl_msg *nl_msg;
-
-nl_msg = nlmsg_alloc_simple(RTM_DELLINK,
-NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL);
-if (!nl_msg) {
-virReportOOMError();
-return -1;
-}
-
-if (nlmsg_append(nl_msg,  ifinfo, sizeof(ifinfo), NLMSG_ALIGNTO)  0)
-goto buffer_too_small;
-
-if (nla_put(nl_msg, IFLA_IFNAME, strlen(ifname)+1, ifname)  0)
-goto buffer_too_small;
-
-if (virNetlinkCommand(nl_msg, resp, recvbuflen, 0, 0,
-  NETLINK_ROUTE, 0)  0) {
-goto cleanup;
-}
-
-if (recvbuflen  NLMSG_LENGTH(0) || resp == NULL)
-goto malformed_resp;
-
-switch (resp-nlmsg_type) {
-case NLMSG_ERROR:
-err = (struct nlmsgerr *)NLMSG_DATA(resp);
-if (resp-nlmsg_len  NLMSG_LENGTH(sizeof(*err)))
-goto malformed_resp;
-
-if (err-error) {
-virReportSystemError(-err-error,
- _(error destroying %s interface),
- ifname);
-goto cleanup;
-}
-break;
-
-case NLMSG_DONE:
-break;
-
-default:
-goto malformed_resp;
-}
-
-rc = 0;
- cleanup:
-nlmsg_free(nl_msg);
-VIR_FREE(resp);
-return rc;
-
- malformed_resp:
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(malformed netlink response message));
-goto cleanup;
-
- buffer_too_small:
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(allocated netlink buffer is too small));
-goto cleanup;
+return virNetlinkDelLink(ifname);
 }
 
 
-- 
2.1.0

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


Re: [libvirt] [PATCH] Fix common misspellings

2015-03-23 Thread Martin Kletzander

On Fri, Mar 20, 2015 at 09:51:23AM -0600, Eric Blake wrote:

On 03/20/2015 06:21 AM, Martin Kletzander wrote:

Wikipedia's list of common misspellings [1] has a machine-readable
version.  This patch fixes those misspellings mentioned in the list
which don't have multiple right variants (as e.g. accension, which can
be both accession and ascension), such misspellings are left
untouched.  The list of changes was manually re-checked for false
positives.

[1] 
https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
This is in no way automated, it's merely a check on whether this makes
sense.  Also I left out three words and two files which I thought
might not be what we want.


Quite the list!  As a native speaker...



+++ b/docs/bugs.html.in
@@ -11,7 +11,7 @@

 p
   If you think that an issue with libvirt may have security
-  implications, strongplease do not/strong publically
+  implications, strongplease do not/strong publicly


Correct.



+++ b/docs/schemas/basictypes.rng
@@ -115,7 +115,7 @@
   !--interface on a device (system).  The duid is often used by servers  --
   !--such as dnsmasq to assign a specific IP address (and optionally a   --
   !--name to an interface.  The applicable standards are RFC3315 and --
-  !--RFC6355.  These standards actualy require the duid to be fixed for  --
+  !--RFC6355.  These standards actually require the duid to be fixed for  --
   !--the hardward device and applicable to all network interfaces on --


Alignment is now off.



+++ b/docs/schemas/interface.rng
@@ -4,7 +4,7 @@
  xmlns:v=http://netcf.org/xml/version/1.0;
  datatypeLibrary=http://www.w3.org/2001/XMLSchema-datatypes;
   !-- Versions for this schema are simple integers that are incremented
-   everytime a changed (but backwards compatible) version
+   every time a changed (but backwards compatible) version
is released. The current version is indicated with the v:serial
attribute on the start element.
   --


Hmm - we aren't really bumping the version when we change the .rng; is
that a bug in our process, or a stale comment worth deleting instead of
spell-checking?  But doesn't stop us from taking this hunk now.



Well, this has something to do with netcf, I guess.  Probably Laine
(Cc'd) would be the one to answer that.




@@ -77,7 +77,7 @@
   are two weeks or less in duration. If a problem is identified
   with a proposed patch for a security issue, requiring further
   investigation and bug fixing, the embargo clock may be restarted.
-  In exceptional circumstances longer initial embargos may be
+  In exceptional circumstances longer initial embargoes may be


This one is ambiguous (I've seen both spellings; zeros/zeroes is another
such word), but Thunderbird's US spell-check dictionary prefers
embargoes, so go for it.



My en_GB.utf8 ispell only allows embargoes.  What is your opinion on
dependant and similar words I've left out?


ACK to all these changes (modulo the alignment fix).



I pushed the patch with the alignment fixed and publicly kept,
thanks for the reviews.

Martin


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

Re: [libvirt] [PATCH] Fix common misspellings

2015-03-23 Thread Martin Kletzander

On Mon, Mar 23, 2015 at 09:58:40AM +0100, Ján Tomko wrote:

On Fri, Mar 20, 2015 at 02:40:05PM +0100, Martin Kletzander wrote:


I've left out ok (which should be OK, but it looks like nobody cares
and there were *so many* false positives in the code), and there's
(in)dependant where it suggests s/dant/dent/ and I couldn't find
anywhere that the version with 'a' is wrong, but I see a lot of
consistent usage of that and even my spell-checker doesn't mark it as
wrong.


Dependant is the UK spelling of that person that financially depends on you,
all other uses should use 'dent'.



Is that something that's just well known and I don't know that or do
you have that from some particular place/page/person?  I'd like to
know more about some details.  And to know whether I should send
another version for some other words (when there's time, as this is
not something we need).  Just out of curiosity.

Thanks
Martin


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

[libvirt] [PATCH] Fix underlinking of libvirt_driver_interface.so

2015-03-23 Thread Natanael Copa
Always add udev linker flags when WITH_UDEV is enabled to avoid
underlinking.

See commit 43dbcb15 (interface: always build all available backends)

Signed-off-by: Natanael Copa nc...@alpinelinux.org
---
 src/Makefile.am | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 956d9ce..00b47e7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1457,12 +1457,11 @@ libvirt_driver_interface_la_LIBADD =
 if WITH_NETCF
 libvirt_driver_interface_la_CFLAGS += $(NETCF_CFLAGS)
 libvirt_driver_interface_la_LIBADD += $(NETCF_LIBS)
-else ! WITH_NETCF
+endif WITH_NETCF
 if WITH_UDEV
 libvirt_driver_interface_la_CFLAGS += $(UDEV_CFLAGS)
 libvirt_driver_interface_la_LIBADD += $(UDEV_LIBS)
 endif WITH_UDEV
-endif ! WITH_NETCF
 if WITH_DRIVER_MODULES
 libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la
 libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
-- 
2.3.3

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


Re: [libvirt] Windows 7 guest installer does not detect drive if physical partition used instead of disk file.

2015-03-23 Thread Stefan Hajnoczi
On Sat, Mar 21, 2015 at 01:50:46AM +0800, Emmanuel Noobadmin wrote:
 Running
 3.18.9-200.fc21.x86_64
 qemu 2:2.1.3-3.fc21
 libvirt 1.2.9.2-1.fc21
 System is a Thinkpad X250 with Intel i7-5600u Broadwell GT2
 
 I'm trying to replace the Win7 installation on my laptop with Fedora
 21 and virtualizing Windows 7 for work purposes. I'd prefer to give
 the guest its own NTFS partition instead of using a file for both
 performance and ease of potential recovery.
 
 So I've set aside unpartitioned space on the hard disk and added
 /dev/sda to the virt-manager storage pool, created a new volume and
 assigned it to the guest as an IDE drive. Unfortunately, the Windows 7
 installer does not see this drive despite being IDE and not virtio.
 If I use a qcow2 file as the drive, the installer has no problems
 detecting it.
 
 To eliminate virt-manager from the equation, I've also tried to do a
 very basic install using virt-install with similar results, the
 physical partition cannot be detected regardless of bus type
 (IDE/SATA/virtio) even with the signed Redhat virtio drivers loaded by
 the installer.
 
 I was unable to find any similar issues or solutions online except a 2
 year old thread on linuxquestions which quoted that we must specify
 the whole disk instead of a partition. However, I cannot find the
 source of that quote.
 http://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/qemu-kvm-on-a-real-partition-947162/
 
 Is this really the case and the reason why Windows 7 cannot see the
 physical partition or there is something else I am doing wrong?

I have CCed the libvirt mailing list, since KVM is a component here but
your question seems to be mainly about libvirt, virt-manager,
virt-install, etc.

It sounds like you want an NTFS partition on /dev/sda.  That requires
passing the whole /dev/sda drive to the guest - and the Windows
installer might overwrite your GRUB Master Boot Record.  Be careful when
trying to do this.

Also keep in mind that the virtual machine's hardware and your physical
hardware are probably quiet different (different chipsets, PCI devices,
etc).  Windows might not be happy booting on the physical host if it was
installed under KVM, and vice versa.  This is known as
physical-to-virtual (p2v) migration and means some tweaks or driver
installs may be necessary to make Windows run after switching.

Stefan


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

Re: [libvirt] [PATCH 5/6] tools: fix the wrong check when use virsh setvcpus --maximum

2015-03-23 Thread Pavel Hrdina
On Mon, Mar 23, 2015 at 11:33:50AM +0800, Yanbing Du wrote:
 
 
 On 03/20/2015 10:39 PM, Pavel Hrdina wrote:
  From: Luyao Huang lhu...@redhat.com
 
  We will ignore --maximum option when only use setvcpus with
  this option, like this (this error is another issue):
 
# virsh setvcpus test3 --maximum 10
error: Failed to create controller cpu for group: No such file or 
  directory
 
  this is because we do not set it in flags before we check if there is
  a flags set.
 
  Refactor these code and fix the logic.
 
  Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1204033
 
  Signed-off-by: Luyao Huang lhu...@redhat.com
  Signed-off-by: Pavel Hrdina phrd...@redhat.com
  ---
tools/virsh-domain.c | 30 ++
1 file changed, 6 insertions(+), 24 deletions(-)
 
  diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
  index 1d8225c..9430ad9 100644
  --- a/tools/virsh-domain.c
  +++ b/tools/virsh-domain.c
  @@ -6735,6 +6735,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
VSH_EXCLUSIVE_OPTIONS_VAR(guest, config);
  +VSH_EXCLUSIVE_OPTIONS_VAR(guest, maximum);
  +VSH_EXCLUSIVE_OPTIONS_VAR(config, maximum);
 
 'maximum' should be used with 'config', and 'live' and 'maximum' are 
 mutually exclusive

Yes, you're right, I've definitely meant live instead of config. Good catch.

Pavel

 
 
if (config)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
  @@ -6742,9 +6744,8 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (guest)
flags |= VIR_DOMAIN_VCPU_GUEST;
  -/* none of the options were specified */
  -if (!current  flags == 0)
  -flags = -1;
  +if (maximum)
  +flags |= VIR_DOMAIN_VCPU_MAXIMUM;
 
if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
return false;
  @@ -6754,30 +6755,11 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
 
  -if (flags == -1) {
  +/* none of the options were specified */
  +if (!current  flags == 0) {
if (virDomainSetVcpus(dom, count) != 0)
goto cleanup;
} else {
  -/* If the --maximum flag was given, we need to ensure only the
  -   --config flag is in effect as well */
  -if (maximum) {
  -vshDebug(ctl, VSH_ERR_DEBUG, --maximum flag was given\n);
  -
  -flags |= VIR_DOMAIN_VCPU_MAXIMUM;
  -
  -/* If neither the --config nor --live flags were given, OR
  -   if just the --live flag was given, we need to error out
  -   warning the user that the --maximum flag can only be used
  -   with the --config flag */
  -if (live || !config) {
  -
  -/* Warn the user about the invalid flag combination */
  -vshError(ctl, _(--maximum must be used with --config 
  only));
  -goto cleanup;
  -}
  -}
  -
  -/* Apply the virtual cpu changes */
if (virDomainSetVcpusFlags(dom, count, flags)  0)
goto cleanup;
}
 
 
 -- 
 Regards,
 Yanbing Du
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list

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


Re: [libvirt] [libvirt-designer][PATCH] Changes for code consistency

2015-03-23 Thread Michal Privoznik
On 21.03.2015 01:06, Jayashree Deshpande wrote:
 ---
  libvirt-designer/libvirt-designer-domain.c   | 194 
 ---
  libvirt-designer/libvirt-designer-domain.h   |  41 --
  libvirt-designer/libvirt-designer-internal.c |   3 +-
  libvirt-designer/libvirt-designer-internal.h |   4 +-
  libvirt-designer/libvirt-designer-main.c |  21 +--
  libvirt-designer/libvirt-designer-main.h |   7 +-
  6 files changed, 168 insertions(+), 102 deletions(-)

Ah! I did say I push the former patch of yours. But it seems like I
forgot to do so as I was leaving for the weekend. Lucky me, as this
patch enhances the one I forgot to push. I can merge those two together
and push as one. Cool. ACKed and pushed. Here's proof :)

http://libvirt.org/git/?p=libvirt-designer.git;a=commit;h=9c5614b60e3c98a820ac591987cca57d7f20cdd2

Michal

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


Re: [libvirt] [PATCH] conf: fix running vm numa settings disappear after restart libvirtd

2015-03-23 Thread Peter Krempa
On Thu, Mar 19, 2015 at 18:13:04 +0800, Luyao Huang wrote:
 5bba61f introduce a issue : when start a vm with numa settings and
 restart libvirtd, numa settings will disappear. Because when parse the
 vm states file, there is no node in /domain/cpu/numa this place.
 
 Change to use ./cpu/numa instead of /domain/cpu/numa.
 
 Signed-off-by: Luyao Huang lhu...@redhat.com
 ---
  src/conf/numa_conf.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

Indeed the status XML wraps the  domain element with another container
element.

 
 diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c
 index b92cb44..c34ba5f 100644
 --- a/src/conf/numa_conf.c
 +++ b/src/conf/numa_conf.c
 @@ -663,10 +663,10 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def,
  int ret = -1;
  
  /* check if NUMA definition is present */
 -if (!virXPathNode(/domain/cpu/numa[1], ctxt))
 +if (!virXPathNode(./cpu/numa[1], ctxt))
  return 0;
  
 -if ((n = virXPathNodeSet(/domain/cpu/numa[1]/cell, ctxt, nodes)) = 
 0) {
 +if ((n = virXPathNodeSet(./cpu/numa[1]/cell, ctxt, nodes)) = 0) {
  virReportError(VIR_ERR_XML_ERROR, %s,
 _(NUMA topology defined without NUMA cells));
  goto cleanup;
 -- 

ACK, I'll push your patch after I figure out how to add tests for
problems like this.

Peter


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

Re: [libvirt] qemu_migration: Precreate missing storage breaks with network drives

2015-03-23 Thread Michal Privoznik
On 20.03.2015 20:23, Noel Burton-Krahn wrote:
 Hi Michal,
 
 I think issuing a libvirt migrate to a host where the network disks
 don't already exist would be a prequisite failure.  Libvirt can never
 copy a network disk, but it shouldn't fail trying to migrate an existing
 domain that contains a network disk.  If a libvirt user wishes to
 migrate a domain that contains a network disk, it's their responsibility
 to ensure the disk exists before calling migrate.

That's how it was back in the old days. Then libvirt introduced storage
migration, but requiring users to pre-create storage on destination
themselves. And just recently I taught libvirt to automatically
pre-create the storage. However, not for all disk types.

If a disk on destination is missing, it's likely broken guest ABI
libvirt should have not allowed migration in the first place. How come
the migration was allowed?

Michal

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


Re: [libvirt] [PATCH] Fix common misspellings

2015-03-23 Thread Ján Tomko
On Fri, Mar 20, 2015 at 02:40:05PM +0100, Martin Kletzander wrote:
 
 I've left out ok (which should be OK, but it looks like nobody cares
 and there were *so many* false positives in the code), and there's
 (in)dependant where it suggests s/dant/dent/ and I couldn't find
 anywhere that the version with 'a' is wrong, but I see a lot of
 consistent usage of that and even my spell-checker doesn't mark it as
 wrong.

Dependant is the UK spelling of that person that financially depends on you,
all other uses should use 'dent'.

Jan


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

Re: [libvirt] [PATCH 3/3] network_conf: Drop virNetworkObjIsDuplicate

2015-03-23 Thread Michal Privoznik
On 20.03.2015 20:59, John Ferlan wrote:
 
 
 On 03/16/2015 12:42 PM, Michal Privoznik wrote:
 This function does not make any sense now, that network driver is
 (almost) dropped. I mean, previously, when threads were
 serialized, this function was there to check, if no other network
 with the same name or UUID exists. However, nowadays that threads
 can run more in parallel, this function is useless, in fact it
 gives misleading return values. Consider the following scenario.
 Two threads, both trying to define networks with same name but
 different UUID (e.g. because it was generated during XML parsing
 phase, whatever). Lets assume that both threads are about to call
 networkValidate() which immediately calls
 virNetworkObjIsDuplicate().

 T1: calls virNetworkObjIsDuplicate() and since no network with
 given name or UUID exist, success is returned.
 T2: calls virNetworkObjIsDuplicate() and since no network with
 given name or UUID exist, success is returned.

 T1: calls virNetworkAssignDef() and successfully places its
 network into the virNetworkObjList.
 T2: calls virNetworkAssignDef() and since network with the same
 name exists, the network definition is replaced.

 Okay, this is mainly because virNetworkAssignDef() does not check
 whether name and UUID matches. Well, lets make it so! And drop
 useless function too.

 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/conf/network_conf.c   | 171 
 ++
  src/conf/network_conf.h   |  10 +--
  src/libvirt_private.syms  |   1 -
  src/network/bridge_driver.c   |  17 ++--
  src/parallels/parallels_network.c |   4 +-
  src/test/test_driver.c|  10 ++-
  6 files changed, 99 insertions(+), 114 deletions(-)

 diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
 index d7c5dec..1fb06ef 100644
 --- a/src/conf/network_conf.c
 +++ b/src/conf/network_conf.c
 @@ -504,6 +504,81 @@ virNetworkObjAssignDef(virNetworkObjPtr network,
  }
  
  /*
 + * If flags  VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE then this will
 + * refuse updating an existing def if the current def is Live
 
 s/Live/live  (or active or already running)
 
 + *
 + * If flags  VIR_NETWORK_OBJ_LIST_ADD_LIVE then the @def being
 + * added is assumed to represent a live config, not a future
 + * inactive config
 
 * If no flags is 0
 
 + */
 +static virNetworkObjPtr
 +virNetworkAssignDefLocked(virNetworkObjListPtr nets,
 +  virNetworkDefPtr def,
 +  unsigned int flags)
 +{
 +virNetworkObjPtr network;
 +virNetworkObjPtr ret = NULL;
 +char uuidstr[VIR_UUID_STRING_BUFLEN];
 +
 +/* See if a network with matching UUID already exists */
 +if ((network = virNetworkObjFindByUUIDLocked(nets, def-uuid))) {
 +virObjectLock(network);
 +/* UUID matches, but if names don't match, refuse it */
 +if (STRNEQ(network-def-name, def-name)) {
 +virUUIDFormat(network-def-uuid, uuidstr);
 +virReportError(VIR_ERR_OPERATION_FAILED,
 +   _(network '%s' is already defined with uuid 
 %s),
 +   network-def-name, uuidstr);
 +goto cleanup;
 +}
 +
 +if (flags  VIR_NETWORK_OBJ_LIST_ADD_CHECK_LIVE) {
 +/* UUID  name match, but if network is already active, refuse 
 it */
 +if (virNetworkObjIsActive(network)) {
 +virReportError(VIR_ERR_OPERATION_INVALID,
 +   _(network is already active as '%s'),
 +   network-def-name);
 +goto cleanup;
 +}
 +}
 +
 +virNetworkObjAssignDef(network,
 +   def,
 +   !!(flags  VIR_NETWORK_OBJ_LIST_ADD_LIVE));
 +} else {
 +/* UUID does not match, but if a name matches, refuse it */
 +if ((network = virNetworkObjFindByNameLocked(nets, def-name))) {
 +virObjectLock(network);
 +virUUIDFormat(network-def-uuid, uuidstr);
 +virReportError(VIR_ERR_OPERATION_FAILED,
 +   _(network '%s' already exists with uuid %s),
 +   def-name, uuidstr);
 +goto cleanup;
 +}
 +
 +if (!(network = virNetworkObjNew()))
 +  goto cleanup;
 +
 +virObjectLock(network);
 +
 +virUUIDFormat(def-uuid, uuidstr);
 +if (virHashAddEntry(nets-objs, uuidstr, network)  0)
 +goto cleanup;
 +
 +network-def = def;
 +network-persistent = !(flags  VIR_NETWORK_OBJ_LIST_ADD_LIVE);
 +virObjectRef(network);
 +}
 +
 +ret = network;
 +network = NULL;
 +
 + cleanup:
 +virNetworkObjEndAPI(network);
 +return ret;
 +}
 +
 +/*
   * virNetworkAssignDef:
   * @nets: list of all networks
   * @def: the new NetworkDef (will be consumed by this function iff 
 successful)
 
 

Re: [libvirt] [PATCH] Fix underlinking of libvirt_driver_interface.so

2015-03-23 Thread Ján Tomko
On Mon, Mar 23, 2015 at 10:11:14AM +0100, Natanael Copa wrote:
 Always add udev linker flags when WITH_UDEV is enabled to avoid
 underlinking.
 
 See commit 43dbcb15 (interface: always build all available backends)
 
 Signed-off-by: Natanael Copa nc...@alpinelinux.org
 ---
  src/Makefile.am | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
 

ACK and pushed.

Jan

 diff --git a/src/Makefile.am b/src/Makefile.am
 index 956d9ce..00b47e7 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -1457,12 +1457,11 @@ libvirt_driver_interface_la_LIBADD =
  if WITH_NETCF
  libvirt_driver_interface_la_CFLAGS += $(NETCF_CFLAGS)
  libvirt_driver_interface_la_LIBADD += $(NETCF_LIBS)
 -else ! WITH_NETCF
 +endif WITH_NETCF
  if WITH_UDEV
  libvirt_driver_interface_la_CFLAGS += $(UDEV_CFLAGS)
  libvirt_driver_interface_la_LIBADD += $(UDEV_LIBS)
  endif WITH_UDEV
 -endif ! WITH_NETCF
  if WITH_DRIVER_MODULES
  libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la
  libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
 -- 
 2.3.3
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [PATCHv2 2/5] Add functions to track virtio-serial addresses

2015-03-23 Thread John Ferlan


On 03/17/2015 07:41 AM, Ján Tomko wrote:
 Create a sorted array of virtio-serial controllers.
 Each of the elements contains the controller index
 and a bitmap of available ports.
 
 Buses are not tracked, because they aren't supported by QEMU.
 ---
  src/conf/domain_addr.c   | 348 
 +++
  src/conf/domain_addr.h   |  56 
  src/libvirt_private.syms |   9 ++
  3 files changed, 413 insertions(+)
 

I assumed the ACK to 1/5 sticks...

 diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
 index fb4a76f..d9d01fc 100644
 --- a/src/conf/domain_addr.c
 +++ b/src/conf/domain_addr.c
 @@ -718,3 +718,351 @@ virDomainCCWAddressSetCreate(void)
  virDomainCCWAddressSetFree(addrs);
  return NULL;
  }
 +
 +
 +#define VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS 31
 +
 +
 +/* virDomainVirtioSerialAddrSetCreate
 + *
 + * Allocates an address set for virtio serial addresses
 + */
 +virDomainVirtioSerialAddrSetPtr
 +virDomainVirtioSerialAddrSetCreate(void)
 +{
 +virDomainVirtioSerialAddrSetPtr ret = NULL;
 +
 +if (VIR_ALLOC(ret)  0)
 +return NULL;
 +
 +return ret;
 +}
 +
 +static void
 +virDomainVirtioSerialControllerFree(virDomainVirtioSerialControllerPtr cont)

Should the Free routine take a pointer so that when we VIR_FREE the
pointer the caller doesn't have to worry about setting their copy to NULL?

 +{
 +if (cont) {
 +virBitmapFree(cont-ports);
 +VIR_FREE(cont);
 +}
 +}
 +
 +static ssize_t
 +virDomainVirtioSerialAddrPlaceController(virDomainVirtioSerialAddrSetPtr 
 addrs,
 + virDomainVirtioSerialControllerPtr 
 cont)
 +{
 +size_t i;
 +
 +for (i = 0; i  addrs-ncontrollers; i++) {
 +if (addrs-controllers[i]-idx = cont-idx)
 +return i;
 +}

Would entries controller type='virtio-serial' index='1' ports='4'
and controller type='virtio-serial' index='1' be rejected elsewhere?
I would think index would be unique but this algorithm seems to be
fine and happy with it.

 +return -1;
 +}
 +
 +static ssize_t
 +virDomainVirtioSerialAddrFindController(virDomainVirtioSerialAddrSetPtr 
 addrs,
 +unsigned int idx)
 +{
 +size_t i;
 +
 +for (i = 0; i  addrs-ncontrollers; i++) {
 +if (addrs-controllers[i]-idx == idx)
 +return i;
 +}
 +return -1;
 +}
 +
 +/* virDomainVirtioSerialAddrSetAddController
 + *
 + * Adds virtio serial ports of the existing controller
 + * to the address set.
 + */
 +int
 +virDomainVirtioSerialAddrSetAddController(virDomainVirtioSerialAddrSetPtr 
 addrs,
 +  virDomainControllerDefPtr cont)
 +{
 +int ret = -1;
 +int ports;
 +virDomainVirtioSerialControllerPtr cnt = NULL;
 +ssize_t insertAt;
 +
 +if (cont-type != VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
 +return 0;
 +
 +ports = cont-opts.vioserial.ports;
 +if (ports == -1)
 +ports = VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS;
 +
 +VIR_DEBUG(Adding virtio serial controller index %u with %d
 +   ports to the address set, cont-idx, ports);
 +
 +if (VIR_ALLOC(cnt)  0)
 +goto cleanup;
 +
 +if (!(cnt-ports = virBitmapNew(ports)))
 +goto cleanup;
 +cnt-idx = cont-idx;
 +
 +insertAt = virDomainVirtioSerialAddrPlaceController(addrs, cnt);
 +if (VIR_INSERT_ELEMENT(addrs-controllers, insertAt,
 +   addrs-ncontrollers, cnt)  0)
 +goto cleanup;
 +
 +ret = 0;
 +
 + cleanup:
 +virDomainVirtioSerialControllerFree(cnt);
 +return ret;
 +}
 +
 +/* virDomainVirtioSerialAddrSetAddControllers
 + *
 + * Adds virtio serial ports of controllers present in the domain definition
 + * to the address set.
 + */
 +int
 +virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr 
 addrs,
 +   virDomainDefPtr def)
 +{
 +size_t i;
 +
 +for (i = 0; i  def-ncontrollers; i++) {
 +if (virDomainVirtioSerialAddrSetAddController(addrs,
 +  def-controllers[i])  
 0)
 +return -1;
 +}
 +
 +return 0;
 +}
 +
 +/* virDomainVirtioSerialAddrSetRemoveController
 + *
 + * Removes a virtio serial controller from the address set.
 + */
 +int
 +virDomainVirtioSerialAddrSetRemoveController(virDomainVirtioSerialAddrSetPtr 
 addrs,
 + virDomainControllerDefPtr cont)
 +{
 +int ret = -1;
 +ssize_t pos;
 +
 +if (cont-type != VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
 +return 0;
 +
 +VIR_DEBUG(Removing virtio serial controller index %u 
 +  from the address set, cont-idx);
 +
 +pos = virDomainVirtioSerialAddrFindController(addrs, cont-idx);
 +
 +if (pos = 0 
 +VIR_DELETE_ELEMENT(addrs-controllers, pos, addrs-ncontrollers)  0)
 +goto cleanup;
 +

If 'pos' 

[libvirt] [PATCH] Document that USB hostdevs do not need nodeDettach

2015-03-23 Thread Ján Tomko
The virNodeDeviceDettach API only works on PCI devices.

Originally added by commit 10d3272e, but the API never
supported USB devices.

Reported by: Martin Polednik mpoled...@redhat.com
---
 docs/formatdomain.html.in | 19 +--
 tools/virsh.pod   | 17 -
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 82aa14f..d6abe17 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3114,21 +3114,20 @@
 with additional attributes noted.
 dl
   dtusb/dt
-  ddFor USB devices, the user is responsible to call
-codevirNodeDeviceDettach/code (or
-codevirsh nodedev-detach/code) before starting the guest
-or hot-plugging the device and codevirNodeDeviceReAttach/code
-(or codevirsh nodedev-reattach/code) after hot-unplug or
-stopping the guest.
+  ddUSB devices are detached from the host on guest startup
+and reattached after the guest exits or the device is
+hot-unplugged.
   /dd
   dtpci/dt
   ddFor PCI devices, when codemanaged/code is yes it is
 detached from the host before being passed on to the guest
 and reattached to the host after the guest exits. If
-codemanaged/code is omitted or no, follow the steps
-described for a USB device to detach before starting the
-guest or hot-plugging and reattach after stopping the guest
-or hot-unplug.
+codemanaged/code is omitted or no, the user is
+responsible to call codevirNodeDeviceDettach/code
+(or codevirsh nodedev-detach/code before starting the guest
+or hot-plugging the device and codevirNodeDeviceReAttach/code
+(or codevirsh nodedev-reattach/code) after hot-unplug or
+stopping the guest.
   /dd
   dtscsi/dt
   ddFor SCSI devices, user is responsible to make sure the device
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 8262a45..4d825c1 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2385,7 +2385,7 @@ attach taking effect the next time libvirt starts the 
domain.
 For cdrom and floppy devices, this command only replaces the media
 within an existing device; consider using Bupdate-device for this
 usage.  For passthrough host devices, see also Bnodedev-detach,
-needed if the device does not use managed mode.
+needed if the PCI device does not use managed mode.
 
 If I--live is specified, affect a running domain.
 If I--config is specified, affect the next startup of a persistent domain.
@@ -2646,15 +2646,14 @@ Lhttp://libvirt.org/formatnode.html.
 
 Passthrough devices cannot be simultaneously used by the host and its
 guest domains, nor by multiple active guests at once.  If the
-hostdev description includes the attribute Bmanaged='yes', and the
-hypervisor driver supports it, then the device is in managed mode, and
+hostdev description of a PCI device includes the attribute Bmanaged='yes',
+and the hypervisor driver supports it, then the device is in managed mode, and
 attempts to use that passthrough device in an active guest will
 automatically behave as if Bnodedev-detach (guest start, device
 hot-plug) and Bnodedev-reattach (guest stop, device hot-unplug) were
-called at the right points (currently, qemu does this for PCI devices,
-but not USB).  If a device is not marked as managed, then it must
-manually be detached before guests can use it, and manually reattached
-to be returned to the host.  Also, if a device is manually detached,
+called at the right points.  If a PCI device is not marked as managed,
+then it must manually be detached before guests can use it, and manually
+reattached to be returned to the host.  Also, if a device is manually detached,
 then the host does not regain control of the device without a matching
 reattach, even if the guests use the device in managed mode.
 
@@ -2712,8 +2711,8 @@ Icap and I--tree are mutually exclusive.
 
 Declare that Inodedev is no longer in use by any guests, and that
 the host can resume normal use of the device.  This is done
-automatically for devices in managed mode, but must be done explicitly
-to match any explicit Bnodedev-detach.
+automatically for PCI devices in managed mode and USB devices, but
+must be done explicitly to match any explicit Bnodedev-detach.
 
 =item Bnodedev-reset Inodedev
 
-- 
2.0.5

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


[libvirt] [PATCH] RFC: Add domain vmport attribute

2015-03-23 Thread Marc-André Lureau
The QEMU machine vmport option allows to set the VMWare IO port
emulation. This emulation is useful for absolute pointer input when the
guest has vmware input drivers, and is enabled by default for kvm.

However it is unnecessary for Spice-enabled VM, since the agent already
handles absolute pointer and multi-monitors. Furthermore, it prevents
Spice from switching to relative input since the regular ps/2 pointer
driver is replaced by the vmware driver. It is thus advised to disable
vmport when using a Spice VM. This will permit the Spice client to
switch from absolute to relative pointer, as it may be required for
certain games or applications.
---

PS: the patch could be split in domain+docs+qemu+test

docs/formatdomain.html.in  |  7 +-
 docs/schemas/domaincommon.rng  |  8 +++
 src/conf/domain_conf.c |  9 
 src/conf/domain_conf.h |  1 +
 src/qemu/qemu_capabilities.c   |  6 ++
 src/qemu/qemu_capabilities.h   |  1 +
 src/qemu/qemu_command.c| 13 +++
 .../qemuxml2argv-machine-vmport-opt.args   |  6 ++
 .../qemuxml2argv-machine-vmport-opt.xml| 25 ++
 tests/qemuxml2argvtest.c   |  2 ++
 10 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-vmport-opt.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-vmport-opt.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index be35c82..51d74d1 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -124,7 +124,12 @@
 and codemachine/code referring to the machine
 type. The a href=formatcaps.htmlCapabilities XML/a
 provides details on allowed values for
-these. span class=sinceSince 0.0.1/span/dd
+these. span class=sinceSince 0.0.1/span
+The optional codevmport/code attribute (accepted values
+are codeyes/code and codeno/code), sets the
+emulation of VMWare IO port, for vmmouse etc. span
+class=sinceSince 1.2.14/span
+  /dd
   dtcodeloader/code/dt
   ddThe optional codeloader/code tag refers to a firmware blob
 used to assist the domain creation process. It is used by Xen
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ebd9299..da3c8c0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -339,6 +339,14 @@
   ref name=hvmaarch64/
 /choice
   /optional
+  optional
+attribute name=vmport
+  choice
+valueyes/value
+valueno/value
+  /choice
+/attribute
+  /optional
   valuehvm/value
 /element
   /define
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index ae7d8df..d12598b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14218,6 +14218,15 @@ virDomainDefParseXML(xmlDocPtr xml,
 goto error;
 }
 
+tmp = virXPathString(string(./os/type[1]/@vmport), ctxt);
+if (tmp 
+(def-os.vmport = virTristateBoolTypeFromString(tmp)) = 0) {
+virReportError(VIR_ERR_OS_TYPE,
+   _(unknown vmport value: %s), tmp);
+goto error;
+}
+VIR_FREE(tmp);
+
 /*
  * Booting options for different OS types
  *
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 9d314fa..4cc2ff7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1767,6 +1767,7 @@ struct _virDomainOSDef {
 char *bootloader;
 char *bootloaderArgs;
 int smbios_mode;
+int vmport; /* enum virTristateBool */
 
 virDomainBIOSDef bios;
 };
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index ccf22f0..f5481d3 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -279,6 +279,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   qxl.vgamem_mb,
   qxl-vga.vgamem_mb,
   pc-dimm,
+
+  machine-vmport-opt, /* 185 */
 );
 
 
@@ -3239,6 +3241,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
 if (qemuCaps-version = 1003000)
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_USB_OPT);
 
+/* vmport option is supported v2.2.0 onwards */
+if (qemuCaps-version = 2002000)
+virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_VMPORT_OPT);
+
 /* WebSockets were introduced between 1.3.0 and 1.3.1 */
 if (qemuCaps-version = 1003001)
 virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNC_WEBSOCKET);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index c7b1ac7..48c8f96 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -224,6 +224,7 @@ typedef enum {
 QEMU_CAPS_QXL_VGAMEM = 182, /* -device 

Re: [libvirt] Windows 7 guest installer does not detect drive if physical partition used instead of disk file.

2015-03-23 Thread Emmanuel Noobadmin
On 3/23/15, Stefan Hajnoczi stefa...@gmail.com wrote:
 I have CCed the libvirt mailing list, since KVM is a component here but
 your question seems to be mainly about libvirt, virt-manager,
 virt-install, etc.

Apologies for posting to the wrong list, I assumed it would be KVM
related as the guest could run but could not see the drive.

More information
1. install guest with /dev/sdxx as virtio device (the problem case)
- installer does not see any drive
- load drivers on Redhat virtio cdrom
- installer still does not see any drive

2. Install guest with qcow2 disk file as virtio device
- as previous scenario but installer see drives after installing drivers

3. install guest with qcow2 disk file as IDE device
- complete installation
- add /dev/sdxx as virtio disk
- goto Windows Device Manager and update virtio driver for unknown controller
- Windows see /dev/sdxx after driver installed


 It sounds like you want an NTFS partition on /dev/sda.  That requires
 passing the whole /dev/sda drive to the guest - and the Windows
 installer might overwrite your GRUB Master Boot Record.  Be careful when
 trying to do this.

Yes, I wanted to give Windows its own native partition that could be
read directly if I had to yank the disk and put it into a Windows
machine. Is this why #3 works but not #1? That as long as I want to
install Windows directly to an NTFS partition on/dev/sda, it is
required that I pass the whole drive to Windows?

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


[libvirt] [PATCH] compile failure 'src/cpu/cpu_map.xml': No such file or directory'

2015-03-23 Thread Amy Fong
From 73172eeed1fcffcfae088a3059fbca0689b7437f Mon Sep 17 00:00:00 2001
From: Amy Fong amy.f...@windriver.com
Date: Mon, 23 Mar 2015 13:44:03 -0400
Subject: [PATCH] libvirt: 'src/cpu/cpu_map.xml': No such file or directory'

In some circumstances where the build tree differs from the source,
libvirt's compile will try to create the symlink for cpu_map.xml before
creating the directory $(abs_builddir)/cpu.

Add a test to create this directory if it hasn't already been created.

Signed-off-by: Amy Fong amy.f...@windriver.com
---
 src/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index 00b47e7..2e4a520 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1039,6 +1039,7 @@ libvirt_cpu_la_SOURCES = $(CPU_SOURCES)
 libvirt_cpu_la_DEPENDENCIES = $(abs_builddir)/cpu/cpu_map.xml
 
 $(abs_builddir)/cpu/cpu_map.xml:
+   if [ ! -d $(abs_builddir)/cpu ]; then $(MKDIR_P) $(abs_builddir)/cpu/; 
fi
$(AM_V_GEN)ln -s $(abs_srcdir)/cpu/cpu_map.xml $@
 
 if WITH_VMX
-- 
2.1.4

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


Re: [libvirt] [PATCH 2/2] qemu: add a max_core setting to qemu.conf for core dump size

2015-03-23 Thread John Ferlan


On 03/18/2015 08:36 AM, Daniel P. Berrange wrote:
 Currently the QEMU processes inherit their core dump rlimit
 from libvirtd, which is really suboptimal. This change allows
 their limit to be directly controller from qemu.conf instead.
 ---
  src/libvirt_private.syms   |  2 ++
  src/qemu/libvirtd_qemu.aug |  1 +
  src/qemu/qemu.conf | 12 
  src/qemu/qemu_conf.c   |  3 +++
  src/qemu/qemu_conf.h   |  2 ++
  src/qemu/qemu_process.c|  2 ++
  src/qemu/test_libvirtd_qemu.aug.in |  1 +
  src/util/vircommand.c  | 14 ++
  src/util/vircommand.h  |  1 +
  src/util/virprocess.c  | 35 +++
  src/util/virprocess.h  |  1 +
  11 files changed, 74 insertions(+)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index ca3520d..7446357 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1240,6 +1240,7 @@ virCommandSetErrorFD;
  virCommandSetGID;
  virCommandSetInputBuffer;
  virCommandSetInputFD;
 +virCommandSetMaxCoreSize;
  virCommandSetMaxFiles;
  virCommandSetMaxMemLock;
  virCommandSetMaxProcesses;
 @@ -1951,6 +1952,7 @@ virProcessRunInMountNamespace;
  virProcessSchedPolicyTypeFromString;
  virProcessSchedPolicyTypeToString;
  virProcessSetAffinity;
 +virProcessSetMaxCoreSize;
  virProcessSetMaxFiles;
  virProcessSetMaxMemLock;
  virProcessSetMaxProcesses;
 diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
 index 62951da..029a55a 100644
 --- a/src/qemu/libvirtd_qemu.aug
 +++ b/src/qemu/libvirtd_qemu.aug
 @@ -71,6 +71,7 @@ module Libvirtd_qemu =
   | bool_entry set_process_name
   | int_entry max_processes
   | int_entry max_files
 + | int_entry max_core
  
 let device_entry = bool_entry mac_filter
   | bool_entry relaxed_acs_check
 diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
 index 1c589a2..12e4326 100644
 --- a/src/qemu/qemu.conf
 +++ b/src/qemu/qemu.conf
 @@ -390,6 +390,18 @@
  #max_processes = 0
  #max_files = 0
  
 +# If max_core is set to a positive integer, then QEMU will be
 +# permitted to create core dumps when it crashes, provided its
 +# RAM size is smaller than the limit set. Be warned that the
 +# core dump will include a full copy of the guest RAM, so if
 +# the largest guest is 32 GB in size, the max_core limit will
 +# have to be at least 33/34 GB to allow enough overhead.
 +#
 +# By default it will inherit core limit from libvirtd, which
 +# is usually set to 0 by systemd/init.
 +#
 +# Size is in bytes
 +#max_core = 0

It's too bad it cannot be a sized value... Reading 20G in a file for
me is so much easier than the comparable byte value say nothing if we
get to 128G, 1T, etc. (some day).

  
  
  # mac_filter enables MAC addressed based filtering on bridge ports.
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index bca05c9..97bb8b8 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -770,6 +770,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr 
 cfg,
  GET_VALUE_BOOL(set_process_name, cfg-setProcessName);
  GET_VALUE_ULONG(max_processes, cfg-maxProcesses);
  GET_VALUE_ULONG(max_files, cfg-maxFiles);
 +GET_VALUE_ULONG(max_core, cfg-maxCore);
 +if (virConfGetValue(conf, max_core))
 +cfg-setMaxCore = true;

Should we ensure cfg-maxCore = 0 (or does that get magically done by
one the many macros). Paranoia based on shared LL/LLU algorithm (and
that my eyes/brain is tired).  Which leads me down the path of - if
'max_core' is set to zero or doesn't exist, then cfg-maxCore would be
zero - so is the 'setMaxCore' necessary.

  
  GET_VALUE_STR(lock_manager, cfg-lockManagerName);
  
 diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
 index cb01fb6..ac7a1bf 100644
 --- a/src/qemu/qemu_conf.h
 +++ b/src/qemu/qemu_conf.h
 @@ -143,6 +143,8 @@ struct _virQEMUDriverConfig {
  
  int maxProcesses;
  int maxFiles;
 +bool setMaxCore;
 +unsigned long long maxCore;
  
  int maxQueuedJobs;
  
 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
 index 37cdb8f..995d6ef 100644
 --- a/src/qemu/qemu_process.c
 +++ b/src/qemu/qemu_process.c
 @@ -4731,6 +4731,8 @@ int qemuProcessStart(virConnectPtr conn,
  virCommandSetPreExecHook(cmd, qemuProcessHook, hookData);
  virCommandSetMaxProcesses(cmd, cfg-maxProcesses);
  virCommandSetMaxFiles(cmd, cfg-maxFiles);
 +if (cfg-setMaxCore)
 +virCommandSetMaxCoreSize(cmd, cfg-maxCore);
  virCommandSetUmask(cmd, 0x002);
  
  VIR_DEBUG(Setting up security labelling);
 diff --git a/src/qemu/test_libvirtd_qemu.aug.in 
 b/src/qemu/test_libvirtd_qemu.aug.in
 index fc4935b..9bb3683 100644
 --- a/src/qemu/test_libvirtd_qemu.aug.in
 +++ b/src/qemu/test_libvirtd_qemu.aug.in
 @@ -61,6 +61,7 @@ module Test_libvirtd_qemu =
  { set_process_name 

Re: [libvirt] [PATCH] Relax filesystem target type

2015-03-23 Thread Daniel P. Berrange
On Sat, Mar 21, 2015 at 11:45:03AM +0100, Guido Günther wrote:
 When using QEMU's 9pfs the target dir element is not necessarily an
 absolute path. If it is not validation currently fails with the
 misleaading

In fact the target dir is not actually a directory at all. With
KVM is is an opaque tag, so we should not validate this content
at all. We should allow arbitrary content. Yes, the attribute
name is a really unfortunate/awful historical mistake.


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] RFC: Add domain vmport attribute

2015-03-23 Thread Daniel P. Berrange
On Mon, Mar 23, 2015 at 05:32:30PM +0100, Marc-André Lureau wrote:
 The QEMU machine vmport option allows to set the VMWare IO port
 emulation. This emulation is useful for absolute pointer input when the
 guest has vmware input drivers, and is enabled by default for kvm.
 
 However it is unnecessary for Spice-enabled VM, since the agent already
 handles absolute pointer and multi-monitors. Furthermore, it prevents
 Spice from switching to relative input since the regular ps/2 pointer
 driver is replaced by the vmware driver. It is thus advised to disable
 vmport when using a Spice VM. This will permit the Spice client to
 switch from absolute to relative pointer, as it may be required for
 certain games or applications.


 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-vmport-opt.xml 
 b/tests/qemuxml2argvdata/qemuxml2argv-machine-vmport-opt.xml
 new file mode 100644
 index 000..ee796f6
 --- /dev/null
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-vmport-opt.xml
 @@ -0,0 +1,25 @@
 +domain type='qemu'
 +  nameQEMUGuest1/name
 +  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
 +  memory unit='KiB'219100/memory
 +  currentMemory unit='KiB'219100/currentMemory
 +  vcpu placement='static'1/vcpu
 +  os
 +type arch='i686' machine='pc' vmport='no'hvm/type
 +boot dev='hd'/
 +  /os

I think we'd normally place this kind of attribute in the
features/features block rather than here. eg see the
toggle for turning on/off hyper-v emulation.


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 1/2] conf: parse integers into long long, instead of long

2015-03-23 Thread John Ferlan


On 03/18/2015 08:36 AM, Daniel P. Berrange wrote:
 When parsing integer values, we only used 'long' data type
 in the virConfValue struct. This is insufficiently large
 to deal with things like guest memory sizes on 32-bit platforms
 which are using PAE for addressing  4 GB of RAM.
 ---
  daemon/libvirtd-config.c  |   6 +--
  src/locking/lock_daemon_config.c  |   4 +-
  src/locking/lock_driver_lockd.c   |   4 +-
  src/locking/lock_driver_sanlock.c |   6 +--
  src/lxc/lxc_conf.c|   6 +--
  src/qemu/qemu_conf.c  |   6 +--
  src/util/virconf.c|  22 
  src/util/virconf.h|   6 +--
  src/xenconfig/xen_common.c|   8 +--
  tests/Makefile.am |   5 ++
  tests/libvirtdconftest.c  |   4 +-
  tests/virconftest.c   | 105 
 ++
  12 files changed, 146 insertions(+), 36 deletions(-)
  create mode 100644 tests/virconftest.c
 

Beyond the concept of typing in that many numbers which boggles the mind
and eyes... A couple of notes:

 virConfParseLLong()

  - comment needs to be updated from Parse one long int value to long
long

 virConfSaveValue()

  - should the %llu be separate from %lld, since now we're talking
memory values?  That leads to the more general question/issue of whether we

 virConfParseValue()

  - Similarly, should the virConfParseLLong have a virConfParseULLong?
Yeah - I know, hard to imagine typing that many digits *and* being
correct! Need to spend a long time shaving yaks and counting hairs to
get that large!

 testCorrupt()

  - The error message invalid type: got string; expected unsigned long
(and just long) - Should they change to unsigned long long and long
long respectively?


ACK - unless there's something someone believes has to fit within the
LONG/ULONG space.

John


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