[libvirt] [PATCH] src: Move DLOPEN_LIBS to libraries introducing the dependency

2018-08-09 Thread Michal Privoznik
There are few places where dlopen() is called. This call means we
have to link with DLOPEN_LIBS. However, instead of having each
final, installable library linking with it, move the directive to
the source that introduced the dependency.

Signed-off-by: Michal Privoznik 
---
 src/Makefile.am  | 2 ++
 src/util/Makefile.inc.am | 1 +
 tools/Makefile.am| 4 ++--
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index a4f213480e..61876cf382 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -752,6 +752,7 @@ libvirt_setuid_rpc_client_la_CFLAGS = \
$(AM_CFLAGS) \
$(SECDRIVER_CFLAGS) \
$(XDR_CFLAGS) \
+   $(DLOPEN_LIBS) \
$(NULL)
 endif WITH_SETUID_RPC_CLIENT
 
@@ -1000,6 +1001,7 @@ libvirt_nss_la_CFLAGS = \
$(NULL)
 libvirt_nss_la_LDFLAGS = \
$(AM_LDFLAGS) \
+   $(DLOPEN_LIBS) \
$(NULL)
 endif WITH_NSS
 
diff --git a/src/util/Makefile.inc.am b/src/util/Makefile.inc.am
index 8ef9ee1dfa..c5c50f1844 100644
--- a/src/util/Makefile.inc.am
+++ b/src/util/Makefile.inc.am
@@ -278,6 +278,7 @@ libvirt_util_la_LIBADD = \
$(NUMACTL_LIBS) \
$(ACL_LIBS) \
$(GNUTLS_LIBS) \
+   $(DLOPEN_LIBS) \
$(NULL)
 
 
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 26c887649e..3e129c04c4 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -528,7 +528,7 @@ nss_libnss_libvirt_impl_la_CFLAGS = \
 nss_libnss_libvirt_impl_la_LIBADD = \
../gnulib/lib/libgnu.la \
../src/libvirt-nss.la \
-   $(DLOPEN_LIBS)
+   $(NULL)
 
 nss_libnss_libvirt_la_SOURCES =
 nss_libnss_libvirt_la_LDFLAGS = \
@@ -556,7 +556,7 @@ nss_libnss_libvirt_guest_impl_la_CFLAGS = \
 nss_libnss_libvirt_guest_impl_la_LIBADD = \
../gnulib/lib/libgnu.la \
../src/libvirt-nss.la \
-   $(DLOPEN_LIBS)
+   $(NULL)
 
 nss_libnss_libvirt_guest_la_SOURCES =
 nss_libnss_libvirt_guest_la_LDFLAGS = \
-- 
2.16.4

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


Re: [libvirt] [PATCH] Fix link errors in tools/nss and tests

2018-08-09 Thread Michal Privoznik
On 08/09/2018 07:15 PM, Jim Fehlig wrote:

> 
> I tested the patch, works fine. What is the best course of action since
> I pushed the other one? Revert it and push your patch?

No need to revert. I'll send a patch that moves DLOPEN_* where I suggested.

Michal

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


[libvirt] [PATCH 2/2] esx:Fix esxDomainGetMaxVcpus to return correct vcpus

2018-08-09 Thread Marcos Paulo de Souza
Before this change, esxDomainGetMaxVcpus returned -1, which in turn
fails in libvirt. This commit reimplements esxDomainGetMaxVcpus instead
of calling esxDomainGetVcpusFlags. The implementation checks for
capability.maxSupportedVcpus, but as this one can be ommited in ESXi, we
also check for capability.maxHostSupportedVcpus. With this change,
virDomainSetVcpus, virDomainGetMaxVcpus and virDomainGetVcpusFlags and
returning correct values.

Signed-off-by: Marcos Paulo de Souza 
---
 src/esx/esx_driver.c | 36 ++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index d5e8a7b4eb..3169314fa4 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2581,8 +2581,40 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int 
flags)
 static int
 esxDomainGetMaxVcpus(virDomainPtr domain)
 {
-return esxDomainGetVcpusFlags(domain, (VIR_DOMAIN_AFFECT_LIVE |
-   VIR_DOMAIN_VCPU_MAXIMUM));
+esxPrivate *priv = domain->conn->privateData;
+esxVI_String *propertyNameList = NULL;
+esxVI_ObjectContent *hostSystem = NULL;
+esxVI_Int *supportedVcpus = NULL;
+esxVI_Int *hostVcpus = NULL;
+
+if (esxVI_EnsureSession(priv->primary) < 0)
+return -1;
+
+priv->maxVcpus = -1;
+
+if (esxVI_String_AppendValueToList(,
+   "capability.maxHostSupportedVcpus\0"
+   "capability.maxSupportedVcpus"
+  ) < 0 ||
+esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
+  ) < 0 ||
+esxVI_GetInt(hostSystem, "capability.maxHostSupportedVcpus",
+  , esxVI_Occurrence_RequiredItem) < 0 ||
+esxVI_GetInt(hostSystem, "capability.maxSupportedVcpus",
+  , esxVI_Occurrence_OptionalItem) < 0)
+
+goto cleanup;
+
+/* as maxSupportedVcpus is optional, check also for maxHostSupportedVcpus 
*/
+priv->maxVcpus = supportedVcpus ? supportedVcpus->value : hostVcpus->value;
+
+ cleanup:
+esxVI_String_Free();
+esxVI_ObjectContent_Free();
+esxVI_Int_Free();
+esxVI_Int_Free();
+
+return priv->maxVcpus;
 }
 
 
-- 
2.17.1

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


[libvirt] [PATCH 1/2] esx: Make esxDomainGetVcpusFlags return vcpus again

2018-08-09 Thread Marcos Paulo de Souza
Before this patch, esxDomainGetVcpusFlags was returning -1 since
"maxSupportedVcpus" can be NULL in ESXi[1]. In order to make it work,
replicate the same behavior than esxDomainGetInfo that used
config.hardware.numCPU to return the correct number of vcpus of a VM.

This patch, together with the next one, makes the calls
virDomainSetVcpus, virDomainGetMaxVcpus and virDomainGetVcpusFlags to
return successfull again.

[1]:https://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.host.Capability.html

Signed-off-by: Marcos Paulo de Souza 
---
 src/esx/esx_driver.c | 36 +++-
 1 file changed, 11 insertions(+), 25 deletions(-)

diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index c2154799fa..d5e8a7b4eb 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -2547,45 +2547,31 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned 
int flags)
 {
 esxPrivate *priv = domain->conn->privateData;
 esxVI_String *propertyNameList = NULL;
-esxVI_ObjectContent *hostSystem = NULL;
-esxVI_DynamicProperty *dynamicProperty = NULL;
+esxVI_ObjectContent *virtualMachine = NULL;
+esxVI_Int *vcpus = NULL;
 
 virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
   VIR_DOMAIN_VCPU_MAXIMUM, -1);
 
-if (priv->maxVcpus > 0)
-return priv->maxVcpus;
-
 priv->maxVcpus = -1;
 
 if (esxVI_EnsureSession(priv->primary) < 0)
 return -1;
 
 if (esxVI_String_AppendValueToList(,
-   "capability.maxSupportedVcpus") < 0 ||
-esxVI_LookupHostSystemProperties(priv->primary, propertyNameList,
- ) < 0) {
+   "config.hardware.numCPU\0") < 0 ||
+esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
+ propertyNameList, ,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+   esxVI_GetInt(virtualMachine, "config.hardware.numCPU",
+  , esxVI_Occurrence_RequiredItem) < 0)
 goto cleanup;
-}
-
-for (dynamicProperty = hostSystem->propSet; dynamicProperty;
- dynamicProperty = dynamicProperty->_next) {
-if (STREQ(dynamicProperty->name, "capability.maxSupportedVcpus")) {
-if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Int) < 0) {
-goto cleanup;
-}
-
-priv->maxVcpus = dynamicProperty->val->int32;
-break;
-} else {
-VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
-}
-}
 
+priv->maxVcpus = vcpus->value;
  cleanup:
 esxVI_String_Free();
-esxVI_ObjectContent_Free();
+esxVI_ObjectContent_Free();
+esxVI_Int_Free();
 
 return priv->maxVcpus;
 }
-- 
2.17.1

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


[libvirt] [PATCH 0/2] esx: Fix {g,s}et vcpus

2018-08-09 Thread Marcos Paulo de Souza
Hi guys,

while checking my ESXi 6.5, and trying to query and change vcpus values, I
discovered this was not working. So, these two patches aim to fix the problem. I
checked some docs[1].

Let me know if there are points where it can be improved.

Thanks,

[1] 
https://www.vmware.com/support/orchestrator/doc/vco_vsphere55_api/html/VcHostCapability.html

Marcos Paulo de Souza (2):
  esx: Make esxDomainGetVcpusFlags return vcpus again
  esx:Fix esxDomainGetMaxVcpus to return correct vcpus

 src/esx/esx_driver.c | 72 +++-
 1 file changed, 45 insertions(+), 27 deletions(-)

-- 
2.17.1

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


Re: [libvirt] [PATCH 2/3] libxl: implement virDomainPM* functions

2018-08-09 Thread Jim Fehlig

On 08/05/2018 05:01 PM, Marek Marczykowski-Górecki wrote:

Signed-off-by: Marek Marczykowski-Górecki 
---
  src/libxl/libxl_driver.c | 126 -
  1 file changed, 126 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 5a5e792..10c7aab 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1403,6 +1403,128 @@ libxlDomainDestroy(virDomainPtr dom)
  return libxlDomainDestroyFlags(dom, 0);
  }
  
+#ifdef LIBXL_HAVE_DOMAIN_SUSPEND_ONLY

+static int
+libxlDomainPMSuspendForDuration(virDomainPtr dom,
+unsigned int target,
+unsigned long long duration,
+unsigned int flags)
+{
+virDomainObjPtr vm;
+int ret = -1;
+libxlDriverPrivatePtr driver = dom->conn->privateData;
+libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+
+virCheckFlags(0, -1);
+if (target != VIR_NODE_SUSPEND_TARGET_MEM) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
+_("PMSuspend type %d not supported by libxenlight driver"),
+target);
+return -1;
+}
+
+if (duration != 0) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+_("libxenlight driver supports only duration=0"));
+return -1;
+}
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainPMSuspendForDurationEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("Domain is not running"));
+goto endjob;
+}


Error is now reported in virDomainObjIsActive, so this can be simplified to

if (virDomainObjCheckActive(vm) < 0)
goto endjob;


+
+/* Unlock virDomainObjPtr to not deadlock with even handler, which will try
+ * to send lifecycle event
+ */
+virObjectUnlock(vm);
+ret = libxl_domain_suspend_only(cfg->ctx, vm->def->id, NULL);
+virObjectLock(vm);
+
+if (ret < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Failed to suspend domain '%d'"), vm->def->id);
+goto endjob;
+}
+
+ret = 0;
+
+ endjob:
+libxlDomainObjEndJob(driver, vm);
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);


We now use virDomainObjEndAPI().


+return ret;
+}
+#endif
+
+static int
+libxlDomainPMWakeup(virDomainPtr dom,
+unsigned int flags)


Whitespace off a bit. Could probably be moved to previous line.


+{
+libxlDriverPrivatePtr driver = dom->conn->privateData;
+virDomainObjPtr vm;
+int ret = -1;
+virObjectEventPtr event = NULL;
+libxlDomainObjPrivatePtr priv;
+libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+
+virCheckFlags(0, -1);
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainPMWakeupEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0)
+goto cleanup;
+
+if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PMSUSPENDED) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("Domain is not suspended"));
+goto endjob;
+}
+
+event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED,
+ VIR_DOMAIN_EVENT_STARTED_WAKEUP);
+
+priv = vm->privateData;
+if (libxl_domain_resume(cfg->ctx, vm->def->id, 1, NULL) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Failed to resume domain '%d'"), vm->def->id);
+goto endjob;
+}
+virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_WAKEUP);
+/* reenable death event - libxl reports it only once */
+if (priv->deathW)
+libxl_evdisable_domain_death(cfg->ctx, priv->deathW);
+if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, >deathW))
+goto endjob;


Is returning failure the right thing to do here? Should we kill off the domain 
first? In libxlDomainStart we destroy the domain if enabling death events fails.



+
+ret = 0;
+
+ endjob:
+libxlDomainObjEndJob(driver, vm);
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);


virDomainObjEndAPI();


+virObjectEventStateQueue(driver->domainEventState, event);
+return ret;
+}
+
  static char *
  libxlDomainGetOSType(virDomainPtr dom)
  {
@@ -6385,6 +6507,10 @@ static virHypervisorDriver libxlHypervisorDriver = {
  .domainReboot = libxlDomainReboot, /* 0.9.0 */
  .domainDestroy = libxlDomainDestroy, /* 0.9.0 */
  .domainDestroyFlags = libxlDomainDestroyFlags, /* 0.9.4 */
+#ifdef LIBXL_HAVE_DOMAIN_SUSPEND_ONLY
+.domainPMSuspendForDuration = libxlDomainPMSuspendForDuration, /* 

Re: [libvirt] [PATCH 3/3] libxl: initialize domain state with real data

2018-08-09 Thread Jim Fehlig

On 08/05/2018 05:01 PM, Marek Marczykowski-Górecki wrote:

When libvirtd is started, initialize domain objects state with its real
state, not only RUNNING/SHUTOFF.

Signed-off-by: Marek Marczykowski-Górecki 
---
  src/libxl/libxl_driver.c | 11 +++
  1 file changed, 11 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 10c7aab..16b3146 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -412,6 +412,17 @@ libxlReconnectDomain(virDomainObjPtr vm,
  vm->def, hostdev_flags) < 0)
  goto error;
  
+if (d_info.shutdown &&

+d_info.shutdown_reason == LIBXL_SHUTDOWN_REASON_SUSPEND)
+virDomainObjSetState(vm, VIR_DOMAIN_PMSUSPENDED,
+ VIR_DOMAIN_PMSUSPENDED_UNKNOWN);
+else if (d_info.paused)
+virDomainObjSetState(vm, VIR_DOMAIN_PAUSED,
+ VIR_DOMAIN_PAUSED_UNKNOWN);
+else
+virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
+ VIR_DOMAIN_RUNNING_UNKNOWN);
+
  if (virAtomicIntInc(>nactive) == 1 && driver->inhibitCallback)
  driver->inhibitCallback(true, driver->inhibitOpaque);
  



Reviewed-by: Jim Fehlig 

Regards,
Jim

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

Re: [libvirt] [PATCH 1/3] libxl: send lifecycle event on suspend

2018-08-09 Thread Jim Fehlig

On 08/05/2018 05:01 PM, Marek Marczykowski-Górecki wrote:

Signed-off-by: Marek Marczykowski-Górecki 
---
  src/libxl/libxl_domain.c | 20 
  1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 2ab78ac..b800bc9 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -520,6 +520,18 @@ libxlDomainShutdownThread(void *opaque)
  case VIR_DOMAIN_LIFECYCLE_ACTION_LAST:
  goto endjob;
  }
+} else if (xl_reason == LIBXL_SHUTDOWN_REASON_SUSPEND) {
+virDomainObjSetState(vm, VIR_DOMAIN_PMSUSPENDED,
+ VIR_DOMAIN_PMSUSPENDED_UNKNOWN);
+
+dom_event = virDomainEventLifecycleNewFromObj(vm,
+   VIR_DOMAIN_EVENT_PMSUSPENDED,
+   
VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY);
+/*
+ * Similar to the xl implementation, ignore SUSPEND.  Any actions 
needed
+ * after calling libxl_domain_suspend() are handled by it's callers.
+ */
+goto endjob;
  } else {
  VIR_INFO("Unhandled shutdown_reason %d", xl_reason);
  goto endjob;
@@ -563,7 +575,6 @@ void
  libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST libxl_event *event)
  {
  libxlDriverPrivatePtr driver = data;
-libxl_shutdown_reason xl_reason = event->u.domain_shutdown.shutdown_reason;
  struct libxlShutdownThreadInfo *shutdown_info = NULL;
  virThread thread;
  libxlDriverConfigPtr cfg;
@@ -574,13 +585,6 @@ libxlDomainEventHandler(void *data, VIR_LIBXL_EVENT_CONST 
libxl_event *event)
  }
  
  /*

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



Reviewed-by: Jim Fehlig 

Regards,
Jim

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

Re: [libvirt] [PATCH] Fix libvirt-driver-libxl check

2018-08-09 Thread Jim Fehlig

On 08/05/2018 03:50 PM, Marek Marczykowski-Górecki wrote:

Fix saving CFLAGS in LIBVIRT_DRIVER_CHECK_LIBXL - LIBVIRT_CHECK_LIB will
override old_CFLAGS, so use a different name.

Signed-off-by: Marek Marczykowski-Górecki 


Reviewed-by: Jim Fehlig 

and pushed.

Regards,
Jim


---
  m4/virt-driver-libxl.m4 | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/m4/virt-driver-libxl.m4 b/m4/virt-driver-libxl.m4
index 2cc1c062d8..90338eb306 100644
--- a/m4/virt-driver-libxl.m4
+++ b/m4/virt-driver-libxl.m4
@@ -46,10 +46,10 @@ AC_DEFUN([LIBVIRT_DRIVER_CHECK_LIBXL], [
  dnl The libxl driver will make use of this new parameter for specifying
  dnl the Xen migration stream version. Specify LIBXL_API_VERSION to trigger
  dnl an error if there is too old xenlight
-old_CFLAGS="$CFLAGS"
+libxlold_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $LIBXL_API_VERSION"
  LIBVIRT_CHECK_LIB([LIBXL], [xenlight], [libxl_ctx_alloc], [libxl.h], 
[fail="1"])
-CFLAGS="$old_CFLAGS"
+CFLAGS="$libxlold_CFLAGS"
  
  if test $fail = 1; then

AC_MSG_ERROR([You must install the libxl Library from Xen >= 4.4 to 
compile libxenlight driver with -lxl])



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

Re: [libvirt] [PATCH] Fix link errors in tools/nss and tests

2018-08-09 Thread Jim Fehlig

On 08/09/2018 07:42 AM, Michal Privoznik wrote:

On 08/08/2018 07:00 PM, Jim Fehlig wrote:

While local builds succeed fine, a build worker building in a chroot
environment is encountering errors when linking some items in tools/nss
and tests, e.g.

[  469s] libtool: link: gcc -shared  -fPIC -DPIC  -Wl,--whole-archive 
nss/.libs/libnss_libvirt_impl.a -Wl,--no-whole-archive  -lpthread -lutil 
-ltirpc  -fstack-protector-strong -grecord-gcc-switches -O2 
-fstack-protector-strong -g -Wl,--version-script=./nss/libvirt_nss.syms -Wl,-z 
-Wl,relro -Wl,-z -Wl,now -Wl,--no-copy-dt-needed-entries -Wl,-z -Wl,defs 
-grecord-gcc-switches -O2 -fstack-protector-strong -g   -pthread -Wl,-soname 
-Wl,libnss_libvirt.so.2 -o nss/.libs/libnss_libvirt.so.2
[  469s] nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virjsoncompat.o): In 
function `virJSONJanssonOnce':
[  469s] /home/abuild/rpmbuild/BUILD/libvirt-4.6.0/src/util/virjsoncompat.c:63: 
undefined reference to `dlopen'
[  469s] /home/abuild/rpmbuild/BUILD/libvirt-4.6.0/src/util/virjsoncompat.c:79: 
undefined reference to `dlsym'
...

A similar problem was fixed in commit b018ada3 and inspires this fix.

Signed-off-by: Jim Fehlig 
---
  tools/Makefile.am | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1452d984a0..26c887649e 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -527,7 +527,8 @@ nss_libnss_libvirt_impl_la_CFLAGS = \
  
  nss_libnss_libvirt_impl_la_LIBADD = \

../gnulib/lib/libgnu.la \
-   ../src/libvirt-nss.la
+   ../src/libvirt-nss.la \
+   $(DLOPEN_LIBS)
  
  nss_libnss_libvirt_la_SOURCES =

  nss_libnss_libvirt_la_LDFLAGS = \
@@ -554,7 +555,8 @@ nss_libnss_libvirt_guest_impl_la_CFLAGS = \
  
  nss_libnss_libvirt_guest_impl_la_LIBADD = \

../gnulib/lib/libgnu.la \
-   ../src/libvirt-nss.la
+   ../src/libvirt-nss.la \
+   $(DLOPEN_LIBS)
  
  nss_libnss_libvirt_guest_la_SOURCES =

  nss_libnss_libvirt_guest_la_LDFLAGS = \



While I agree that we need to put DLOPEN_LIBS somewhere shouldn't be
that the lib that compiles virjsoncompat.c in?


Yes, you are right.


I mean, that is the
source of the dependency and therefore anything linking with it will
need similar treatment. Something among these lines (quickly written and
untested patch):


diff --git i/src/Makefile.am w/src/Makefile.am
index a4f213480e..51c134f08e 100644
--- i/src/Makefile.am
+++ w/src/Makefile.am
@@ -744,6 +744,7 @@ libvirt_setuid_rpc_client_la_LDFLAGS = \
 $(AM_LDFLAGS) \
 $(LIBXML_LIBS) \
 $(SECDRIVER_LIBS) \
+   $(DLOPEN_LIBS) \
 $(NULL)
  libvirt_setuid_rpc_client_la_CFLAGS = \
 -DLIBVIRT_SETUID_RPC_CLIENT \
@@ -1000,6 +1001,7 @@ libvirt_nss_la_CFLAGS = \
 $(NULL)
  libvirt_nss_la_LDFLAGS = \
 $(AM_LDFLAGS) \
+   $(DLOPEN_LIBS) \
 $(NULL)
  endif WITH_NSS

diff --git i/src/util/Makefile.inc.am w/src/util/Makefile.inc.am
index 8ef9ee1dfa..c5c50f1844 100644
--- i/src/util/Makefile.inc.am
+++ w/src/util/Makefile.inc.am
@@ -278,6 +278,7 @@ libvirt_util_la_LIBADD = \
 $(NUMACTL_LIBS) \
 $(ACL_LIBS) \
 $(GNUTLS_LIBS) \
+   $(DLOPEN_LIBS) \
 $(NULL)


I tested the patch, works fine. What is the best course of action since I pushed 
the other one? Revert it and push your patch?


Regards,
Jim

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


Re: [libvirt] [PATCH] qemuBuildBootCommandLine: remove unused boot_order_str

2018-08-09 Thread Andrea Bolognani
On Thu, 2018-08-09 at 18:17 +0200, Ján Tomko wrote:
> After commit caccbba this variable is always NULL.
> 
> Signed-off-by: Ján Tomko 
> ---
>  src/qemu/qemu_command.c | 16 +++-
>  1 file changed, 3 insertions(+), 13 deletions(-)

Reviewed-by: Andrea Bolognani 

-- 
Andrea Bolognani / Red Hat / Virtualization

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

[libvirt] [PATCH] qemuBuildBootCommandLine: remove unused boot_order_str

2018-08-09 Thread Ján Tomko
After commit caccbba this variable is always NULL.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 65bd88a652..12ff09d46d 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6457,7 +6457,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
  virQEMUCapsPtr qemuCaps)
 {
 virBuffer boot_buf = VIR_BUFFER_INITIALIZER;
-char *boot_order_str = NULL, *boot_opts_str = NULL;
+char *boot_opts_str = NULL;
 
 if (def->os.bootmenu) {
 if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES)
@@ -6499,20 +6499,11 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
 goto error;
 
 boot_opts_str = virBufferContentAndReset(_buf);
-if (boot_order_str || boot_opts_str) {
+if (boot_opts_str) {
 virCommandAddArg(cmd, "-boot");
-
-if (boot_order_str && boot_opts_str) {
-virCommandAddArgFormat(cmd, "order=%s,%s",
-   boot_order_str, boot_opts_str);
-} else if (boot_order_str) {
-virCommandAddArg(cmd, boot_order_str);
-} else if (boot_opts_str) {
-virCommandAddArg(cmd, boot_opts_str);
-}
+virCommandAddArg(cmd, boot_opts_str);
 }
 VIR_FREE(boot_opts_str);
-VIR_FREE(boot_order_str);
 
 if (def->os.kernel)
 virCommandAddArgList(cmd, "-kernel", def->os.kernel, NULL);
@@ -6533,7 +6524,6 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
 return 0;
 
  error:
-VIR_FREE(boot_order_str);
 VIR_FREE(boot_opts_str);
 virBufferFreeAndReset(_buf);
 return -1;
-- 
2.16.1

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

Re: [libvirt] [PATCH] network: restrict usage of port management APIs

2018-08-09 Thread Daniel P . Berrangé
On Thu, Aug 09, 2018 at 11:54:42AM -0400, Laine Stump wrote:
> On 08/09/2018 03:58 AM, Daniel P. Berrangé wrote:
> > On Wed, Aug 08, 2018 at 11:41:23PM -0400, Laine Stump wrote:
> >> On 08/08/2018 11:46 AM, Daniel P. Berrangé wrote:
> >>> The port allocation APIs are currently called unconditionally for all
> >>> types of NIC, but (mostly) only do anything for NICs with type=network.
> >>>
> >>> The exception is the port allocate API which does some validation even
> >>> for NICs with type!=network. Relying on this validation is flawed,
> >>> however, since the network driver may not even be installed, so virt
> >>> drivers must not delegation validation to it for NICs with
> >>> type!=network.
> >> Although I never thought through all the minute details to the end (and
> >> didn't need to because ,,,AllocateActualDevice() wasn't in a public
> >> API), I had always figured that these calls into the network driver
> >> would be where, eventually, we would do all of the plumbing for a
> >> network device, like creating the tap/macvtap device during startup, and
> >> disconnecting/deleting devices during domain shutdown. (it also kind of
> >> makes sense for nwfilters to be added/removed by the network driver
> >> during these APIs, since the filterref is in the  definition).
> >>
> >> That's the reason for the unconditional calls.
> >>
> >> (one of the "minute details" that I hadn't thought about was the fact
> >> that we probably can't do *all* of the plumbing at one time - at the
> >> very least we need to have one API call for creating the devices and
> >> hooking them up, and another call that happens right before the guest
> >> CPUs are started (to bring everything online). Still, if we limit the
> >> netAllocate API to only being called for type='network' then we
> >> definitely will need an additional API that will likely be called
> >> unconditionally just after netAllocation is called just for 
> >> type='network'.)
> > Yep, this is a bigger problem than I first considered. We have four
> > hypervisors using tap devices (qemu, lxc, libxl & bhyve) and all of
> > them have different requirements for the way the tap devices are
> > created. This is going to make it hard to delegate everything to the
> > network driver, as the work is hypervisor specific.
> 
> The differences between qemu and lxc were on my mind but, without
> looking, I had naively assumed that "all the others" (including libxl
> and bhve) were just doing something similar to qemu :-/

If anything libxl & bhyve are much closer to LXC in approach, in that
they want a persistent TAP device passed by name, not a transient TAP
device passed by FD.

> >> BTW, once it is the responsibility of the network driver to create tap
> >> devices and connect them to bridges, the network driver will no longer
> >> be optional (unless we want to duplicate the code in the hypervisor
> >> drivers), but that is the price we have to pay in order to give
> >> unprivileged libvirt the ability to use any type of network device.
> > Even if the network driver can create tap devices, I'd still want to
> > deal with type=network vs type=bridge separately for access control
> > purposes. It is desirable to be able to have ACLs on the opening operation
> > and the natural place to attach the ACL is against the virNetworkPtr
> > object. We have no object to represent standalone bridge devices outside
> > of a virNetworkPtr, so nothing to attach an ACL to for creating tap
> > devices.
> 
> So are you saying that the network driver simply wouldn't be able to
> create the tap devices for type=bridge (or type=direct)? I'm not exactly
> following you (although I don't doubt what you say).

That's the direction i'm leaning towards right now at least. Adding the
API is easy, I just don't know what useful security model I could give it.

Consider the original goal was to allow the unprivileged libvirtd to have
useful network connectivity for guests. This means we want unprivileged
libvirtd to be able to request a TAP device without requiring root password
auth.

I don't think it is viable to allow this for arbitrary bridge devices out
of the box.  It is, however, just about reasonable to allow unprivileged
libvirtd to request a connection to the virbr0 "default" virtual network
without root auth, as the connectivity provided by the dfault network
is quite tightly defined.

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

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

Re: [libvirt] [PATCH] network: restrict usage of port management APIs

2018-08-09 Thread Laine Stump
On 08/09/2018 03:58 AM, Daniel P. Berrangé wrote:
> On Wed, Aug 08, 2018 at 11:41:23PM -0400, Laine Stump wrote:
>> On 08/08/2018 11:46 AM, Daniel P. Berrangé wrote:
>>> The port allocation APIs are currently called unconditionally for all
>>> types of NIC, but (mostly) only do anything for NICs with type=network.
>>>
>>> The exception is the port allocate API which does some validation even
>>> for NICs with type!=network. Relying on this validation is flawed,
>>> however, since the network driver may not even be installed, so virt
>>> drivers must not delegation validation to it for NICs with
>>> type!=network.
>> Although I never thought through all the minute details to the end (and
>> didn't need to because ,,,AllocateActualDevice() wasn't in a public
>> API), I had always figured that these calls into the network driver
>> would be where, eventually, we would do all of the plumbing for a
>> network device, like creating the tap/macvtap device during startup, and
>> disconnecting/deleting devices during domain shutdown. (it also kind of
>> makes sense for nwfilters to be added/removed by the network driver
>> during these APIs, since the filterref is in the  definition).
>>
>> That's the reason for the unconditional calls.
>>
>> (one of the "minute details" that I hadn't thought about was the fact
>> that we probably can't do *all* of the plumbing at one time - at the
>> very least we need to have one API call for creating the devices and
>> hooking them up, and another call that happens right before the guest
>> CPUs are started (to bring everything online). Still, if we limit the
>> netAllocate API to only being called for type='network' then we
>> definitely will need an additional API that will likely be called
>> unconditionally just after netAllocation is called just for type='network'.)
> Yep, this is a bigger problem than I first considered. We have four
> hypervisors using tap devices (qemu, lxc, libxl & bhyve) and all of
> them have different requirements for the way the tap devices are
> created. This is going to make it hard to delegate everything to the
> network driver, as the work is hypervisor specific.

The differences between qemu and lxc were on my mind but, without
looking, I had naively assumed that "all the others" (including libxl
and bhve) were just doing something similar to qemu :-/

>
> I'm trying to tackle this is distinct achieveable phases. Even the
> current AllocateActualDevice() method is doing too much at the same
> time. For example, it deals with allocating the resources inside the
> network driver (ie reserving a VF or hostdev), as well as populating
> the virDomainNetActualDef struct, and invoking hook scripts. This
> makes it too tangled up with the hyervisor drivers - for example
> needing a full domain XML is very undesirable.

I've always been hopeful that we could figure out some way to
consolidate everything needed for setup/teardown into just a few well
defined actions (to avoid an explosion of APIs that, as a side effect,
are difficult to explain). But as always, "Easy to do" is easy to say
(and again I find myself using ":-/")


Anyway, as long as I know you're considering this, I'm sure you've got a
better picture in your brain than I do, so

Reviewed-by: Laine Stump 

for the patch.

>
>> BTW, once it is the responsibility of the network driver to create tap
>> devices and connect them to bridges, the network driver will no longer
>> be optional (unless we want to duplicate the code in the hypervisor
>> drivers), but that is the price we have to pay in order to give
>> unprivileged libvirt the ability to use any type of network device.
> Even if the network driver can create tap devices, I'd still want to
> deal with type=network vs type=bridge separately for access control
> purposes. It is desirable to be able to have ACLs on the opening operation
> and the natural place to attach the ACL is against the virNetworkPtr
> object. We have no object to represent standalone bridge devices outside
> of a virNetworkPtr, so nothing to attach an ACL to for creating tap
> devices.

So are you saying that the network driver simply wouldn't be able to
create the tap devices for type=bridge (or type=direct)? I'm not exactly
following you (although I don't doubt what you say).

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

Re: [libvirt] [PATCH v2] qemu: qemuDomainChangeNet: validity checks should be done before XML autocompletion

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 11:21:52AM +0200, Katerina Koukiou wrote:

This patch ensures that changes in attributes of interfaces will be emit
errors accept if they are missing from the XML.
Previously we were falsely reporting successfull updates, because some


*successful


changed attributes got overwritten before the validity checks.


The more I think about this 'feature' that allows you to omit parts of
the changed XML, the weirder it gets.



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

Signed-off-by: Katerina Koukiou 
---
src/qemu/qemu_hotplug.c | 42 +
1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1488f0a7c2..76ab56a479 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -3445,23 +3445,9 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
goto cleanup;
}

-/* info: if newdev->info is empty, fill it in from olddev,
- * otherwise verify that it matches - nothing is allowed to
- * change. (There is no helper function to do this, so
- * individually check the few feidls of virDomainDeviceInfo that
- * are relevant in this case).
+/* info: Nothing is allowed to change. First fill the missing newdev->info
+ * from olddev and then check for changes.


Maybe the other way around (checking first - with respect to what was
specified in the XML, then overwriting) might be cleaner, see below.


 */
-if (!virDomainDeviceAddressIsValid(>info,
-   VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) &&
-virDomainDeviceInfoCopy(>info, >info) < 0) {
-goto cleanup;
-}
-if (!virPCIDeviceAddressEqual(>info.addr.pci,
-  >info.addr.pci)) {
-virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
-   _("cannot modify network device guest PCI address"));
-goto cleanup;
-}
/* grab alias from olddev if not set in newdev */
if (!newdev->info.alias &&
VIR_STRDUP(newdev->info.alias, olddev->info.alias) < 0)
@@ -3469,26 +3455,50 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,

/* device alias is checked already in virDomainDefCompatibleDevice */

+if (newdev->info.rombar == VIR_TRISTATE_BOOL_ABSENT)
+newdev->info.rombar = olddev->info.rombar;
if (olddev->info.rombar != newdev->info.rombar) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
   _("cannot modify network device rom bar setting"));
goto cleanup;
}
+
+if (!newdev->info.romfile &&
+VIR_STRDUP(newdev->info.romfile, olddev->info.romfile) < 0)
+goto cleanup;
if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
   _("cannot modify network rom file"));
goto cleanup;
}
+
+if (newdev->info.bootIndex == 0)
+newdev->info.bootIndex = olddev->info.bootIndex;
if (olddev->info.bootIndex != newdev->info.bootIndex) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
   _("cannot modify network device boot index setting"));
goto cleanup;
}
+
+if (newdev->info.romenabled == VIR_TRISTATE_BOOL_ABSENT)
+newdev->info.romenabled = olddev->info.romenabled;
if (olddev->info.romenabled != newdev->info.romenabled) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
   _("cannot modify network device rom enabled setting"));
goto cleanup;
}
+
+/* if pci addr is missing or is invalid we overwrite it from olddev */
+if (!virDomainDeviceAddressIsValid(>info,
+   VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)) {
+newdev->info.addr.pci = olddev->info.addr.pci;


This is an insufficient way to copy the address. The 'addr' union might
be containing an address of a different type. And the 'info.type' attribute also
needs to be copied, either 1) manually or via a 2) DeviceInfoCopy call.

Also, the checks can be moved to a separate fuction first (qemuDomainChangeNet
is over 400 lines long now), e.g. qemuDomainChangeNetAllowed.

Then either:
1) change the unconditional copy of the attributes not present in newdev
  to call another helper (DeviceInfoCopyIfNeeded? MaybeCopy?) that only fills
  the missing parts; or
2) Make qemuDomainChangeNetAllowed only look at specified attributes and
  move the DeviceInfoCopy call after it. (Also, to prevent memory
  leaks, the original info should be cleared before calling copy)

Jano


+}
+if (!virPCIDeviceAddressEqual(>info.addr.pci,
+  >info.addr.pci)) {


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

Re: [libvirt] [PATCH 1/6] qemu: capabilities: Always assume QEMU_CAPS_BOOTINDEX

2018-08-09 Thread Peter Krempa
On Thu, Aug 09, 2018 at 16:34:56 +0200, Ján Tomko wrote:
> On Thu, Aug 09, 2018 at 02:48:54PM +0200, Peter Krempa wrote:
> > The field was added in qemu v0.13.0-rc0-731-g1ca4d09ae0 so all supported
> > qemu versions now use it.
> > 
> > There's a LOT of test fallout as we did not use capabilities close
> > enough to upstream for many of our tests.
> > 
> > Signed-off-by: Peter Krempa 
> > ---
> 
> Actually, you can also remove these files, since their non-bootindex
> variants will replace them:
> 
> tests/qemuxml2argvdata/boot-complex-bootindex.args| 48 
> -
> tests/qemuxml2argvdata/boot-complex-bootindex.xml | 66 
> 
> tests/qemuxml2argvdata/boot-menu-disable-drive-bootindex.args | 29 
> -
> tests/qemuxml2argvdata/boot-menu-disable-drive-bootindex.xml  | 28 
> 
> tests/qemuxml2argvdata/boot-menu-enable-bootindex.args| 29 
> -
> tests/qemuxml2argvdata/boot-menu-enable-bootindex.xml | 28 
> 
> tests/qemuxml2argvdata/bootindex-floppy-q35.args  | 24 
> -
> tests/qemuxml2argvdata/bootindex-floppy-q35.xml   | 32 
> ---
> tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml | 32 
> 

Thanks! I've squashed these into the commit and pushed the series.


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

Re: [libvirt] [PATCH] qemuxml2xmloutdata: Use more symlinks

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 04:50:58PM +0200, Michal Privoznik wrote:

There are couple of files that are the same in both
qemuxml2argvdata and qemuxml2xmloutdata directories. Link them
instead of having full copy.

Signed-off-by: Michal Privoznik 
---
tests/qemuxml2xmloutdata/boot-floppy-q35.xml   | 33 +---
tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml  | 33 +---


These two are a) identical to each other b) one of them will be made
redundant after Peter pushes the BOOTINDEX capability changes.
If you wait until he pushes it, there might be one less change needed in
this commit.


tests/qemuxml2xmloutdata/disk-virtio-queues.xml| 35 +---
tests/qemuxml2xmloutdata/intel-iommu-machine.xml   | 27 +
tests/qemuxml2xmloutdata/intel-iommu.xml   | 27 +


These are also identical. It makes sense for them to point to their
respective source counterparts. But the followup question is, whether we
want to make the source files point to each other.


tests/qemuxml2xmloutdata/luks-disks.xml| 46 +-
tests/qemuxml2xmloutdata/vcpu-placement-static.xml | 34 +---
7 files changed, 7 insertions(+), 228 deletions(-)
mode change 100644 => 12 tests/qemuxml2xmloutdata/boot-floppy-q35.xml
mode change 100644 => 12 tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml
mode change 100644 => 12 tests/qemuxml2xmloutdata/disk-virtio-queues.xml
mode change 100644 => 12 tests/qemuxml2xmloutdata/intel-iommu-machine.xml
mode change 100644 => 12 tests/qemuxml2xmloutdata/intel-iommu.xml
mode change 100644 => 12 tests/qemuxml2xmloutdata/luks-disks.xml
mode change 100644 => 12 tests/qemuxml2xmloutdata/vcpu-placement-static.xml



One way or another:
Reviewed-by: Ján Tomko 

Jano


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:Fix snapshot creating with vm xml persistent

2018-08-09 Thread Michal Privoznik
On 08/07/2018 01:46 PM, Bobo Du wrote:
> the vm xml will be existed when the vm is undefined after started.
> blockcommit interface also has the bug with above.
> Step1:prepare a vm,eg:test1,start it and undefined
> Step2: virsh snapshot-create-as test1 --disk-only --no-metadata
> Step3:ls /etc/libvirt/qemu/test1.xml,then it will be exist here
> 
> Signed-off-by: Bobo Du  ---
>  src/qemu/qemu_driver.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index fb0d4a8..d977922 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -7570,6 +7570,7 @@ qemuDomainUndefineFlags(virDomainPtr dom,
>  if (!virDomainObjIsActive(vm))
>  qemuDomainRemoveInactive(driver, vm);
>  
> +virDomainDefFree(vm->newDef);
>  ret = 0;
>   endjob:
>  qemuDomainObjEndJob(driver, vm);
> 

This doesn't feel right. Firstly, vm->newDef becomes a stale pointer
after this patch. But more importantly, if snapshot-create-as saves the
xml it is clearly not testing vm->persistent flag and the fix should
focus on that.

Michal

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

Re: [libvirt] [PATCH] conf: rewrite filtering for capabilities lookup

2018-08-09 Thread Michal Privoznik
On 08/03/2018 04:28 PM, Daniel P. Berrangé wrote:
> The virCapabilitiesDomainDataLookupInternal() is given a list of
> parameters representing the desired domain characteristics. It then has
> to look throught the capabilities to identify an acceptable match.
> 
> The virCapsDomainDataCompare() method is used for filtering out
> candidates which don't match the desired criteria. It is called
> primarily from the innermost loops and as such is doing many repeated
> checks. For example if architcture and os type were checked at the top
> level loop the two inner loops could be avoided entirely. If emulator
> and domain type were checked in the 2nd level loop the 3rd level loop
> can be avoided too.
> 
> This change thus removes the virCapsDomainDataCompare() method and puts
> suitable checks at the start of each loop to ensure it executes the
> minimal number of loop iterations possible. The code becomes clearer to
> understand as a nice side-effect.

Unfinished sen... ;-)

> 
> Signed-off-by: Daniel P. Berrangé 
> ---
>  src/conf/capabilities.c | 100 ++--
>  1 file changed, 45 insertions(+), 55 deletions(-)
> 


> @@ -731,6 +720,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps,
>  goto error;
>  }
>  
> +VIR_DEBUG("No match %s", virBufferCurrentContent());
>  virReportError(VIR_ERR_INVALID_ARG,
> _("could not find capabilities for %s"),
> virBufferCurrentContent());
> 

This debug is pretty useless because the error message is the same and
will be in the logs too.

ACK

Michal

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

[libvirt] [PATCH] qemuxml2xmloutdata: Use more symlinks

2018-08-09 Thread Michal Privoznik
There are couple of files that are the same in both
qemuxml2argvdata and qemuxml2xmloutdata directories. Link them
instead of having full copy.

Signed-off-by: Michal Privoznik 
---
 tests/qemuxml2xmloutdata/boot-floppy-q35.xml   | 33 +---
 tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml  | 33 +---
 tests/qemuxml2xmloutdata/disk-virtio-queues.xml| 35 +---
 tests/qemuxml2xmloutdata/intel-iommu-machine.xml   | 27 +
 tests/qemuxml2xmloutdata/intel-iommu.xml   | 27 +
 tests/qemuxml2xmloutdata/luks-disks.xml| 46 +-
 tests/qemuxml2xmloutdata/vcpu-placement-static.xml | 34 +---
 7 files changed, 7 insertions(+), 228 deletions(-)
 mode change 100644 => 12 tests/qemuxml2xmloutdata/boot-floppy-q35.xml
 mode change 100644 => 12 tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml
 mode change 100644 => 12 tests/qemuxml2xmloutdata/disk-virtio-queues.xml
 mode change 100644 => 12 tests/qemuxml2xmloutdata/intel-iommu-machine.xml
 mode change 100644 => 12 tests/qemuxml2xmloutdata/intel-iommu.xml
 mode change 100644 => 12 tests/qemuxml2xmloutdata/luks-disks.xml
 mode change 100644 => 12 tests/qemuxml2xmloutdata/vcpu-placement-static.xml

diff --git a/tests/qemuxml2xmloutdata/boot-floppy-q35.xml 
b/tests/qemuxml2xmloutdata/boot-floppy-q35.xml
deleted file mode 100644
index af685d9c98..00
--- a/tests/qemuxml2xmloutdata/boot-floppy-q35.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-  QEMUGuest1
-  c7a5fdbd-edaf-9455-926a-d65c16db1809
-  219100
-  219100
-  1
-  
-hvm
-
-  
-  
-  destroy
-  restart
-  destroy
-  
-/usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
-
-  
-
-
-
-
-
-
-  
-
diff --git a/tests/qemuxml2xmloutdata/boot-floppy-q35.xml 
b/tests/qemuxml2xmloutdata/boot-floppy-q35.xml
new file mode 12
index 00..2543835ffb
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/boot-floppy-q35.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/boot-floppy-q35.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml 
b/tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml
deleted file mode 100644
index af685d9c98..00
--- a/tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-  QEMUGuest1
-  c7a5fdbd-edaf-9455-926a-d65c16db1809
-  219100
-  219100
-  1
-  
-hvm
-
-  
-  
-  destroy
-  restart
-  destroy
-  
-/usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
-
-  
-
-
-
-
-
-
-  
-
diff --git a/tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml 
b/tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml
new file mode 12
index 00..0ab2dad20f
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/bootindex-floppy-q35.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/disk-virtio-queues.xml 
b/tests/qemuxml2xmloutdata/disk-virtio-queues.xml
deleted file mode 100644
index 37885c6f9c..00
--- a/tests/qemuxml2xmloutdata/disk-virtio-queues.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-  QEMUGuest1
-  c7a5fdbd-edaf-9455-926a-d65c16db1809
-  219136
-  219136
-  1
-  
-hvm
-
-  
-  
-  destroy
-  restart
-  destroy
-  
-/usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
-
-  
-
-
-  
-
-
-
-
-
-  
-
diff --git a/tests/qemuxml2xmloutdata/disk-virtio-queues.xml 
b/tests/qemuxml2xmloutdata/disk-virtio-queues.xml
new file mode 12
index 00..d6773202b7
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/disk-virtio-queues.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/disk-virtio-queues.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/intel-iommu-machine.xml 
b/tests/qemuxml2xmloutdata/intel-iommu-machine.xml
deleted file mode 100644
index 0961e4288d..00
--- a/tests/qemuxml2xmloutdata/intel-iommu-machine.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-  QEMUGuest1
-  c7a5fdbd-edaf-9455-926a-d65c16db1809
-  219100
-  219100
-  1
-  
-hvm
-
-  
-  
-  destroy
-  restart
-  destroy
-  
-/usr/bin/qemu-system-x86_64
-
-
-  
-
-
-
-
-
-  
-
diff --git a/tests/qemuxml2xmloutdata/intel-iommu-machine.xml 
b/tests/qemuxml2xmloutdata/intel-iommu-machine.xml
new file mode 12
index 00..dd29ce5ff0
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/intel-iommu-machine.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/intel-iommu-machine.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/intel-iommu.xml 
b/tests/qemuxml2xmloutdata/intel-iommu.xml
deleted file mode 100644
index 0961e4288d..00
--- a/tests/qemuxml2xmloutdata/intel-iommu.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-  QEMUGuest1
-  c7a5fdbd-edaf-9455-926a-d65c16db1809
-  219100
-  219100
-  1
-  
-hvm
-
-  
-  
-  destroy
-  restart
-  

Re: [libvirt] [PATCH 1/6] qemu: capabilities: Always assume QEMU_CAPS_BOOTINDEX

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:54PM +0200, Peter Krempa wrote:

The field was added in qemu v0.13.0-rc0-731-g1ca4d09ae0 so all supported
qemu versions now use it.

There's a LOT of test fallout as we did not use capabilities close
enough to upstream for many of our tests.

Signed-off-by: Peter Krempa 
---


Actually, you can also remove these files, since their non-bootindex
variants will replace them:

tests/qemuxml2argvdata/boot-complex-bootindex.args| 48 
-
tests/qemuxml2argvdata/boot-complex-bootindex.xml | 66 

tests/qemuxml2argvdata/boot-menu-disable-drive-bootindex.args | 29 
-
tests/qemuxml2argvdata/boot-menu-disable-drive-bootindex.xml  | 28 

tests/qemuxml2argvdata/boot-menu-enable-bootindex.args| 29 
-
tests/qemuxml2argvdata/boot-menu-enable-bootindex.xml | 28 

tests/qemuxml2argvdata/bootindex-floppy-q35.args  | 24 
-
tests/qemuxml2argvdata/bootindex-floppy-q35.xml   | 32 
---
tests/qemuxml2xmloutdata/bootindex-floppy-q35.xml | 32 


Jano


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

Re: [libvirt] [PATCH 6/6] qemu: domain: Fix machine type version check for 'isa-fdc' usage

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:59PM +0200, Peter Krempa wrote:

Starting from pc-q35-2.4 the floppy controller is not enabled by
default. Fix the version check so that it does not match 2.11 as being
2.1.



O:-)

Thanks.


Signed-off-by: Peter Krempa 
---
src/qemu/qemu_domain.c   | 12 
.../qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args |  4 +---
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a5d81f863b..654cd4b872 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9427,10 +9427,14 @@ qemuDomainMachineNeedsFDC(const char *machine)

if (p) {
if (STRPREFIX(p, "1.") ||
-STRPREFIX(p, "2.0") ||
-STRPREFIX(p, "2.1") ||
-STRPREFIX(p, "2.2") ||
-STRPREFIX(p, "2.3"))
+STREQ(p, "2.0") ||
+STRPREFIX(p, "2.0-") ||
+STREQ(p, "2.1") ||
+STRPREFIX(p, "2.1-") ||
+STREQ(p, "2.2") ||
+STRPREFIX(p, "2.2-") ||
+STREQ(p, "2.3") ||
+STRPREFIX(p, "2.3-"))


I think STREQs are just enough here - unless you know of any downstreams
adding something after the QEMU version after a dash.


Reviewed-by: Ján Tomko 

Jano


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

Re: [libvirt] [PATCH 5/6] qemu: command: Don't format -device isa-fdc, ... twice with two floppy drives

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:58PM +0200, Peter Krempa wrote:

Fix regression introduced in 42fd5a58adb. With q35 machine type which


Please wrap the commit id in <> or rephrase the sentence to have the
commit id separated by spaces.


requires the explicitly specified FDC we'd format two  isa-fdc


two spaces


controllers to the command line as the code was moved to a place where
it's called per-disk.

Move the call back after formatting all disks and reiterate the disks to
find the floppy controllers.

This also moves the '-global' directive which sets up the default
ISA-FDC to the end after all the disks but since we are modifying the
properties it is safe to do so.

Signed-off-by: Peter Krempa 
---
src/qemu/qemu_command.c| 100 +
tests/qemuxml2argvdata/boot-complex-bootindex.args |   2 +-
tests/qemuxml2argvdata/boot-complex.args   |   2 +-
tests/qemuxml2argvdata/boot-strict.args|   2 +-
.../disk-floppy-q35-2_11.x86_64-latest.args|   2 +-
.../disk-floppy-q35-2_9.x86_64-latest.args |   3 +-
tests/qemuxml2argvdata/disk-floppy-tray.args   |   2 +-
tests/qemuxml2argvdata/disk-floppy.args|   2 +-
.../disk-floppy.x86_64-latest.args |   2 +-
tests/qemuxml2argvdata/user-aliases.args   |   2 +-
10 files changed, 71 insertions(+), 48 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index daf037328f..1169164a39 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2143,50 +2143,78 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,


static int
-qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
-  const virDomainDef *def,
-  virDomainDiskDefPtr disk,
-  virQEMUCapsPtr qemuCaps,
-  unsigned int bootindex)
+qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
+const virDomainDef *def,
+virQEMUCapsPtr qemuCaps,
+unsigned int bootFloppy)
{
virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
+bool explicitfdc = qemuDomainNeedsFDC(def);
+bool hasfloppy = false;
+unsigned int bootindex;
char driveLetter;
char *backendAlias = NULL;
char *backendStr = NULL;
char *bootindexStr = NULL;
+size_t i;
int ret = -1;

-if (disk->info.addr.drive.unit)
-driveLetter = 'B';
-else
-driveLetter = 'A';
+virBufferAddLit(_opts, "isa-fdc,");

-if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, ) < 0)
-goto cleanup;
+for (i = 0; i < def->ndisks; i++) {
+virDomainDiskDefPtr disk = def->disks[i];

-if (backendAlias &&
-virAsprintf(, "drive%c=%s", driveLetter, backendAlias) < 0)
-goto cleanup;
+if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
+continue;

-if (bootindex &&
-virAsprintf(, "bootindex%c=%u", driveLetter, bootindex) < 
0)
-goto cleanup;
+hasfloppy = true;

-if (!qemuDomainNeedsFDC(def)) {
-if (backendStr) {
-virCommandAddArg(cmd, "-global");
-virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
-}
+if (disk->info.bootIndex)
+bootindex = disk->info.bootIndex;
+else
+bootindex = bootFloppy;

-if (bootindexStr) {
-virCommandAddArg(cmd, "-global");
-virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
+bootFloppy = 0;


before, we only zeroed bootFloppy if we have used it, not if we used
disk->info.bootIndex


+
+if (disk->info.addr.drive.unit)
+driveLetter = 'B';
+else
+driveLetter = 'A';
+
+if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, ) < 0)
+goto cleanup;
+
+if (backendAlias &&
+virAsprintf(, "drive%c=%s", driveLetter, backendAlias) 
< 0)
+goto cleanup;
+
+if (bootindex &&
+virAsprintf(, "bootindex%c=%u", driveLetter, bootindex) 
< 0)
+goto cleanup;
+
+if (!explicitfdc) {
+if (backendStr) {
+virCommandAddArg(cmd, "-global");
+virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
+}
+
+if (bootindexStr) {
+virCommandAddArg(cmd, "-global");
+virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
+}
+} else {
+virBufferStrcat(_opts, backendStr, ",", NULL);
+virBufferStrcat(_opts, bootindexStr, ",", NULL);
}
-} else {
+
+VIR_FREE(backendAlias);
+VIR_FREE(backendStr);
+VIR_FREE(bootindexStr);
+}
+
+


Two empty lines.


+if (explicitfdc && hasfloppy) {
/* Newer Q35 machine types require an explicit FDC 

Re: [libvirt] [jenkins-ci PATCH] projects: Don't use ~/rpmbuild for osinfo-db

2018-08-09 Thread Daniel P . Berrangé
On Thu, Aug 09, 2018 at 03:57:00PM +0200, Andrea Bolognani wrote:
> Commit 15a19dbc0b73 made sure all explicit calls use
> the current directory instead of ~/rpmbuild as workspace,
> but osinfo-db wasn't affected by the change since its
> build recipe calls the custom 'make rpm' target and
> continued storing build artifacts in ~/rpmbuild.
> 
> Signed-off-by: Andrea Bolognani 
> ---
>  projects/osinfo-db.yaml | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/projects/osinfo-db.yaml b/projects/osinfo-db.yaml
> index 141a373..d154c98 100644
> --- a/projects/osinfo-db.yaml
> +++ b/projects/osinfo-db.yaml
> @@ -19,7 +19,5 @@
>parent_jobs: 'osinfo-db-master-check'
>machines: '{rpm_machines}'
>command: |
> -rm -f *.tar.{archive_format}
> -$MAKE osinfo-db.spec
>  perl -i -p -e 's/BuildRequires: osinfo-db-tools.*//' 
> osinfo-db.spec
> -$MAKE rpm
> +rpmbuild --clean --define "_topdir `pwd`/rpmbuild" --define 
> "_sourcedir `pwd`" -ba osinfo-db.spec


Reviewed-by: Daniel P. Berrangé 

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

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

Re: [libvirt] [PATCH 3/6] qemu: Remove unused argument 'bootable' from qemuBuildDriveStr

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:56PM +0200, Peter Krempa wrote:

Now that the argument is unused we can remove it transitively from all
the call graphs.

Signed-off-by: Peter Krempa 
---
src/qemu/qemu_command.c | 20 +++-
src/qemu/qemu_command.h |  3 +--
src/qemu/qemu_hotplug.c |  2 +-
3 files changed, 9 insertions(+), 16 deletions(-)



Reviewed-by: Ján Tomko 

Jano


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

[libvirt] [jenkins-ci PATCH] projects: Don't use ~/rpmbuild for osinfo-db

2018-08-09 Thread Andrea Bolognani
Commit 15a19dbc0b73 made sure all explicit calls use
the current directory instead of ~/rpmbuild as workspace,
but osinfo-db wasn't affected by the change since its
build recipe calls the custom 'make rpm' target and
continued storing build artifacts in ~/rpmbuild.

Signed-off-by: Andrea Bolognani 
---
 projects/osinfo-db.yaml | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/projects/osinfo-db.yaml b/projects/osinfo-db.yaml
index 141a373..d154c98 100644
--- a/projects/osinfo-db.yaml
+++ b/projects/osinfo-db.yaml
@@ -19,7 +19,5 @@
   parent_jobs: 'osinfo-db-master-check'
   machines: '{rpm_machines}'
   command: |
-rm -f *.tar.{archive_format}
-$MAKE osinfo-db.spec
 perl -i -p -e 's/BuildRequires: osinfo-db-tools.*//' osinfo-db.spec
-$MAKE rpm
+rpmbuild --clean --define "_topdir `pwd`/rpmbuild" --define 
"_sourcedir `pwd`" -ba osinfo-db.spec
-- 
2.17.1

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


Re: [libvirt] [PATCH 4/6] tests: qemuxml2argv: Add 2 floppy drive tests for q35 with 2.9 and 2.11 machine

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:57PM +0200, Peter Krempa wrote:

The floppy drive command line is different on the q35 machine. Make sure
to test that both drives are supported and also multiple machine
versions as we generate the commandline differently.

Note that both output files show wrong command line which will be fixed
subsequently.

Signed-off-by: Peter Krempa 
---
.../disk-floppy-q35-2_11.x86_64-latest.args| 37 +
tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml| 38 ++
.../disk-floppy-q35-2_9.x86_64-latest.args | 36 
tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml | 38 ++
tests/qemuxml2argvtest.c   |  2 ++
5 files changed, 151 insertions(+)
create mode 100644 
tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml
create mode 100644 tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml



Reviewed-by: Ján Tomko 

Jano


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

Re: [libvirt] [PATCH 2/6] qemu: capabilities: Remove unused QEMU_CAPS_DRIVE_BOOT

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:55PM +0200, Peter Krempa wrote:

The capability was never set except for (stale) tests. Remove it.

Signed-off-by: Peter Krempa 
---
src/qemu/qemu_capabilities.h |  2 +-
src/qemu/qemu_command.c  | 19 +--
tests/qemuxml2argvtest.c | 26 +-
3 files changed, 11 insertions(+), 36 deletions(-)



Reviewed-by: Ján Tomko 

Jano


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

Re: [libvirt] [PATCH 1/6] qemu: capabilities: Always assume QEMU_CAPS_BOOTINDEX

2018-08-09 Thread Ján Tomko

On Thu, Aug 09, 2018 at 02:48:54PM +0200, Peter Krempa wrote:

The field was added in qemu v0.13.0-rc0-731-g1ca4d09ae0 so all supported
qemu versions now use it.

There's a LOT of test fallout as we did not use capabilities close
enough to upstream for many of our tests.

Signed-off-by: Peter Krempa 
---
src/qemu/qemu_capabilities.c   |  4 +-
src/qemu/qemu_capabilities.h   |  2 +-
src/qemu/qemu_command.c| 96 +-
tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |  1 -


[...]


tests/qemuxml2argvdata/watchdog-injectnmi.args |  4 +-
tests/qemuxml2argvdata/watchdog.args   |  4 +-
tests/qemuxml2argvdata/x86-kvm-32-on-64.args   |  3 +-
tests/qemuxml2argvtest.c   | 39 +++--
tests/qemuxml2xmltest.c|  5 +-
597 files changed, 691 insertions(+), 1076 deletions(-)



Reviewed-by: Ján Tomko 

Jano


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

[libvirt] [PATCH 13/17] vircgroup: Introduce virCgroupEnableMissingControllers

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 103 ---
 1 file changed, 58 insertions(+), 45 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 45fe2595d1..99cbdaa59b 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1494,6 +1494,58 @@ virCgroupNewDetectMachine(const char *name,
 }
 
 
+static int
+virCgroupEnableMissingControllers(char *path,
+  pid_t pidleader,
+  int controllers,
+  virCgroupPtr *group)
+{
+virCgroupPtr parent = NULL;
+char *offset = path;
+int ret = -1;
+
+if (virCgroupNew(pidleader,
+ "",
+ NULL,
+ controllers,
+ ) < 0)
+return ret;
+
+for (;;) {
+virCgroupPtr tmp;
+char *t = strchr(offset + 1, '/');
+if (t)
+*t = '\0';
+
+if (virCgroupNew(pidleader,
+ path,
+ parent,
+ controllers,
+ ) < 0)
+goto cleanup;
+
+if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_NONE) < 0) {
+virCgroupFree();
+goto cleanup;
+}
+if (t) {
+*t = '/';
+offset = t;
+virCgroupFree();
+parent = tmp;
+} else {
+*group = tmp;
+break;
+}
+}
+
+ret = 0;
+ cleanup:
+virCgroupFree();
+return ret;
+}
+
+
 /*
  * Returns 0 on success, -1 on fatal error, -2 on systemd not available
  */
@@ -1510,11 +1562,9 @@ virCgroupNewMachineSystemd(const char *name,
int controllers,
virCgroupPtr *group)
 {
-int ret = -1;
 int rv;
-virCgroupPtr init, parent = NULL;
+virCgroupPtr init;
 VIR_AUTOFREE(char *) path = NULL;
-char *offset;
 
 VIR_DEBUG("Trying to setup machine '%s' via systemd", name);
 if ((rv = virSystemdCreateMachine(name,
@@ -1543,46 +1593,12 @@ virCgroupNewMachineSystemd(const char *name,
 
 if (!path || STREQ(path, "/") || path[0] != '/') {
 VIR_DEBUG("Systemd didn't setup its controller");
-ret = -2;
-goto cleanup;
+return -2;
 }
 
-offset = path;
-
-if (virCgroupNew(pidleader,
- "",
- NULL,
- controllers,
- ) < 0)
-goto cleanup;
-
-
-for (;;) {
-virCgroupPtr tmp;
-char *t = strchr(offset + 1, '/');
-if (t)
-*t = '\0';
-
-if (virCgroupNew(pidleader,
- path,
- parent,
- controllers,
- ) < 0)
-goto cleanup;
-
-if (virCgroupMakeGroup(parent, tmp, true, VIR_CGROUP_NONE) < 0) {
-virCgroupFree();
-goto cleanup;
-}
-if (t) {
-*t = '/';
-offset = t;
-virCgroupFree();
-parent = tmp;
-} else {
-*group = tmp;
-break;
-}
+if (virCgroupEnableMissingControllers(path, pidleader,
+  controllers, group) < 0) {
+return -1;
 }
 
 if (virCgroupAddTask(*group, pidleader) < 0) {
@@ -1595,10 +1611,7 @@ virCgroupNewMachineSystemd(const char *name,
 }
 }
 
-ret = 0;
- cleanup:
-virCgroupFree();
-return ret;
+return 0;
 }
 
 
-- 
2.17.1

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


[libvirt] [PATCH 15/17] vircgroup: Remove virCgroupAddTaskController

2018-08-09 Thread Pavel Hrdina
There is no need for this function, both of the checks are done
later by virCgroupGetControllerPath.

Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 31 +--
 1 file changed, 1 insertion(+), 30 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 84f5c4197f..37982a9607 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1128,35 +1128,6 @@ virCgroupNew(pid_t pid,
 }
 
 
-/**
- * virCgroupAddTaskController:
- *
- * @group: The cgroup to add a task to
- * @pid: The pid of the task to add
- * @controller: The cgroup controller to be operated on
- *
- * Returns: 0 on success or -1 on error
- */
-static int
-virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller)
-{
-if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Controller %d out of range"), controller);
-return -1;
-}
-
-if (!group->controllers[controller].mountPoint) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Controller '%s' not mounted"),
-   virCgroupControllerTypeToString(controller));
-return -1;
-}
-
-return virCgroupSetValueI64(group, controller, "tasks", pid);
-}
-
-
 static int
 virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
 {
@@ -1174,7 +1145,7 @@ virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, 
bool withSystemd)
 if (i == VIR_CGROUP_CONTROLLER_SYSTEMD && !withSystemd)
 continue;
 
-if (virCgroupAddTaskController(group, pid, i) < 0)
+if (virCgroupSetValueI64(group, i, "tasks", pid) < 0)
 goto cleanup;
 }
 
-- 
2.17.1

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


[libvirt] [PATCH 09/17] vircgroup: Move function used in tests into vircgrouppriv.h

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.h | 13 -
 src/util/vircgrouppriv.h | 13 +
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 138bb3c076..48be077aba 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -64,22 +64,9 @@ typedef enum {
 
 bool virCgroupAvailable(void);
 
-int virCgroupNewPartition(const char *path,
-  bool create,
-  int controllers,
-  virCgroupPtr *group)
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
-
 int virCgroupNewSelf(virCgroupPtr *group)
 ATTRIBUTE_NONNULL(1);
 
-int virCgroupNewDomainPartition(virCgroupPtr partition,
-const char *driver,
-const char *name,
-bool create,
-virCgroupPtr *group)
-ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
-
 int virCgroupNewThread(virCgroupPtr domain,
virCgroupThreadName nameval,
int id,
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
index 1b47d3b858..a0034f3889 100644
--- a/src/util/vircgrouppriv.h
+++ b/src/util/vircgrouppriv.h
@@ -54,4 +54,17 @@ int virCgroupDetectMountsFromFile(virCgroupPtr group,
   const char *path,
   bool checkLinks);
 
+int virCgroupNewPartition(const char *path,
+  bool create,
+  int controllers,
+  virCgroupPtr *group)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4);
+
+int virCgroupNewDomainPartition(virCgroupPtr partition,
+const char *driver,
+const char *name,
+bool create,
+virCgroupPtr *group)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5);
+
 #endif /* __VIR_CGROUP_PRIV_H__ */
-- 
2.17.1

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


[libvirt] [PATCH 12/17] vircgroup: Use virCgroupMountOptsMatchController in virCgroupDetectPlacement

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 43 ++-
 1 file changed, 14 insertions(+), 29 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 52be5e5fb8..45fe2595d1 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -598,42 +598,27 @@ virCgroupDetectPlacement(virCgroupPtr group,
 
 for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
 const char *typestr = virCgroupControllerTypeToString(i);
-int typelen = strlen(typestr);
-char *tmp = controllers;
-
-while (tmp) {
-char *next = strchr(tmp, ',');
-int len;
-if (next) {
-len = next - tmp;
-next++;
-} else {
-len = strlen(tmp);
-}
 
+if (virCgroupMountOptsMatchController(controllers, typestr) &&
+group->controllers[i].mountPoint != NULL &&
+group->controllers[i].placement == NULL) {
 /*
  * selfpath == "/" + path="" -> "/"
  * selfpath == "/libvirt.service" + path == "" -> 
"/libvirt.service"
  * selfpath == "/libvirt.service" + path == "foo" -> 
"/libvirt.service/foo"
  */
-if (typelen == len && STREQLEN(typestr, tmp, len) &&
-group->controllers[i].mountPoint != NULL &&
-group->controllers[i].placement == NULL) {
-if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
-if (VIR_STRDUP(group->controllers[i].placement,
-   selfpath) < 0)
-goto cleanup;
-} else {
-if (virAsprintf(>controllers[i].placement,
-"%s%s%s", selfpath,
-(STREQ(selfpath, "/") ||
- STREQ(path, "") ? "" : "/"),
-path) < 0)
-goto cleanup;
-}
+if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
+if (VIR_STRDUP(group->controllers[i].placement,
+   selfpath) < 0)
+goto cleanup;
+} else {
+if (virAsprintf(>controllers[i].placement,
+"%s%s%s", selfpath,
+(STREQ(selfpath, "/") ||
+ STREQ(path, "") ? "" : "/"),
+path) < 0)
+goto cleanup;
 }
-
-tmp = next;
 }
 }
 }
-- 
2.17.1

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


[libvirt] [PATCH 14/17] vircgroup: machinename will never be NULL

2018-08-09 Thread Pavel Hrdina
Commit  moved machineName
generation before virCgroupNewDetectMachine() is called.

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

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 99cbdaa59b..84f5c4197f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -266,27 +266,22 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
 if (virCgroupPartitionEscape() < 0)
 return false;
 
-if (machinename &&
-(virAsprintf(, "%s.libvirt-%s",
- machinename, drivername) < 0 ||
- virCgroupPartitionEscape() < 0))
+if (virAsprintf(, "%s.libvirt-%s",
+machinename, drivername) < 0 ||
+virCgroupPartitionEscape() < 0)
 return false;
 
 if (!(scopename_old = virSystemdMakeScopeName(name, drivername, true)))
 return false;
 
-/* We should keep trying even if this failed */
-if (!machinename)
-virResetLastError();
-else if (!(scopename_new = virSystemdMakeScopeName(machinename,
-   drivername, false)))
+if (!(scopename_new = virSystemdMakeScopeName(machinename,
+  drivername, false)))
 return false;
 
 if (virCgroupPartitionEscape(_old) < 0)
 return false;
 
-if (scopename_new &&
-virCgroupPartitionEscape(_new) < 0)
+if (virCgroupPartitionEscape(_new) < 0)
 return false;
 
 for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
@@ -315,16 +310,16 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
 tmp++;
 
 if (STRNEQ(tmp, name) &&
-STRNEQ_NULLABLE(tmp, machinename) &&
+STRNEQ(tmp, machinename) &&
 STRNEQ(tmp, partname) &&
-STRNEQ_NULLABLE(tmp, partmachinename) &&
+STRNEQ(tmp, partmachinename) &&
 STRNEQ(tmp, scopename_old) &&
-STRNEQ_NULLABLE(tmp, scopename_new)) {
+STRNEQ(tmp, scopename_new)) {
 VIR_DEBUG("Name '%s' for controller '%s' does not match "
   "'%s', '%s', '%s', '%s' or '%s'",
   tmp, virCgroupControllerTypeToString(i),
-  name, NULLSTR(machinename), partname,
-  scopename_old, NULLSTR(scopename_new));
+  name, machinename, partname,
+  scopename_old, scopename_new);
 return false;
 }
 }
-- 
2.17.1

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


[libvirt] [PATCH 02/17] docs: Update how we create cgroup directory names

2018-08-09 Thread Pavel Hrdina
Commit  changed the way how cgroup directory names are
constructed but the documentation was not updated.

Signed-off-by: Pavel Hrdina 
---
 docs/cgroups.html.in | 34 ++
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/docs/cgroups.html.in b/docs/cgroups.html.in
index a498590c45..081ba2eae1 100644
--- a/docs/cgroups.html.in
+++ b/docs/cgroups.html.in
@@ -76,11 +76,13 @@
 
   The systemd convention is for the scope name of virtual machines / 
containers
   to be of the general format machine-$NAME.scope. Libvirt 
forms the
-  $NAME part of this by concatenating the driver type with 
the name
-  of the guest, and then escaping any systemd reserved characters.
+  $NAME part of this by concatenating the driver type with 
the id
+  and truncated name of the guest, and then escaping any systemd reserved
+  characters.
   So for a guest demo running under the lxc 
driver,
-  we get a $NAME of lxc-demo which when escaped 
is
-  lxc\x2ddemo. So the complete scope name is 
machine-lxc\x2ddemo.scope.
+  we get a $NAME of lxc-12345-demo which when 
escaped
+  is lxc\x2d12345\x2ddemo. So the complete scope name is
+  machine-lxc\x2d12345\x2ddemo.scope.
   The scope names map directly to the cgroup directory names.
 
 
@@ -113,19 +115,19 @@ $ROOT
   |
   +- machine.slice
   |
-  +- machine-qemu\x2dvm1.scope
+  +- machine-qemu\x2d1\x2dvm1.scope
   |   |
   |   +- emulator
   |   +- vcpu0
   |   +- vcpu1
   |
-  +- machine-qemu\x2dvm2.scope
+  +- machine-qemu\x2d2\x2dvm2.scope
   |   |
   |   +- emulator
   |   +- vcpu0
   |   +- vcpu1
   |
-  +- machine-qemu\x2dvm3.scope
+  +- machine-qemu\x2d3\x2dvm3.scope
   |   |
   |   +- emulator
   |   +- vcpu0
@@ -135,15 +137,15 @@ $ROOT
   |   |
   |   +- machine-engineering-testing.slice
   |   |   |
-  |   |   +- machine-lxc\x2dcontainer1.scope
+  |   |   +- machine-lxc\x2d1\x2dcontainer1.scope
   |   |
   |   +- machine-engineering-production.slice
   |   |
-  |   +- machine-lxc\x2dcontainer2.scope
+  |   +- machine-lxc\x2d2\x2dcontainer2.scope
   |
   +- machine-marketing.slice
   |
-  +- machine-lxc\x2dcontainer3.scope
+  +- machine-lxc\x2d3\x2dcontainer3.scope
 
 
 Non-systemd cgroups layout
@@ -174,19 +176,19 @@ $ROOT
   |
   +- machine
   |
-  +- vm1.libvirt-qemu
+  +- qemu-1-vm1.libvirt-qemu
   |   |
   |   +- emulator
   |   +- vcpu0
   |   +- vcpu1
   |
-  +- vm2.libvirt-qemu
+  +- qeme-2-vm2.libvirt-qemu
   |   |
   |   +- emulator
   |   +- vcpu0
   |   +- vcpu1
   |
-  +- vm3.libvirt-qemu
+  +- qemu-3-vm3.libvirt-qemu
   |   |
   |   +- emulator
   |   +- vcpu0
@@ -196,15 +198,15 @@ $ROOT
   |   |
   |   +- testing.partition
   |   |   |
-  |   |   +- container1.libvirt-lxc
+  |   |   +- lxc-1-container1.libvirt-lxc
   |   |
   |   +- production.partition
   |   |
-  |   +- container2.libvirt-lxc
+  |   +- lxc-2-container2.libvirt-lxc
   |
   +- marketing.partition
   |
-  +- container3.libvirt-lxc
+  +- lxc-3-container3.libvirt-lxc
 
 
 Using custom partitions
-- 
2.17.1

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


[libvirt] [PATCH 05/17] vircgroup: Extract file link resolving into separate function

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 85 +---
 1 file changed, 48 insertions(+), 37 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 5144b33d43..fd58ba154f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -356,6 +356,51 @@ virCgroupCopyMounts(virCgroupPtr group,
 }
 
 
+static int
+virCgroupResolveMountLink(const char *mntDir,
+  const char *typeStr,
+  virCgroupControllerPtr controller)
+{
+VIR_AUTOFREE(char *) linkSrc = NULL;
+char *dirName;
+struct stat sb;
+
+dirName = strrchr(mntDir, '/');
+if (!dirName) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Missing '/' separator in cgroup mount '%s'"), 
mntDir);
+return -1;
+}
+
+if (!strchr(dirName + 1, ','))
+return 0;
+
+*dirName = '\0';
+if (virAsprintf(, "%s/%s", mntDir, typeStr) < 0)
+return -1;
+*dirName = '/';
+
+if (lstat(linkSrc, ) < 0) {
+if (errno == ENOENT) {
+VIR_WARN("Controller %s co-mounted at %s is missing symlink at %s",
+ typeStr, mntDir, linkSrc);
+} else {
+virReportSystemError(errno, _("Cannot stat %s"), linkSrc);
+return -1;
+}
+} else {
+if (!S_ISLNK(sb.st_mode)) {
+VIR_WARN("Expecting a symlink at %s for controller %s",
+ linkSrc, typeStr);
+} else {
+VIR_STEAL_PTR(controller->linkPoint, linkSrc);
+}
+}
+
+return 0;
+}
+
+
 /*
  * Process /proc/mounts figuring out what controllers are
  * mounted and where
@@ -397,8 +442,6 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
 }
 
 if (typelen == len && STREQLEN(typestr, tmp, len)) {
-struct stat sb;
-char *tmp2;
 
 /* Note that the lines in /proc/mounts have the same
  * order than the mount operations, and that there may
@@ -412,44 +455,12 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
 if (VIR_STRDUP(controller->mountPoint, entry.mnt_dir) < 0)
 goto cleanup;
 
-tmp2 = strrchr(entry.mnt_dir, '/');
-if (!tmp2) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Missing '/' separator in cgroup 
mount '%s'"),
-   entry.mnt_dir);
-goto cleanup;
-}
-
 /* If it is a co-mount it has a filename like "cpu,cpuacct"
  * and we must identify the symlink path */
-if (checkLinks && strchr(tmp2 + 1, ',')) {
-VIR_AUTOFREE(char *) linksrc = NULL;
-
-*tmp2 = '\0';
-if (virAsprintf(, "%s/%s",
-entry.mnt_dir, typestr) < 0)
+if (checkLinks &&
+virCgroupResolveMountLink(entry.mnt_dir, typestr,
+  controller) < 0) {
 goto cleanup;
-*tmp2 = '/';
-
-if (lstat(linksrc, ) < 0) {
-if (errno == ENOENT) {
-VIR_WARN("Controller %s co-mounted at %s is 
missing symlink at %s",
- typestr, entry.mnt_dir, linksrc);
-} else {
-virReportSystemError(errno,
- _("Cannot stat %s"),
- linksrc);
-goto cleanup;
-}
-} else {
-if (!S_ISLNK(sb.st_mode)) {
-VIR_WARN("Expecting a symlink at %s for 
controller %s",
- linksrc, typestr);
-} else {
-controller->linkPoint = linksrc;
-linksrc = NULL;
-}
-}
 }
 }
 tmp = next;
-- 
2.17.1

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


Re: [libvirt] [PATCH] Fix link errors in tools/nss and tests

2018-08-09 Thread Michal Privoznik
On 08/08/2018 07:00 PM, Jim Fehlig wrote:
> While local builds succeed fine, a build worker building in a chroot
> environment is encountering errors when linking some items in tools/nss
> and tests, e.g.
> 
> [  469s] libtool: link: gcc -shared  -fPIC -DPIC  -Wl,--whole-archive 
> nss/.libs/libnss_libvirt_impl.a -Wl,--no-whole-archive  -lpthread -lutil 
> -ltirpc  -fstack-protector-strong -grecord-gcc-switches -O2 
> -fstack-protector-strong -g -Wl,--version-script=./nss/libvirt_nss.syms 
> -Wl,-z -Wl,relro -Wl,-z -Wl,now -Wl,--no-copy-dt-needed-entries -Wl,-z 
> -Wl,defs -grecord-gcc-switches -O2 -fstack-protector-strong -g   -pthread 
> -Wl,-soname -Wl,libnss_libvirt.so.2 -o nss/.libs/libnss_libvirt.so.2
> [  469s] nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virjsoncompat.o): In 
> function `virJSONJanssonOnce':
> [  469s] 
> /home/abuild/rpmbuild/BUILD/libvirt-4.6.0/src/util/virjsoncompat.c:63: 
> undefined reference to `dlopen'
> [  469s] 
> /home/abuild/rpmbuild/BUILD/libvirt-4.6.0/src/util/virjsoncompat.c:79: 
> undefined reference to `dlsym'
> ...
> 
> A similar problem was fixed in commit b018ada3 and inspires this fix.
> 
> Signed-off-by: Jim Fehlig 
> ---
>  tools/Makefile.am | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/Makefile.am b/tools/Makefile.am
> index 1452d984a0..26c887649e 100644
> --- a/tools/Makefile.am
> +++ b/tools/Makefile.am
> @@ -527,7 +527,8 @@ nss_libnss_libvirt_impl_la_CFLAGS = \
>  
>  nss_libnss_libvirt_impl_la_LIBADD = \
>   ../gnulib/lib/libgnu.la \
> - ../src/libvirt-nss.la
> + ../src/libvirt-nss.la \
> + $(DLOPEN_LIBS)
>  
>  nss_libnss_libvirt_la_SOURCES =
>  nss_libnss_libvirt_la_LDFLAGS = \
> @@ -554,7 +555,8 @@ nss_libnss_libvirt_guest_impl_la_CFLAGS = \
>  
>  nss_libnss_libvirt_guest_impl_la_LIBADD = \
>   ../gnulib/lib/libgnu.la \
> - ../src/libvirt-nss.la
> + ../src/libvirt-nss.la \
> + $(DLOPEN_LIBS)
>  
>  nss_libnss_libvirt_guest_la_SOURCES =
>  nss_libnss_libvirt_guest_la_LDFLAGS = \
> 

While I agree that we need to put DLOPEN_LIBS somewhere shouldn't be
that the lib that compiles virjsoncompat.c in? I mean, that is the
source of the dependency and therefore anything linking with it will
need similar treatment. Something among these lines (quickly written and
untested patch):


diff --git i/src/Makefile.am w/src/Makefile.am
index a4f213480e..51c134f08e 100644
--- i/src/Makefile.am
+++ w/src/Makefile.am
@@ -744,6 +744,7 @@ libvirt_setuid_rpc_client_la_LDFLAGS = \
$(AM_LDFLAGS) \
$(LIBXML_LIBS) \
$(SECDRIVER_LIBS) \
+   $(DLOPEN_LIBS) \
$(NULL)
 libvirt_setuid_rpc_client_la_CFLAGS = \
-DLIBVIRT_SETUID_RPC_CLIENT \
@@ -1000,6 +1001,7 @@ libvirt_nss_la_CFLAGS = \
$(NULL)
 libvirt_nss_la_LDFLAGS = \
$(AM_LDFLAGS) \
+   $(DLOPEN_LIBS) \
$(NULL)
 endif WITH_NSS

diff --git i/src/util/Makefile.inc.am w/src/util/Makefile.inc.am
index 8ef9ee1dfa..c5c50f1844 100644
--- i/src/util/Makefile.inc.am
+++ w/src/util/Makefile.inc.am
@@ -278,6 +278,7 @@ libvirt_util_la_LIBADD = \
$(NUMACTL_LIBS) \
$(ACL_LIBS) \
$(GNUTLS_LIBS) \
+   $(DLOPEN_LIBS) \
$(NULL)



Michal

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


[libvirt] [PATCH 17/17] lxc: Use virCgroupGetMemoryStat

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/lxc/lxc_cgroup.c | 65 +---
 1 file changed, 7 insertions(+), 58 deletions(-)

diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 8e937ec389..d93a19d684 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -220,64 +220,13 @@ static int virLXCCgroupGetMemTotal(virCgroupPtr cgroup,
 static int virLXCCgroupGetMemStat(virCgroupPtr cgroup,
   virLXCMeminfoPtr meminfo)
 {
-int ret = 0;
-FILE *statfd = NULL;
-char *statFile = NULL;
-char *line = NULL;
-size_t n;
-
-ret = virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_MEMORY,
-"memory.stat", );
-if (ret != 0) {
-virReportSystemError(-ret, "%s",
- _("cannot get the path of MEMORY cgroup 
controller"));
-return ret;
-}
-
-statfd = fopen(statFile, "r");
-if (statfd == NULL) {
-ret = -errno;
-goto cleanup;
-}
-
-while (getline(, , statfd) > 0) {
-
-char *value = strchr(line, ' ');
-char *nl = value ? strchr(line, '\n') : NULL;
-unsigned long long stat_value;
-
-if (!value)
-continue;
-
-if (nl)
-*nl = '\0';
-
-*value = '\0';
-
-if (virStrToLong_ull(value + 1, NULL, 10, _value) < 0) {
-ret = -EINVAL;
-goto cleanup;
-}
-if (STREQ(line, "cache"))
-meminfo->cached = stat_value >> 10;
-else if (STREQ(line, "inactive_anon"))
-meminfo->inactive_anon = stat_value >> 10;
-else if (STREQ(line, "active_anon"))
-meminfo->active_anon = stat_value >> 10;
-else if (STREQ(line, "inactive_file"))
-meminfo->inactive_file = stat_value >> 10;
-else if (STREQ(line, "active_file"))
-meminfo->active_file = stat_value >> 10;
-else if (STREQ(line, "unevictable"))
-meminfo->unevictable = stat_value >> 10;
-}
-ret = 0;
-
- cleanup:
-VIR_FREE(line);
-VIR_FREE(statFile);
-VIR_FORCE_FCLOSE(statfd);
-return ret;
+return virCgroupGetMemoryStat(cgroup,
+  >cached,
+  >inactive_anon,
+  >active_anon,
+  >inactive_file,
+  >active_file,
+  >unevictable);
 }
 
 
-- 
2.17.1

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


[libvirt] [PATCH 08/17] vircgroup: Unexport unused function virCgroupRemoveRecursively

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/libvirt_private.syms |  1 -
 src/util/vircgroup.c | 11 +--
 src/util/vircgroup.h |  1 -
 3 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 95d7c9f834..59d9bc380e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1550,7 +1550,6 @@ virCgroupNewSelf;
 virCgroupNewThread;
 virCgroupPathOfController;
 virCgroupRemove;
-virCgroupRemoveRecursively;
 virCgroupSetBlkioDeviceReadBps;
 virCgroupSetBlkioDeviceReadIops;
 virCgroupSetBlkioDeviceWeight;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 6d937626e6..280d781f41 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -3312,7 +3312,7 @@ virCgroupGetCpuacctPercpuUsage(virCgroupPtr group, char 
**usage)
 }
 
 
-int
+static int
 virCgroupRemoveRecursively(char *grppath)
 {
 DIR *grpdir;
@@ -4529,15 +4529,6 @@ virCgroupSetCpuCfsQuota(virCgroupPtr group 
ATTRIBUTE_UNUSED,
 }
 
 
-int
-virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED)
-{
-virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
-return -1;
-}
-
-
 int
 virCgroupRemove(virCgroupPtr group ATTRIBUTE_UNUSED)
 {
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 74c7db..138bb3c076 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -273,7 +273,6 @@ int virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, 
bool *migrate);
 int virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus);
 int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus);
 
-int virCgroupRemoveRecursively(char *grppath);
 int virCgroupRemove(virCgroupPtr group);
 
 int virCgroupKillRecursive(virCgroupPtr group, int signum);
-- 
2.17.1

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


[libvirt] [PATCH 06/17] vircgroup: Remove unused function virCgroupKill()

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/libvirt_private.syms |  1 -
 src/util/vircgroup.c | 37 -
 src/util/vircgroup.h |  1 -
 3 files changed, 39 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 32ed5a09f9..8f80ee2250 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1539,7 +1539,6 @@ virCgroupGetMemSwapUsage;
 virCgroupGetPercpuStats;
 virCgroupHasController;
 virCgroupHasEmptyTasks;
-virCgroupKill;
 virCgroupKillPainfully;
 virCgroupKillRecursive;
 virCgroupNewDetect;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index fd58ba154f..d9f6c5b06f 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -3510,33 +3510,6 @@ virCgroupPidCopy(const void *name)
 }
 
 
-/*
- * Returns 1 if some PIDs are killed, 0 if none are killed, or -1 on error
- */
-int
-virCgroupKill(virCgroupPtr group, int signum)
-{
-VIR_DEBUG("group=%p path=%s signum=%d", group, group->path, signum);
-int ret;
-/* The 'tasks' file in cgroups can contain duplicated
- * pids, so we use a hash to track which we've already
- * killed.
- */
-virHashTablePtr pids = virHashCreateFull(100,
- NULL,
- virCgroupPidCode,
- virCgroupPidEqual,
- virCgroupPidCopy,
- NULL);
-
-ret = virCgroupKillInternal(group, signum, pids);
-
-virHashFree(pids);
-
-return ret;
-}
-
-
 static int
 virCgroupKillRecursiveInternal(virCgroupPtr group,
int signum,
@@ -4585,16 +4558,6 @@ virCgroupRemove(virCgroupPtr group ATTRIBUTE_UNUSED)
 }
 
 
-int
-virCgroupKill(virCgroupPtr group ATTRIBUTE_UNUSED,
-  int signum ATTRIBUTE_UNUSED)
-{
-virReportSystemError(ENOSYS, "%s",
- _("Control groups not supported on this platform"));
-return -1;
-}
-
-
 int
 virCgroupKillRecursive(virCgroupPtr group ATTRIBUTE_UNUSED,
int signum ATTRIBUTE_UNUSED)
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index af93316197..a23a491d95 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -280,7 +280,6 @@ int virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus);
 int virCgroupRemoveRecursively(char *grppath);
 int virCgroupRemove(virCgroupPtr group);
 
-int virCgroupKill(virCgroupPtr group, int signum);
 int virCgroupKillRecursive(virCgroupPtr group, int signum);
 int virCgroupKillPainfully(virCgroupPtr group);
 
-- 
2.17.1

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


[libvirt] [PATCH 01/17] docs: List cpuacct in controllers used by QEMU driver

2018-08-09 Thread Pavel Hrdina
The cpuacct controller is used to get cpu stats.

Signed-off-by: Pavel Hrdina 
---
 docs/cgroups.html.in | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/docs/cgroups.html.in b/docs/cgroups.html.in
index e33d07a82b..a498590c45 100644
--- a/docs/cgroups.html.in
+++ b/docs/cgroups.html.in
@@ -23,12 +23,13 @@
 
 
   The QEMU driver is capable of using the cpuset,
-  cpu, memory, blkio and
-  devices controllers. None of them are compulsory.
-  If any controller is not mounted, the resource management APIs
-  which use it will cease to operate. It is possible to explicitly
-  turn off use of a controller, even when mounted, via the
-  /etc/libvirt/qemu.conf configuration file.
+  cpu, cpuacct, memory,
+  blkio and devices controllers.
+  None of them are compulsory. If any controller is not mounted,
+  the resource management APIs which use it will cease to operate.
+  It is possible to explicitly turn off use of a controller,
+  even when mounted, via the /etc/libvirt/qemu.conf
+  configuration file.
 
 
 
-- 
2.17.1

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


[libvirt] [PATCH 03/17] vircgroup: Rename structs to start with underscore

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 2 +-
 src/util/vircgroup.h | 4 ++--
 src/util/vircgrouppriv.h | 6 +++---
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 6bf4e88da1..7602641713 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -385,7 +385,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
 const char *typestr = virCgroupControllerTypeToString(i);
 int typelen = strlen(typestr);
 char *tmp = entry.mnt_opts;
-struct virCgroupController *controller = >controllers[i];
+struct _virCgroupController *controller = >controllers[i];
 while (tmp) {
 char *next = strchr(tmp, ',');
 int len;
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index d833927678..cfa69b67cb 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -28,8 +28,8 @@
 # include "virutil.h"
 # include "virbitmap.h"
 
-struct virCgroup;
-typedef struct virCgroup *virCgroupPtr;
+struct _virCgroup;
+typedef struct _virCgroup *virCgroupPtr;
 
 enum {
 VIR_CGROUP_CONTROLLER_CPU,
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
index 722863e5b6..71788639d6 100644
--- a/src/util/vircgrouppriv.h
+++ b/src/util/vircgrouppriv.h
@@ -31,7 +31,7 @@
 
 # include "vircgroup.h"
 
-struct virCgroupController {
+struct _virCgroupController {
 int type;
 char *mountPoint;
 /* If mountPoint holds several controllers co-mounted,
@@ -42,10 +42,10 @@ struct virCgroupController {
 char *placement;
 };
 
-struct virCgroup {
+struct _virCgroup {
 char *path;
 
-struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
+struct _virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
 };
 
 int virCgroupDetectMountsFromFile(virCgroupPtr group,
-- 
2.17.1

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


[libvirt] [PATCH 10/17] vircgroup: Remove pointless bool parameter

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 280d781f41..6ffa1e9c58 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -251,7 +251,6 @@ static bool
 virCgroupValidateMachineGroup(virCgroupPtr group,
   const char *name,
   const char *drivername,
-  bool stripEmulatorSuffix,
   const char *machinename)
 {
 size_t i;
@@ -303,10 +302,9 @@ virCgroupValidateMachineGroup(virCgroupPtr group,
 if (!tmp)
 return false;
 
-if (stripEmulatorSuffix &&
-(i == VIR_CGROUP_CONTROLLER_CPU ||
- i == VIR_CGROUP_CONTROLLER_CPUACCT ||
- i == VIR_CGROUP_CONTROLLER_CPUSET)) {
+if (i == VIR_CGROUP_CONTROLLER_CPU ||
+i == VIR_CGROUP_CONTROLLER_CPUACCT ||
+i == VIR_CGROUP_CONTROLLER_CPUSET) {
 if (STREQ(tmp, "/emulator"))
 *tmp = '\0';
 tmp = strrchr(group->controllers[i].placement, '/');
@@ -1486,8 +1484,7 @@ virCgroupNewDetectMachine(const char *name,
 return -1;
 }
 
-if (!virCgroupValidateMachineGroup(*group, name, drivername,
-   true, machinename)) {
+if (!virCgroupValidateMachineGroup(*group, name, drivername, machinename)) 
{
 VIR_DEBUG("Failed to validate machine name for '%s' driver '%s'",
   name, drivername);
 virCgroupFree(group);
-- 
2.17.1

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


[libvirt] [PATCH 00/17] some cgroup cleanup patches

2018-08-09 Thread Pavel Hrdina
Preparation for cgroupv2 support.

Pavel Hrdina (17):
  docs: List cpuacct in controllers used by QEMU driver
  docs: Update how we create cgroup directory names
  vircgroup: Rename structs to start with underscore
  vircgroup: Introduce standard set of typedefs and use them
  vircgroup: Extract file link resolving into separate function
  vircgroup: Remove unused function virCgroupKill()
  vircgroup: Unexport unused function virCgroupAddTaskController()
  vircgroup: Unexport unused function virCgroupRemoveRecursively
  vircgroup: Move function used in tests into vircgrouppriv.h
  vircgroup: Remove pointless bool parameter
  vircgroup: Extract mount options matching into function
  vircgroup: Use virCgroupMountOptsMatchController in
virCgroupDetectPlacement
  vircgroup: Introduce virCgroupEnableMissingControllers
  vircgroup: machinename will never be NULL
  vircgroup: Remove virCgroupAddTaskController
  vircgroup: Introduce virCgroupGetMemoryStat
  lxc: Use virCgroupGetMemoryStat

 docs/cgroups.html.in |  47 ++--
 src/libvirt_private.syms |   4 +-
 src/lxc/lxc_cgroup.c |  65 +
 src/util/vircgroup.c | 521 ---
 src/util/vircgroup.h |  31 +--
 src/util/vircgrouppriv.h |  21 +-
 6 files changed, 330 insertions(+), 359 deletions(-)

-- 
2.17.1

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


[libvirt] [PATCH 16/17] vircgroup: Introduce virCgroupGetMemoryStat

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/libvirt_private.syms |  1 +
 src/util/vircgroup.c | 88 
 src/util/vircgroup.h |  7 
 3 files changed, 96 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 59d9bc380e..ee0dca6129 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1532,6 +1532,7 @@ virCgroupGetDomainTotalCpuStats;
 virCgroupGetFreezerState;
 virCgroupGetMemoryHardLimit;
 virCgroupGetMemorySoftLimit;
+virCgroupGetMemoryStat;
 virCgroupGetMemoryUsage;
 virCgroupGetMemSwapHardLimit;
 virCgroupGetMemSwapUsage;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 37982a9607..b91acd13c7 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2427,6 +2427,94 @@ virCgroupSetMemory(virCgroupPtr group, unsigned long 
long kb)
 }
 
 
+/**
+ * virCgroupGetMemoryStat:
+ *
+ * @group: The cgroup to change memory for
+ * @cache: page cache memory in KiB
+ * @activeAnon: anonymous and swap cache memory in KiB
+ * @inactiveAnon: anonymous and swap cache memory in KiB
+ * @activeFile: file-backed memory in KiB
+ * @inactiveFile: file-backed memory in KiB
+ * @unevictable: memory that cannot be reclaimed KiB
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+virCgroupGetMemoryStat(virCgroupPtr group,
+   unsigned long long *cache,
+   unsigned long long *activeAnon,
+   unsigned long long *inactiveAnon,
+   unsigned long long *activeFile,
+   unsigned long long *inactiveFile,
+   unsigned long long *unevictable)
+{
+int ret = -1;
+char *stat = NULL;
+char *line = NULL;
+unsigned long long cacheVal = 0;
+unsigned long long activeAnonVal = 0;
+unsigned long long inactiveAnonVal = 0;
+unsigned long long activeFileVal = 0;
+unsigned long long inactiveFileVal = 0;
+unsigned long long unevictableVal = 0;
+
+if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_MEMORY,
+ "memory.stat",
+ ) < 0) {
+return -1;
+}
+
+line = stat;
+
+while (line) {
+char *newLine = strchr(line, '\n');
+char *valueStr = strchr(line, ' ');
+unsigned long long value;
+
+if (newLine)
+*newLine = '\0';
+
+if (!valueStr) {
+virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+   _("Cannot parse 'memory.stat' cgroup file."));
+goto cleanup;
+}
+*valueStr = '\0';
+
+if (virStrToLong_ull(valueStr + 1, NULL, 10, ) < 0)
+goto cleanup;
+
+if (STREQ(line, "cache"))
+cacheVal = value >> 10;
+else if (STREQ(line, "active_anon"))
+activeAnonVal = value >> 10;
+else if (STREQ(line, "inactive_anon"))
+inactiveAnonVal = value >> 10;
+else if (STREQ(line, "active_file"))
+activeFileVal = value >> 10;
+else if (STREQ(line, "inactive_file"))
+inactiveFileVal = value >> 10;
+else if (STREQ(line, "unevictable"))
+unevictableVal = value >> 10;
+}
+
+*cache = cacheVal;
+*activeAnon = activeAnonVal;
+*inactiveAnon = inactiveAnonVal;
+*activeFile = activeFileVal;
+*inactiveFile = inactiveFileVal;
+*unevictable = unevictableVal;
+
+ret = 0;
+
+ cleanup:
+VIR_FREE(stat);
+return ret;
+}
+
+
 /**
  * virCgroupGetMemoryUsage:
  *
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index 48be077aba..c7fdaaede4 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -177,6 +177,13 @@ int virCgroupGetBlkioDeviceWriteBps(virCgroupPtr group,
 unsigned long long *wbps);
 
 int virCgroupSetMemory(virCgroupPtr group, unsigned long long kb);
+int virCgroupGetMemoryStat(virCgroupPtr group,
+   unsigned long long *cache,
+   unsigned long long *activeAnon,
+   unsigned long long *inactiveAnon,
+   unsigned long long *activeFile,
+   unsigned long long *inactiveFile,
+   unsigned long long *unevictable);
 int virCgroupGetMemoryUsage(virCgroupPtr group, unsigned long *kb);
 
 int virCgroupSetMemoryHardLimit(virCgroupPtr group, unsigned long long kb);
-- 
2.17.1

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


[libvirt] [PATCH 11/17] vircgroup: Extract mount options matching into function

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 80 ++--
 1 file changed, 47 insertions(+), 33 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 6ffa1e9c58..52be5e5fb8 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -399,6 +399,33 @@ virCgroupResolveMountLink(const char *mntDir,
 }
 
 
+static bool
+virCgroupMountOptsMatchController(const char *mntOpts,
+  const char *typeStr)
+{
+const char *tmp = mntOpts;
+int typeLen = strlen(typeStr);
+
+while (tmp) {
+const char *next = strchr(tmp, ',');
+int len;
+if (next) {
+len = next - tmp;
+next++;
+} else {
+len = strlen(tmp);
+}
+
+if (typeLen == len && STREQLEN(typeStr, tmp, len))
+return true;
+
+tmp = next;
+}
+
+return false;
+}
+
+
 /*
  * Process /proc/mounts figuring out what controllers are
  * mounted and where
@@ -426,42 +453,29 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
 
 for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
 const char *typestr = virCgroupControllerTypeToString(i);
-int typelen = strlen(typestr);
-char *tmp = entry.mnt_opts;
-virCgroupControllerPtr controller = >controllers[i];
-while (tmp) {
-char *next = strchr(tmp, ',');
-int len;
-if (next) {
-len = next-tmp;
-next++;
-} else {
-len = strlen(tmp);
-}
 
-if (typelen == len && STREQLEN(typestr, tmp, len)) {
-
-/* Note that the lines in /proc/mounts have the same
- * order than the mount operations, and that there may
- * be duplicates due to bind mounts. This means
- * that the same mount point may be processed more than
- * once. We need to save the results of the last one,
- * and we need to be careful to release the memory used
- * by previous processing. */
-VIR_FREE(controller->mountPoint);
-VIR_FREE(controller->linkPoint);
-if (VIR_STRDUP(controller->mountPoint, entry.mnt_dir) < 0)
-goto cleanup;
+if (virCgroupMountOptsMatchController(entry.mnt_opts, typestr)) {
+/* Note that the lines in /proc/mounts have the same
+ * order than the mount operations, and that there may
+ * be duplicates due to bind mounts. This means
+ * that the same mount point may be processed more than
+ * once. We need to save the results of the last one,
+ * and we need to be careful to release the memory used
+ * by previous processing. */
+virCgroupControllerPtr controller = >controllers[i];
+
+VIR_FREE(controller->mountPoint);
+VIR_FREE(controller->linkPoint);
+if (VIR_STRDUP(controller->mountPoint, entry.mnt_dir) < 0)
+goto cleanup;
 
-/* If it is a co-mount it has a filename like "cpu,cpuacct"
- * and we must identify the symlink path */
-if (checkLinks &&
-virCgroupResolveMountLink(entry.mnt_dir, typestr,
-  controller) < 0) {
-goto cleanup;
-}
+/* If it is a co-mount it has a filename like "cpu,cpuacct"
+ * and we must identify the symlink path */
+if (checkLinks &&
+virCgroupResolveMountLink(entry.mnt_dir, typestr,
+  controller) < 0) {
+goto cleanup;
 }
-tmp = next;
 }
 }
 }
-- 
2.17.1

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


[libvirt] [PATCH 04/17] vircgroup: Introduce standard set of typedefs and use them

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/util/vircgroup.c | 2 +-
 src/util/vircgroup.h | 3 ++-
 src/util/vircgrouppriv.h | 4 +++-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 7602641713..5144b33d43 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -385,7 +385,7 @@ virCgroupDetectMountsFromFile(virCgroupPtr group,
 const char *typestr = virCgroupControllerTypeToString(i);
 int typelen = strlen(typestr);
 char *tmp = entry.mnt_opts;
-struct _virCgroupController *controller = >controllers[i];
+virCgroupControllerPtr controller = >controllers[i];
 while (tmp) {
 char *next = strchr(tmp, ',');
 int len;
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index cfa69b67cb..af93316197 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -29,7 +29,8 @@
 # include "virbitmap.h"
 
 struct _virCgroup;
-typedef struct _virCgroup *virCgroupPtr;
+typedef struct _virCgroup virCgroup;
+typedef virCgroup *virCgroupPtr;
 
 enum {
 VIR_CGROUP_CONTROLLER_CPU,
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
index 71788639d6..1b47d3b858 100644
--- a/src/util/vircgrouppriv.h
+++ b/src/util/vircgrouppriv.h
@@ -41,11 +41,13 @@ struct _virCgroupController {
 char *linkPoint;
 char *placement;
 };
+typedef struct _virCgroupController virCgroupController;
+typedef virCgroupController *virCgroupControllerPtr;
 
 struct _virCgroup {
 char *path;
 
-struct _virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
+virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
 };
 
 int virCgroupDetectMountsFromFile(virCgroupPtr group,
-- 
2.17.1

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


[libvirt] [PATCH 07/17] vircgroup: Unexport unused function virCgroupAddTaskController()

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/libvirt_private.syms |  1 -
 src/util/vircgroup.c | 69 +---
 src/util/vircgroup.h |  4 ---
 3 files changed, 29 insertions(+), 45 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8f80ee2250..95d7c9f834 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1496,7 +1496,6 @@ virBufferVasprintf;
 # util/vircgroup.h
 virCgroupAddMachineTask;
 virCgroupAddTask;
-virCgroupAddTaskController;
 virCgroupAllowAllDevices;
 virCgroupAllowDevice;
 virCgroupAllowDevicePath;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index d9f6c5b06f..6d937626e6 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1136,6 +1136,35 @@ virCgroupNew(pid_t pid,
 }
 
 
+/**
+ * virCgroupAddTaskController:
+ *
+ * @group: The cgroup to add a task to
+ * @pid: The pid of the task to add
+ * @controller: The cgroup controller to be operated on
+ *
+ * Returns: 0 on success or -1 on error
+ */
+static int
+virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller)
+{
+if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Controller %d out of range"), controller);
+return -1;
+}
+
+if (!group->controllers[controller].mountPoint) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Controller '%s' not mounted"),
+   virCgroupControllerTypeToString(controller));
+return -1;
+}
+
+return virCgroupSetValueI64(group, controller, "tasks", pid);
+}
+
+
 static int
 virCgroupAddTaskInternal(virCgroupPtr group, pid_t pid, bool withSystemd)
 {
@@ -1197,35 +1226,6 @@ virCgroupAddMachineTask(virCgroupPtr group, pid_t pid)
 }
 
 
-/**
- * virCgroupAddTaskController:
- *
- * @group: The cgroup to add a task to
- * @pid: The pid of the task to add
- * @controller: The cgroup controller to be operated on
- *
- * Returns: 0 on success or -1 on error
- */
-int
-virCgroupAddTaskController(virCgroupPtr group, pid_t pid, int controller)
-{
-if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Controller %d out of range"), controller);
-return -1;
-}
-
-if (!group->controllers[controller].mountPoint) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Controller '%s' not mounted"),
-   virCgroupControllerTypeToString(controller));
-return -1;
-}
-
-return virCgroupSetValueI64(group, controller, "tasks", pid);
-}
-
-
 static int
 virCgroupSetPartitionSuffix(const char *path, char **res)
 {
@@ -4115,17 +4115,6 @@ virCgroupAddMachineTask(virCgroupPtr group 
ATTRIBUTE_UNUSED,
 }
 
 
-int
-virCgroupAddTaskController(virCgroupPtr group ATTRIBUTE_UNUSED,
-   pid_t pid ATTRIBUTE_UNUSED,
-   int controller ATTRIBUTE_UNUSED)
-{
-virReportSystemError(ENXIO, "%s",
- _("Control groups not supported on this platform"));
-return -1;
-}
-
-
 int
 virCgroupGetBlkioIoServiced(virCgroupPtr group ATTRIBUTE_UNUSED,
 long long *bytes_read ATTRIBUTE_UNUSED,
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index a23a491d95..74c7db 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -134,10 +134,6 @@ int virCgroupPathOfController(virCgroupPtr group,
 int virCgroupAddTask(virCgroupPtr group, pid_t pid);
 int virCgroupAddMachineTask(virCgroupPtr group, pid_t pid);
 
-int virCgroupAddTaskController(virCgroupPtr group,
-   pid_t pid,
-   int controller);
-
 int virCgroupSetBlkioWeight(virCgroupPtr group, unsigned int weight);
 int virCgroupGetBlkioWeight(virCgroupPtr group, unsigned int *weight);
 
-- 
2.17.1

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


[libvirt] [PATCH v1 1/6] virlockspace: Introduce VIR_LOCK_SPACE_ACQUIRE_METADATA flag

2018-08-09 Thread Michal Privoznik
This flag is going to be used to alter default behaviour of the
lock. Firstly, it means we will lock different offset in the file
(offset 1 instead of 0). Secondly, it means the lock acquiring
will actually wait for the lock to be set (compared to default
behaviour which is set or error out).

Signed-off-by: Michal Privoznik 
---
 src/util/virlockspace.c | 40 +---
 src/util/virlockspace.h |  1 +
 2 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c
index 3364c843aa..a7ec0c05bf 100644
--- a/src/util/virlockspace.c
+++ b/src/util/virlockspace.c
@@ -111,6 +111,8 @@ static void 
virLockSpaceResourceFree(virLockSpaceResourcePtr res)
 VIR_FREE(res);
 }
 
+#define DEFAULT_OFFSET 0
+#define METADATA_OFFSET 1
 
 static virLockSpaceResourcePtr
 virLockSpaceResourceNew(virLockSpacePtr lockspace,
@@ -120,6 +122,18 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
 {
 virLockSpaceResourcePtr res;
 bool shared = !!(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED);
+bool metadata = !!(flags & VIR_LOCK_SPACE_ACQUIRE_METADATA);
+off_t start = DEFAULT_OFFSET;
+bool waitForLock = false;
+
+if (metadata) {
+/* We want the metadata lock to act like pthread mutex.
+ * This means waiting for the lock to be acquired. */
+waitForLock = true;
+
+/* Also, we are locking different offset. */
+start = METADATA_OFFSET;
+}
 
 if (VIR_ALLOC(res) < 0)
 return NULL;
@@ -157,7 +171,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
 goto error;
 }
 
-if (virFileLock(res->fd, shared, 0, 1, false) < 0) {
+if (virFileLock(res->fd, shared, start, 1, waitForLock) < 0) {
 if (errno == EACCES || errno == EAGAIN) {
 virReportError(VIR_ERR_RESOURCE_BUSY,
_("Lockspace resource '%s' is locked"),
@@ -204,7 +218,7 @@ virLockSpaceResourceNew(virLockSpacePtr lockspace,
 goto error;
 }
 
-if (virFileLock(res->fd, shared, 0, 1, false) < 0) {
+if (virFileLock(res->fd, shared, start, 1, waitForLock) < 0) {
 if (errno == EACCES || errno == EAGAIN) {
 virReportError(VIR_ERR_RESOURCE_BUSY,
_("Lockspace resource '%s' is locked"),
@@ -621,7 +635,15 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
   lockspace, resname, flags, (unsigned long long)owner);
 
 virCheckFlags(VIR_LOCK_SPACE_ACQUIRE_SHARED |
-  VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE, -1);
+  VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE |
+  VIR_LOCK_SPACE_ACQUIRE_METADATA, -1);
+
+if (flags & VIR_LOCK_SPACE_ACQUIRE_METADATA &&
+flags & VIR_LOCK_SPACE_ACQUIRE_SHARED) {
+virReportInvalidArg(flags, "%s",
+_("metadata and shared are mutually exclusive"));
+return -1;
+}
 
 virMutexLock(>lock);
 
@@ -635,10 +657,14 @@ int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
 
 goto done;
 }
-virReportError(VIR_ERR_RESOURCE_BUSY,
-   _("Lockspace resource '%s' is locked"),
-   resname);
-goto cleanup;
+
+if (!(res->flags & VIR_LOCK_SPACE_ACQUIRE_METADATA) ||
+!(flags & VIR_LOCK_SPACE_ACQUIRE_METADATA)) {
+virReportError(VIR_ERR_RESOURCE_BUSY,
+   _("Lockspace resource '%s' is locked"),
+   resname);
+goto cleanup;
+}
 }
 
 if (!(res = virLockSpaceResourceNew(lockspace, resname, flags, owner)))
diff --git a/src/util/virlockspace.h b/src/util/virlockspace.h
index 041cf20396..a9a3b2e73f 100644
--- a/src/util/virlockspace.h
+++ b/src/util/virlockspace.h
@@ -45,6 +45,7 @@ int virLockSpaceDeleteResource(virLockSpacePtr lockspace,
 typedef enum {
 VIR_LOCK_SPACE_ACQUIRE_SHARED = (1 << 0),
 VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE = (1 << 1),
+VIR_LOCK_SPACE_ACQUIRE_METADATA   = (1 << 2),
 } virLockSpaceAcquireFlags;
 
 int virLockSpaceAcquireResource(virLockSpacePtr lockspace,
-- 
2.16.4

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


[libvirt] [PATCH v1 3/6] lockd_driver_lockd: Implement metadata flag

2018-08-09 Thread Michal Privoznik
Signed-off-by: Michal Privoznik 
---
 src/locking/lock_daemon_dispatch.c |  5 -
 src/locking/lock_driver_lockd.c| 31 +--
 src/locking/lock_driver_lockd.h|  1 +
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/src/locking/lock_daemon_dispatch.c 
b/src/locking/lock_daemon_dispatch.c
index 1b479db55d..ff5a33fa33 100644
--- a/src/locking/lock_daemon_dispatch.c
+++ b/src/locking/lock_daemon_dispatch.c
@@ -54,7 +54,8 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr 
server ATTRIBUTE_UNU
 virMutexLock(>lock);
 
 virCheckFlagsGoto(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED |
-  VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE, 
cleanup);
+  VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE |
+  VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_METADATA, cleanup);
 
 if (priv->restricted) {
 virReportError(VIR_ERR_OPERATION_DENIED, "%s",
@@ -80,6 +81,8 @@ virLockSpaceProtocolDispatchAcquireResource(virNetServerPtr 
server ATTRIBUTE_UNU
 newFlags |= VIR_LOCK_SPACE_ACQUIRE_SHARED;
 if (flags & VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE)
 newFlags |= VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE;
+if (flags & VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_METADATA)
+newFlags |= VIR_LOCK_SPACE_ACQUIRE_METADATA;
 
 if (virLockSpaceAcquireResource(lockspace,
 args->name,
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 957a963a7b..bd14ed8930 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -475,9 +475,11 @@ static int 
virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
 bool autoCreate = false;
 
 virCheckFlags(VIR_LOCK_MANAGER_RESOURCE_READONLY |
-  VIR_LOCK_MANAGER_RESOURCE_SHARED, -1);
+  VIR_LOCK_MANAGER_RESOURCE_SHARED |
+  VIR_LOCK_MANAGER_RESOURCE_METADATA, -1);
 
-if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY)
+if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY &&
+!(flags & VIR_LOCK_MANAGER_RESOURCE_METADATA))
 return 0;
 
 switch (type) {
@@ -489,7 +491,8 @@ static int 
virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
 }
 if (!driver->autoDiskLease) {
 if (!(flags & (VIR_LOCK_MANAGER_RESOURCE_SHARED |
-   VIR_LOCK_MANAGER_RESOURCE_READONLY)))
+   VIR_LOCK_MANAGER_RESOURCE_READONLY |
+   VIR_LOCK_MANAGER_RESOURCE_METADATA)))
 priv->hasRWDisks = true;
 return 0;
 }
@@ -602,6 +605,10 @@ static int 
virLockManagerLockDaemonAddResource(virLockManagerPtr lock,
 priv->resources[priv->nresources-1].flags |=
 VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE;
 
+if (flags & VIR_LOCK_MANAGER_RESOURCE_METADATA)
+priv->resources[priv->nresources-1].flags |=
+VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_METADATA;
+
 return 0;
 
  error:
@@ -626,12 +633,15 @@ static int 
virLockManagerLockDaemonAcquire(virLockManagerPtr lock,
 virCheckFlags(VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY |
   VIR_LOCK_MANAGER_ACQUIRE_RESTRICT, -1);
 
-if (priv->nresources == 0 &&
-priv->hasRWDisks &&
-driver->requireLeaseForDisks) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("Read/write, exclusive access, disks were present, 
but no leases specified"));
-return -1;
+if (priv->nresources == 0) {
+if (priv->hasRWDisks &&
+driver->requireLeaseForDisks) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Read/write, exclusive access, disks were 
present, but no leases specified"));
+return -1;
+}
+
+return 0;
 }
 
 if (!(client = virLockManagerLockDaemonConnect(lock, , )))
@@ -711,7 +721,8 @@ static int 
virLockManagerLockDaemonRelease(virLockManagerPtr lock,
 
 args.flags &=
 ~(VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED |
-  VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE);
+  VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE |
+  VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_METADATA);
 
 if (virNetClientProgramCall(program,
 client,
diff --git a/src/locking/lock_driver_lockd.h b/src/locking/lock_driver_lockd.h
index 6931fe7425..9882793260 100644
--- a/src/locking/lock_driver_lockd.h
+++ b/src/locking/lock_driver_lockd.h
@@ -25,6 +25,7 @@
 enum virLockSpaceProtocolAcquireResourceFlags {
 VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED = (1 << 0),
 VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = (1 << 1),
+VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_METADATA = (1 << 2),
 };
 
 #endif /* __VIR_LOCK_DRIVER_LOCKD_H__ */

[libvirt] [PATCH v1 5/6] domain_lock: Implement metadata locking

2018-08-09 Thread Michal Privoznik
In order for our drivers to lock resources for metadata change we
need set of new APIs. Fortunately, we don't have to care about
every possible device a domain can have. We care only about those
which can live on a network filesystem and hence can be accessed
by multiple daemons at the same time. These devices are covered
in virDomainLockMetadataLock() and only a small fraction of
those can be hotplugged (covered in the rest of the introduced
APIs).

Signed-off-by: Michal Privoznik 
---
 src/libvirt_private.syms  |   8 ++
 src/locking/domain_lock.c | 304 ++
 src/locking/domain_lock.h |  28 +
 3 files changed, 317 insertions(+), 23 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 32ed5a09f9..fdc45e724c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1284,6 +1284,14 @@ virDomainLockImageAttach;
 virDomainLockImageDetach;
 virDomainLockLeaseAttach;
 virDomainLockLeaseDetach;
+virDomainLockMetadataDiskLock;
+virDomainLockMetadataDiskUnlock;
+virDomainLockMetadataImageLock;
+virDomainLockMetadataImageUnlock;
+virDomainLockMetadataLock;
+virDomainLockMetadataMemLock;
+virDomainLockMetadataMemUnlock;
+virDomainLockMetadataUnlock;
 virDomainLockProcessInquire;
 virDomainLockProcessPause;
 virDomainLockProcessResume;
diff --git a/src/locking/domain_lock.c b/src/locking/domain_lock.c
index 705b132457..19a097fb25 100644
--- a/src/locking/domain_lock.c
+++ b/src/locking/domain_lock.c
@@ -69,7 +69,8 @@ static int virDomainLockManagerAddLease(virLockManagerPtr 
lock,
 
 
 static int virDomainLockManagerAddImage(virLockManagerPtr lock,
-virStorageSourcePtr src)
+virStorageSourcePtr src,
+bool metadataOnly)
 {
 unsigned int diskFlags = 0;
 int type = virStorageSourceGetActualType(src);
@@ -82,10 +83,14 @@ static int virDomainLockManagerAddImage(virLockManagerPtr 
lock,
   type == VIR_STORAGE_TYPE_DIR))
 return 0;
 
-if (src->readonly)
-diskFlags |= VIR_LOCK_MANAGER_RESOURCE_READONLY;
-if (src->shared)
-diskFlags |= VIR_LOCK_MANAGER_RESOURCE_SHARED;
+if (metadataOnly) {
+diskFlags = VIR_LOCK_MANAGER_RESOURCE_METADATA;
+} else {
+if (src->readonly)
+diskFlags |= VIR_LOCK_MANAGER_RESOURCE_READONLY;
+if (src->shared)
+diskFlags |= VIR_LOCK_MANAGER_RESOURCE_SHARED;
+}
 
 VIR_DEBUG("Add disk %s", src->path);
 if (virLockManagerAddResource(lock,
@@ -101,13 +106,68 @@ static int virDomainLockManagerAddImage(virLockManagerPtr 
lock,
 }
 
 
+static int
+virDomainLockManagerAddMemory(virLockManagerPtr lock,
+  const virDomainMemoryDef *mem)
+{
+const char *path = NULL;
+
+switch ((virDomainMemoryModel) mem->model) {
+case VIR_DOMAIN_MEMORY_MODEL_NVDIMM:
+path = mem->nvdimmPath;
+break;
+
+case VIR_DOMAIN_MEMORY_MODEL_DIMM:
+case VIR_DOMAIN_MEMORY_MODEL_LAST:
+case VIR_DOMAIN_MEMORY_MODEL_NONE:
+break;
+}
+
+if (!path)
+return 0;
+
+VIR_DEBUG("Adding memory %s", path);
+if (virLockManagerAddResource(lock,
+  VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK,
+  path,
+  0,
+  NULL,
+  VIR_LOCK_MANAGER_RESOURCE_METADATA) < 0)
+return -1;
+
+return 0;
+}
+
+
+static int
+virDomainLockManagerAddFile(virLockManagerPtr lock,
+const char *file)
+{
+if (!file)
+return 0;
+
+VIR_DEBUG("Adding file %s", file);
+if (virLockManagerAddResource(lock,
+  VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK,
+  file,
+  0,
+  NULL,
+  VIR_LOCK_MANAGER_RESOURCE_METADATA) < 0)
+return -1;
+
+return 0;
+}
+
+
 static virLockManagerPtr virDomainLockManagerNew(virLockManagerPluginPtr 
plugin,
  const char *uri,
  virDomainObjPtr dom,
  bool withResources,
+ bool metadataOnly,
  unsigned int flags)
 {
 virLockManagerPtr lock;
+const virDomainDef *def = dom->def;
 size_t i;
 virLockManagerParam params[] = {
 { .type = VIR_LOCK_MANAGER_PARAM_TYPE_UUID,
@@ -115,11 +175,11 @@ static virLockManagerPtr 
virDomainLockManagerNew(virLockManagerPluginPtr plugin,
 },
 { .type = VIR_LOCK_MANAGER_PARAM_TYPE_STRING,
   .key = "name",
-  .value = { .str = dom->def->name },
+  

[libvirt] [PATCH v1 6/6] qemu_security: Lock metadata while relabelling

2018-08-09 Thread Michal Privoznik
Fortunately, we have qemu wrappers so it's sufficient to put
lock/unlock call only there.

Signed-off-by: Michal Privoznik 
---
 src/qemu/qemu_security.c | 107 +++
 1 file changed, 107 insertions(+)

diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
index af3be42854..527563947c 100644
--- a/src/qemu/qemu_security.c
+++ b/src/qemu/qemu_security.c
@@ -26,6 +26,7 @@
 #include "qemu_domain.h"
 #include "qemu_security.h"
 #include "virlog.h"
+#include "locking/domain_lock.h"
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -39,6 +40,12 @@ qemuSecuritySetAllLabel(virQEMUDriverPtr driver,
 {
 int ret = -1;
 qemuDomainObjPrivatePtr priv = vm->privateData;
+bool locked = false;
+
+if (virDomainLockMetadataLock(driver->lockManager, vm) < 0)
+goto cleanup;
+
+locked = true;
 
 if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
 virSecurityManagerTransactionStart(driver->securityManager) < 0)
@@ -55,9 +62,17 @@ qemuSecuritySetAllLabel(virQEMUDriverPtr driver,
 vm->pid) < 0)
 goto cleanup;
 
+locked = false;
+
+if (virDomainLockMetadataUnlock(driver->lockManager, vm) < 0)
+goto cleanup;
+
 ret = 0;
  cleanup:
 virSecurityManagerTransactionAbort(driver->securityManager);
+if (locked &&
+virDomainLockMetadataUnlock(driver->lockManager, vm) < 0)
+VIR_WARN("unable to release metadata lock");
 return ret;
 }
 
@@ -68,6 +83,10 @@ qemuSecurityRestoreAllLabel(virQEMUDriverPtr driver,
 bool migrated)
 {
 qemuDomainObjPrivatePtr priv = vm->privateData;
+bool unlock = true;
+
+if (virDomainLockMetadataLock(driver->lockManager, vm) < 0)
+unlock = false;
 
 /* In contrast to qemuSecuritySetAllLabel, do not use
  * secdriver transactions here. This function is called from
@@ -79,6 +98,10 @@ qemuSecurityRestoreAllLabel(virQEMUDriverPtr driver,
   vm->def,
   migrated,
   priv->chardevStdioLogd);
+
+if (unlock &&
+virDomainLockMetadataUnlock(driver->lockManager, vm) < 0)
+VIR_WARN("unable to release metadata lock");
 }
 
 
@@ -88,6 +111,12 @@ qemuSecuritySetDiskLabel(virQEMUDriverPtr driver,
  virDomainDiskDefPtr disk)
 {
 int ret = -1;
+bool locked = false;
+
+if (virDomainLockMetadataDiskLock(driver->lockManager, vm, disk) < 0)
+goto cleanup;
+
+locked = true;
 
 if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
 virSecurityManagerTransactionStart(driver->securityManager) < 0)
@@ -103,9 +132,17 @@ qemuSecuritySetDiskLabel(virQEMUDriverPtr driver,
 vm->pid) < 0)
 goto cleanup;
 
+locked = false;
+
+if (virDomainLockMetadataDiskUnlock(driver->lockManager, vm, disk) < 0)
+goto cleanup;
+
 ret = 0;
  cleanup:
 virSecurityManagerTransactionAbort(driver->securityManager);
+if (locked &&
+virDomainLockMetadataDiskUnlock(driver->lockManager, vm, disk) < 0)
+VIR_WARN("unable to release disk metadata lock");
 return ret;
 }
 
@@ -116,6 +153,12 @@ qemuSecurityRestoreDiskLabel(virQEMUDriverPtr driver,
  virDomainDiskDefPtr disk)
 {
 int ret = -1;
+bool locked = false;
+
+if (virDomainLockMetadataDiskLock(driver->lockManager, vm, disk) < 0)
+goto cleanup;
+
+locked = true;
 
 if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
 virSecurityManagerTransactionStart(driver->securityManager) < 0)
@@ -131,9 +174,17 @@ qemuSecurityRestoreDiskLabel(virQEMUDriverPtr driver,
 vm->pid) < 0)
 goto cleanup;
 
+locked = false;
+
+if (virDomainLockMetadataDiskUnlock(driver->lockManager, vm, disk) < 0)
+goto cleanup;
+
 ret = 0;
  cleanup:
 virSecurityManagerTransactionAbort(driver->securityManager);
+if (locked &&
+virDomainLockMetadataDiskUnlock(driver->lockManager, vm, disk) < 0)
+VIR_WARN("unable to release disk metadata lock");
 return ret;
 }
 
@@ -144,6 +195,12 @@ qemuSecuritySetImageLabel(virQEMUDriverPtr driver,
   virStorageSourcePtr src)
 {
 int ret = -1;
+bool locked = false;
+
+if (virDomainLockMetadataImageLock(driver->lockManager, vm, src) < 0)
+goto cleanup;
+
+locked = true;
 
 if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT) &&
 virSecurityManagerTransactionStart(driver->securityManager) < 0)
@@ -159,9 +216,17 @@ qemuSecuritySetImageLabel(virQEMUDriverPtr driver,
 vm->pid) < 0)
 goto cleanup;
 
+locked = false;
+
+if (virDomainLockMetadataImageUnlock(driver->lockManager, vm, src) < 0)
+goto 

[libvirt] [PATCH v1 4/6] lock_driver_sanlock: Handle metadata flag gracefully

2018-08-09 Thread Michal Privoznik
No real support implemented here. But hey, at least we will not
fail.

Signed-off-by: Michal Privoznik 
---
 src/locking/lock_driver_sanlock.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/locking/lock_driver_sanlock.c 
b/src/locking/lock_driver_sanlock.c
index 3e5f0e37b0..c1996fb937 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -791,7 +791,8 @@ static int 
virLockManagerSanlockAddResource(virLockManagerPtr lock,
 virLockManagerSanlockPrivatePtr priv = lock->privateData;
 
 virCheckFlags(VIR_LOCK_MANAGER_RESOURCE_READONLY |
-  VIR_LOCK_MANAGER_RESOURCE_SHARED, -1);
+  VIR_LOCK_MANAGER_RESOURCE_SHARED |
+  VIR_LOCK_MANAGER_RESOURCE_METADATA, -1);
 
 if (priv->res_count == SANLK_MAX_RESOURCES) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -804,6 +805,11 @@ static int 
virLockManagerSanlockAddResource(virLockManagerPtr lock,
 if (flags & VIR_LOCK_MANAGER_RESOURCE_READONLY)
 return 0;
 
+/* No metadata locking support for now.
+ * TODO: implement it. */
+if (flags & VIR_LOCK_MANAGER_RESOURCE_METADATA)
+return 0;
+
 switch (type) {
 case VIR_LOCK_MANAGER_RESOURCE_TYPE_DISK:
 if (driver->autoDiskLease) {
@@ -953,12 +959,17 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr 
lock,
 virCheckFlags(VIR_LOCK_MANAGER_ACQUIRE_RESTRICT |
   VIR_LOCK_MANAGER_ACQUIRE_REGISTER_ONLY, -1);
 
-if (priv->res_count == 0 &&
-priv->hasRWDisks &&
-driver->requireLeaseForDisks) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("Read/write, exclusive access, disks were present, 
but no leases specified"));
-return -1;
+if (priv->res_count == 0) {
+if (priv->hasRWDisks &&
+driver->requireLeaseForDisks) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Read/write, exclusive access, disks were 
present, but no leases specified"));
+return -1;
+}
+
+/* We are not handling METADATA flag yet. So no resources
+ * case is no-op for now. */
+return 0;
 }
 
 /* We only initialize 'sock' if we are in the real
-- 
2.16.4

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


[libvirt] [PATCH v1 2/6] lock_driver.h: Introduce metadata flag

2018-08-09 Thread Michal Privoznik
Signed-off-by: Michal Privoznik 
---
 src/locking/lock_driver.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/locking/lock_driver.h b/src/locking/lock_driver.h
index 8b7521..7c8f79520a 100644
--- a/src/locking/lock_driver.h
+++ b/src/locking/lock_driver.h
@@ -56,6 +56,8 @@ typedef enum {
 VIR_LOCK_MANAGER_RESOURCE_READONLY = (1 << 0),
 /* The resource is assigned in shared, writable mode */
 VIR_LOCK_MANAGER_RESOURCE_SHARED   = (1 << 1),
+/* The resource is locked for metadata change */
+VIR_LOCK_MANAGER_RESOURCE_METADATA = (1 << 2),
 } virLockManagerResourceFlags;
 
 typedef enum {
-- 
2.16.4

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


[libvirt] [PATCH v1 0/6] Introduce metadata locking

2018-08-09 Thread Michal Privoznik
All patches are for:

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

You can find them on my Github too:

  https://github.com/zippy2/libvirt/tree/disk_metadata_lock_alt


The locking by itself make very little sense. I have a patches waiting
that implement restoring original seclabels using XATTRs, that should go
on the top of these and can be also found on my Github:

  https://github.com/zippy2/libvirt/tree/seclabels

But those are for different bug therefore I'll send them separately.


And a bit of warning, I haven't bothered implementing this feature into
sanlock driver. The main reason for that was that we tell users to
prefer virtlockd over sanlock and if we really want them to switch lets
do it by the former offering more features than the latter.

Michal Prívozník (6):
  virlockspace: Introduce VIR_LOCK_SPACE_ACQUIRE_METADATA flag
  lock_driver.h: Introduce metadata flag
  lockd_driver_lockd: Implement metadata flag
  lock_driver_sanlock: Handle metadata flag gracefully
  domain_lock: Implement metadata locking
  qemu_security: Lock metadata while relabelling

 src/libvirt_private.syms   |   8 +
 src/locking/domain_lock.c  | 304 ++---
 src/locking/domain_lock.h  |  28 
 src/locking/lock_daemon_dispatch.c |   5 +-
 src/locking/lock_driver.h  |   2 +
 src/locking/lock_driver_lockd.c|  31 ++--
 src/locking/lock_driver_lockd.h|   1 +
 src/locking/lock_driver_sanlock.c  |  25 ++-
 src/qemu/qemu_security.c   | 107 +
 src/util/virlockspace.c|  40 -
 src/util/virlockspace.h|   1 +
 11 files changed, 504 insertions(+), 48 deletions(-)

-- 
2.16.4

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

[libvirt] [jenkins-ci PATCH 4/6] projects: Build libvirt-sandbox on Debian 8

2018-08-09 Thread Andrea Bolognani
Signed-off-by: Andrea Bolognani 
---
 projects/libvirt-sandbox.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/projects/libvirt-sandbox.yaml b/projects/libvirt-sandbox.yaml
index 518080a..da9bf77 100644
--- a/projects/libvirt-sandbox.yaml
+++ b/projects/libvirt-sandbox.yaml
@@ -2,6 +2,7 @@
 - project:
 name: libvirt-sandbox
 machines:
+  - libvirt-debian-8
   - libvirt-debian-9
   - libvirt-fedora-27
   - libvirt-fedora-28
-- 
2.17.1

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


[libvirt] [jenkins-ci PATCH 1/6] guests: Don't prepare Ubuntu 16.04 for virt-manager

2018-08-09 Thread Andrea Bolognani
virt-manager can't be built successfully on the
platform, so we shouldn't install the corresponding
build dependencies.

Signed-off-by: Andrea Bolognani 
---
 guests/host_vars/libvirt-ubuntu-16/main.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/guests/host_vars/libvirt-ubuntu-16/main.yml 
b/guests/host_vars/libvirt-ubuntu-16/main.yml
index 92296b4..4d9914a 100644
--- a/guests/host_vars/libvirt-ubuntu-16/main.yml
+++ b/guests/host_vars/libvirt-ubuntu-16/main.yml
@@ -12,7 +12,6 @@ projects:
   - libvirt-tck
   - osinfo-db
   - osinfo-db-tools
-  - virt-manager
   - virt-viewer
 
 package_format: deb
-- 
2.17.1

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


[libvirt] [jenkins-ci PATCH 5/6] guests: Prepare Debian 8 for libvirt-dbus

2018-08-09 Thread Andrea Bolognani
libvirt-dbus can be built successfully on the
platform, so we should install the corresponding
build dependencies.

Signed-off-by: Andrea Bolognani 
---
 guests/host_vars/libvirt-debian-8/main.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guests/host_vars/libvirt-debian-8/main.yml 
b/guests/host_vars/libvirt-debian-8/main.yml
index fb37205..aca0663 100644
--- a/guests/host_vars/libvirt-debian-8/main.yml
+++ b/guests/host_vars/libvirt-debian-8/main.yml
@@ -2,6 +2,7 @@
 projects:
   - libosinfo
   - libvirt
+  - libvirt-dbus
   - libvirt-glib
   - libvirt-go
   - libvirt-go-xml
-- 
2.17.1

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


[libvirt] [jenkins-ci PATCH 6/6] projects: Build libvirt-dbus on Debian 8

2018-08-09 Thread Andrea Bolognani
As with CentOS 7, we can't run 'make check' on the
platform because we don't have a recent enough Python
interpreter, but the daemon itself will build and run
just fine.

Signed-off-by: Andrea Bolognani 
---
 projects/libvirt-dbus.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/projects/libvirt-dbus.yaml b/projects/libvirt-dbus.yaml
index c12a769..3212465 100644
--- a/projects/libvirt-dbus.yaml
+++ b/projects/libvirt-dbus.yaml
@@ -9,6 +9,7 @@
   parent_jobs: 'libvirt-glib-master-build'
   machines:
 - libvirt-centos-7
+- libvirt-debian-8
 - libvirt-debian-9
 - libvirt-fedora-27
 - libvirt-fedora-28
-- 
2.17.1

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


[libvirt] [jenkins-ci PATCH 3/6] guests: Prepare Debian 8 for libvirt-sandbox

2018-08-09 Thread Andrea Bolognani
libvirt-sandbox can be built successfully on the
platform, so we should install the corresponding
build dependencies.

Signed-off-by: Andrea Bolognani 
---
 guests/host_vars/libvirt-debian-8/main.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/guests/host_vars/libvirt-debian-8/main.yml 
b/guests/host_vars/libvirt-debian-8/main.yml
index a6875a4..fb37205 100644
--- a/guests/host_vars/libvirt-debian-8/main.yml
+++ b/guests/host_vars/libvirt-debian-8/main.yml
@@ -7,6 +7,7 @@ projects:
   - libvirt-go-xml
   - libvirt-perl
   - libvirt-python
+  - libvirt-sandbox
   - libvirt-tck
   - osinfo-db
   - osinfo-db-tools
-- 
2.17.1

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


[libvirt] [jenkins-ci PATCH 0/6] Some coverage fixes and improvements

2018-08-09 Thread Andrea Bolognani
We were installing some unnecessary packages and not building
projects on as many platforms as possible. Let's fix that :)

Andrea Bolognani (6):
  guests: Don't prepare Ubuntu 16.04 for virt-manager
  guests: Don't prepare CentOS 7 for libvirt-sandbox
  guests: Prepare Debian 8 for libvirt-sandbox
  projects: Build libvirt-sandbox on Debian 8
  guests: Prepare Debian 8 for libvirt-dbus
  projects: Build libvirt-dbus on Debian 8

 guests/host_vars/libvirt-centos-7/main.yml  | 1 -
 guests/host_vars/libvirt-debian-8/main.yml  | 2 ++
 guests/host_vars/libvirt-ubuntu-16/main.yml | 1 -
 projects/libvirt-dbus.yaml  | 1 +
 projects/libvirt-sandbox.yaml   | 1 +
 5 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.17.1

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


[libvirt] [jenkins-ci PATCH 2/6] guests: Don't prepare CentOS 7 for libvirt-sandbox

2018-08-09 Thread Andrea Bolognani
libvirt-sandbox can't be built successfully on the
platform, so we shouldn't install the corresponding
build dependencies.

Signed-off-by: Andrea Bolognani 
---
 guests/host_vars/libvirt-centos-7/main.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/guests/host_vars/libvirt-centos-7/main.yml 
b/guests/host_vars/libvirt-centos-7/main.yml
index 4c80e22..e220849 100644
--- a/guests/host_vars/libvirt-centos-7/main.yml
+++ b/guests/host_vars/libvirt-centos-7/main.yml
@@ -9,7 +9,6 @@ projects:
   - libvirt-go-xml
   - libvirt-perl
   - libvirt-python
-  - libvirt-sandbox
   - osinfo-db
   - osinfo-db-tools
   - virt-viewer
-- 
2.17.1

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


[libvirt] [PATCH 1/3] conf: qemu: add support for Hyper-V frequency MSRs

2018-08-09 Thread Vitaly Kuznetsov
Qemu-2.12 gained 'hv-frequencies' cpu flag to enable Hyper-V frequency
MSRs. These MSRs are required (but not sufficient) to make Hyper-V on
KVM pass stable TSC page clocksource to L2 guests.

Signed-off-by: Vitaly Kuznetsov 
---
 docs/formatdomain.html.in   | 7 +++
 docs/schemas/domaincommon.rng   | 5 +
 src/conf/domain_conf.c  | 6 +-
 src/conf/domain_conf.h  | 1 +
 src/cpu/cpu_x86.c   | 3 +++
 src/cpu/cpu_x86_data.h  | 1 +
 src/qemu/qemu_command.c | 1 +
 src/qemu/qemu_parse_command.c   | 1 +
 src/qemu/qemu_process.c | 1 +
 tests/qemuxml2argvdata/hyperv-off.xml   | 1 +
 tests/qemuxml2argvdata/hyperv.args  | 2 +-
 tests/qemuxml2argvdata/hyperv.xml   | 1 +
 tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
 tests/qemuxml2xmloutdata/hyperv.xml | 1 +
 14 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 34664f7903..4ec2b73244 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1937,6 +1937,7 @@
 synic state='on'/
 reset state='on'/
 vendor_id state='on' value='KVM Hv'/
+frequencies state='on'/
   /hyperv
   kvm
 hidden state='on'/
@@ -2059,6 +2060,12 @@
   on, off; value - string, up to 12 characters
   1.3.3 (QEMU 2.5)
 
+
+  frequencies
+  Expose frequency MSRs
+   on, off
+  4.7.0 (QEMU 2.12)
+
   
   
   pvspinlock
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 1a786968cc..fc013ff2a4 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5716,6 +5716,11 @@
 
   
 
+
+  
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8fd774b531..17a9bc8286 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -169,7 +169,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
   "synic",
   "stimer",
   "reset",
-  "vendor_id")
+  "vendor_id",
+  "frequencies")
 
 VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
   "hidden")
@@ -20017,6 +20018,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 case VIR_DOMAIN_HYPERV_SYNIC:
 case VIR_DOMAIN_HYPERV_STIMER:
 case VIR_DOMAIN_HYPERV_RESET:
+case VIR_DOMAIN_HYPERV_FREQUENCIES:
 break;
 
 case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22201,6 +22203,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr 
src,
 case VIR_DOMAIN_HYPERV_SYNIC:
 case VIR_DOMAIN_HYPERV_STIMER:
 case VIR_DOMAIN_HYPERV_RESET:
+case VIR_DOMAIN_HYPERV_FREQUENCIES:
 if (src->hyperv_features[i] != dst->hyperv_features[i]) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27851,6 +27854,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 case VIR_DOMAIN_HYPERV_SYNIC:
 case VIR_DOMAIN_HYPERV_STIMER:
 case VIR_DOMAIN_HYPERV_RESET:
+case VIR_DOMAIN_HYPERV_FREQUENCIES:
 break;
 
 case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c1dfa37fdf..8b15b7e192 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1791,6 +1791,7 @@ typedef enum {
 VIR_DOMAIN_HYPERV_STIMER,
 VIR_DOMAIN_HYPERV_RESET,
 VIR_DOMAIN_HYPERV_VENDOR_ID,
+VIR_DOMAIN_HYPERV_FREQUENCIES,
 
 VIR_DOMAIN_HYPERV_LAST
 } virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 809da94117..a2fbfb577d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -109,6 +109,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_VPINDEX,
 0x4003, 0x0040);
 KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RESET,
 0x4003, 0x0080);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES,
+0x4003, 0x0800);
 
 static virCPUx86Feature x86_kvm_features[] =
 {
@@ -129,6 +131,7 @@ static virCPUx86Feature x86_kvm_features[] =
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_VAPIC),
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_VPINDEX),
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET),
+KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES),
 };
 
 typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index b89110f16c..c01eb41be5 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -63,6 +63,7 @@ struct _virCPUx86CPUID {
 # define VIR_CPU_x86_KVM_HV_VAPIC "__kvm_hv_vapic"
 # define VIR_CPU_x86_KVM_HV_VPINDEX   "__kvm_hv_vpindex"
 # define 

[libvirt] [PATCH 2/3] conf: qemu: add support for Hyper-V reenlightenment notifications

2018-08-09 Thread Vitaly Kuznetsov
Qemu-3.0 supports so-called 'Reenlightenment' notifications and this (in
conjunction with 'hv-frequencies') can be used make Hyper-V on KVM pass
stable TSC page clocksource to L2 guests.

Signed-off-by: Vitaly Kuznetsov 
---
 docs/formatdomain.html.in   | 7 +++
 docs/schemas/domaincommon.rng   | 5 +
 src/conf/domain_conf.c  | 6 +-
 src/conf/domain_conf.h  | 1 +
 src/cpu/cpu_x86.c   | 3 +++
 src/cpu/cpu_x86_data.h  | 1 +
 src/qemu/qemu_command.c | 1 +
 src/qemu/qemu_parse_command.c   | 1 +
 src/qemu/qemu_process.c | 1 +
 tests/qemuxml2argvdata/hyperv-off.xml   | 1 +
 tests/qemuxml2argvdata/hyperv.args  | 3 ++-
 tests/qemuxml2argvdata/hyperv.xml   | 1 +
 tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
 tests/qemuxml2xmloutdata/hyperv.xml | 1 +
 14 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 4ec2b73244..de0993696e 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1938,6 +1938,7 @@
 reset state='on'/
 vendor_id state='on' value='KVM Hv'/
 frequencies state='on'/
+reenlightenment state='on'/
   /hyperv
   kvm
 hidden state='on'/
@@ -2066,6 +2067,12 @@
on, off
   4.7.0 (QEMU 2.12)
 
+
+  reenlightenment
+  Enable re-enlightenment notification on migration
+   on, off
+  4.7.0 (QEMU 3.0)
+
   
   
   pvspinlock
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index fc013ff2a4..b2a1ebfa3f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5721,6 +5721,11 @@
 
   
 
+
+  
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 17a9bc8286..e2154b5bf7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -170,7 +170,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
   "stimer",
   "reset",
   "vendor_id",
-  "frequencies")
+  "frequencies",
+  "reenlightenment")
 
 VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
   "hidden")
@@ -20019,6 +20020,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 case VIR_DOMAIN_HYPERV_STIMER:
 case VIR_DOMAIN_HYPERV_RESET:
 case VIR_DOMAIN_HYPERV_FREQUENCIES:
+case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
 break;
 
 case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22204,6 +22206,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr 
src,
 case VIR_DOMAIN_HYPERV_STIMER:
 case VIR_DOMAIN_HYPERV_RESET:
 case VIR_DOMAIN_HYPERV_FREQUENCIES:
+case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
 if (src->hyperv_features[i] != dst->hyperv_features[i]) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27855,6 +27858,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 case VIR_DOMAIN_HYPERV_STIMER:
 case VIR_DOMAIN_HYPERV_RESET:
 case VIR_DOMAIN_HYPERV_FREQUENCIES:
+case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
 break;
 
 case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8b15b7e192..8fa5002985 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1792,6 +1792,7 @@ typedef enum {
 VIR_DOMAIN_HYPERV_RESET,
 VIR_DOMAIN_HYPERV_VENDOR_ID,
 VIR_DOMAIN_HYPERV_FREQUENCIES,
+VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
 
 VIR_DOMAIN_HYPERV_LAST
 } virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index a2fbfb577d..7a48b78eb9 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -111,6 +111,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RESET,
 0x4003, 0x0080);
 KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES,
 0x4003, 0x0800);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT,
+0x4003, 0x2000);
 
 static virCPUx86Feature x86_kvm_features[] =
 {
@@ -132,6 +134,7 @@ static virCPUx86Feature x86_kvm_features[] =
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_VPINDEX),
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET),
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES),
+KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT),
 };
 
 typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index c01eb41be5..a810c64fc9 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -64,6 +64,7 @@ struct _virCPUx86CPUID {
 # define VIR_CPU_x86_KVM_HV_VPINDEX   "__kvm_hv_vpindex"
 # 

[libvirt] [PATCH 3/3] conf: qemu: add support for Hyper-V PV TLB flush

2018-08-09 Thread Vitaly Kuznetsov
Qemu-3.0 supports Hyper-V-style PV TLB flush, Windows guests can benefit
from this feature as KVM knows which vCPUs are not currently scheduled (and
thus don't require any immediate action).

Signed-off-by: Vitaly Kuznetsov 
---
 docs/formatdomain.html.in   | 7 +++
 docs/schemas/domaincommon.rng   | 5 +
 src/conf/domain_conf.c  | 6 +-
 src/conf/domain_conf.h  | 1 +
 src/cpu/cpu_x86.c   | 3 +++
 src/cpu/cpu_x86_data.h  | 1 +
 src/qemu/qemu_command.c | 1 +
 src/qemu/qemu_parse_command.c   | 1 +
 src/qemu/qemu_process.c | 1 +
 tests/qemuxml2argvdata/hyperv-off.xml   | 1 +
 tests/qemuxml2argvdata/hyperv.args  | 2 +-
 tests/qemuxml2argvdata/hyperv.xml   | 1 +
 tests/qemuxml2xmloutdata/hyperv-off.xml | 1 +
 tests/qemuxml2xmloutdata/hyperv.xml | 1 +
 14 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index de0993696e..c37a4389dc 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1939,6 +1939,7 @@
 vendor_id state='on' value='KVM Hv'/
 frequencies state='on'/
 reenlightenment state='on'/
+tlbflush state='on'/
   /hyperv
   kvm
 hidden state='on'/
@@ -2073,6 +2074,12 @@
on, off
   4.7.0 (QEMU 3.0)
 
+
+  tlbflush
+  Enable PV TLB flush support
+   on, off
+  4.7.0 (QEMU 3.0)
+
   
   
   pvspinlock
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index b2a1ebfa3f..eab2618e51 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -5726,6 +5726,11 @@
 
   
 
+
+  
+
+  
+
   
 
   
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e2154b5bf7..f32bbd760c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -171,7 +171,8 @@ VIR_ENUM_IMPL(virDomainHyperv, VIR_DOMAIN_HYPERV_LAST,
   "reset",
   "vendor_id",
   "frequencies",
-  "reenlightenment")
+  "reenlightenment",
+  "tlbflush")
 
 VIR_ENUM_IMPL(virDomainKVM, VIR_DOMAIN_KVM_LAST,
   "hidden")
@@ -20021,6 +20022,7 @@ virDomainDefParseXML(xmlDocPtr xml,
 case VIR_DOMAIN_HYPERV_RESET:
 case VIR_DOMAIN_HYPERV_FREQUENCIES:
 case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+case VIR_DOMAIN_HYPERV_TLBFLUSH:
 break;
 
 case VIR_DOMAIN_HYPERV_SPINLOCKS:
@@ -22207,6 +22209,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr 
src,
 case VIR_DOMAIN_HYPERV_RESET:
 case VIR_DOMAIN_HYPERV_FREQUENCIES:
 case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+case VIR_DOMAIN_HYPERV_TLBFLUSH:
 if (src->hyperv_features[i] != dst->hyperv_features[i]) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("State of HyperV enlightenment "
@@ -27859,6 +27862,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 case VIR_DOMAIN_HYPERV_RESET:
 case VIR_DOMAIN_HYPERV_FREQUENCIES:
 case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
+case VIR_DOMAIN_HYPERV_TLBFLUSH:
 break;
 
 case VIR_DOMAIN_HYPERV_SPINLOCKS:
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8fa5002985..1287e862fc 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1793,6 +1793,7 @@ typedef enum {
 VIR_DOMAIN_HYPERV_VENDOR_ID,
 VIR_DOMAIN_HYPERV_FREQUENCIES,
 VIR_DOMAIN_HYPERV_REENLIGHTENMENT,
+VIR_DOMAIN_HYPERV_TLBFLUSH,
 
 VIR_DOMAIN_HYPERV_LAST
 } virDomainHyperv;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 7a48b78eb9..7fa84f6014 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -113,6 +113,8 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES,
 0x4003, 0x0800);
 KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT,
 0x4003, 0x2000);
+KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_TLBFLUSH,
+0x4004, 0x0004);
 
 static virCPUx86Feature x86_kvm_features[] =
 {
@@ -135,6 +137,7 @@ static virCPUx86Feature x86_kvm_features[] =
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET),
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES),
 KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT),
+KVM_FEATURE(VIR_CPU_x86_KVM_HV_TLBFLUSH),
 };
 
 typedef struct _virCPUx86Model virCPUx86Model;
diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h
index a810c64fc9..090a21156f 100644
--- a/src/cpu/cpu_x86_data.h
+++ b/src/cpu/cpu_x86_data.h
@@ -65,6 +65,7 @@ struct _virCPUx86CPUID {
 # define VIR_CPU_x86_KVM_HV_RESET "__kvm_hv_reset"
 # define 

[libvirt] [PATCH 0/3] conf: qemu: support new Hyper-V enlightenments

2018-08-09 Thread Vitaly Kuznetsov
Several new Hyper-V enlightenments were recently added to Qemu:
- hv-frequencies
- hv-reenlightenment
- hv-tlbflush

Support these in libvirt.

Vitaly Kuznetsov (3):
  conf: qemu: add support for Hyper-V frequency MSRs
  conf: qemu: add support for Hyper-V reenlightenment notifications
  conf: qemu: add support for Hyper-V PV TLB flush

 docs/formatdomain.html.in   | 21 +
 docs/schemas/domaincommon.rng   | 15 +++
 src/conf/domain_conf.c  | 14 +-
 src/conf/domain_conf.h  |  3 +++
 src/cpu/cpu_x86.c   |  9 +
 src/cpu/cpu_x86_data.h  |  3 +++
 src/qemu/qemu_command.c |  3 +++
 src/qemu/qemu_parse_command.c   |  3 +++
 src/qemu/qemu_process.c |  3 +++
 tests/qemuxml2argvdata/hyperv-off.xml   |  3 +++
 tests/qemuxml2argvdata/hyperv.args  |  3 ++-
 tests/qemuxml2argvdata/hyperv.xml   |  3 +++
 tests/qemuxml2xmloutdata/hyperv-off.xml |  3 +++
 tests/qemuxml2xmloutdata/hyperv.xml |  3 +++
 14 files changed, 87 insertions(+), 2 deletions(-)

-- 
2.14.4

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


Re: [libvirt] [PATCH v3 11/11] util: qemu: use VIR_AUTOPTR for aggregate types

2018-08-09 Thread Sukrit Bhatnagar
My bad. You can ignore this patch.
On Thu, 9 Aug 2018 at 18:18, Erik Skultety  wrote:
>
> On Thu, Aug 09, 2018 at 09:42:19AM +0530, Sukrit Bhatnagar wrote:
> > By making use of GNU C's cleanup attribute handled by the
> > VIR_AUTOPTR macro for declaring aggregate pointer variables,
> > majority of the calls to *Free functions can be dropped, which
> > in turn leads to getting rid of most of our cleanup sections.
> >
> > Signed-off-by: Sukrit Bhatnagar 
> > ---
> >  src/util/virqemu.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/src/util/virqemu.c b/src/util/virqemu.c
> > index bc78853..1cd2b93 100644
> > --- a/src/util/virqemu.c
> > +++ b/src/util/virqemu.c
> > @@ -281,6 +281,7 @@ virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr 
> > srcdef)
> >   cleanup:
> >  virBufferFreeAndReset();
> >  return ret;
> > +
>
> I'm sure you wanted to add some more into the commit, right? :)
>
> Erik

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


[libvirt] [PATCH 3/6] qemu: Remove unused argument 'bootable' from qemuBuildDriveStr

2018-08-09 Thread Peter Krempa
Now that the argument is unused we can remove it transitively from all
the call graphs.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_command.c | 20 +++-
 src/qemu/qemu_command.h |  3 +--
 src/qemu/qemu_hotplug.c |  2 +-
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 78090898be..daf037328f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1632,7 +1632,6 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,

 static char *
 qemuBuildDriveStr(virDomainDiskDefPtr disk,
-  bool bootable ATTRIBUTE_UNUSED,
   virQEMUCapsPtr qemuCaps)
 {
 virBuffer opt = VIR_BUFFER_INITIALIZER;
@@ -2244,14 +2243,12 @@ 
qemuBuildBlockStorageSourceAttachDataCommandline(virCommandPtr cmd,
 static int
 qemuBuildDiskSourceCommandLine(virCommandPtr cmd,
virDomainDiskDefPtr disk,
-   virQEMUCapsPtr qemuCaps,
-   bool driveBoot)
+   virQEMUCapsPtr qemuCaps)
 {
 qemuBlockStorageSourceAttachDataPtr data = NULL;
 int ret = -1;

-if (!(data = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps,
-  driveBoot)))
+if (!(data = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps)))
 return -1;

 if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, data, qemuCaps) < 
0 ||
@@ -2271,12 +2268,11 @@ qemuBuildDiskCommandLine(virCommandPtr cmd,
  const virDomainDef *def,
  virDomainDiskDefPtr disk,
  virQEMUCapsPtr qemuCaps,
- unsigned int bootindex,
- bool driveBoot)
+ unsigned int bootindex)
 {
 char *optstr;

-if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps, driveBoot) < 0)
+if (qemuBuildDiskSourceCommandLine(cmd, disk, qemuCaps) < 0)
 return -1;

 if (!qemuDiskBusNeedsDriveArg(disk->bus)) {
@@ -2326,7 +2322,6 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
 for (i = 0; i < def->ndisks; i++) {
 virDomainDiskDefPtr disk = def->disks[i];
 unsigned int bootindex = 0;
-bool driveBoot = false;

 if (disk->info.bootIndex) {
 bootindex = disk->info.bootIndex;
@@ -2349,7 +2344,7 @@ qemuBuildDisksCommandLine(virCommandPtr cmd,
 }

 if (qemuBuildDiskCommandLine(cmd, def, disk, qemuCaps,
- bootindex, driveBoot) < 0)
+ bootindex) < 0)
 return -1;
 }

@@ -10691,15 +10686,14 @@ qemuBuildHotpluggableCPUProps(const virDomainVcpuDef 
*vcpu)
  */
 qemuBlockStorageSourceAttachDataPtr
 qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
- virQEMUCapsPtr qemuCaps,
- bool driveBoot)
+ virQEMUCapsPtr qemuCaps)
 {
 qemuBlockStorageSourceAttachDataPtr data = NULL;

 if (VIR_ALLOC(data) < 0)
 return NULL;

-if (!(data->driveCmd = qemuBuildDriveStr(disk, driveBoot, qemuCaps)) ||
+if (!(data->driveCmd = qemuBuildDriveStr(disk, qemuCaps)) ||
 !(data->driveAlias = qemuAliasDiskDriveFromDisk(disk))) {
 qemuBlockStorageSourceAttachDataFree(data);
 return NULL;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index cf17dc1ede..283bf3120d 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -103,8 +103,7 @@ bool qemuDiskBusNeedsDriveArg(int bus);

 qemuBlockStorageSourceAttachDataPtr
 qemuBuildStorageSourceAttachPrepareDrive(virDomainDiskDefPtr disk,
- virQEMUCapsPtr qemuCaps,
- bool driveBoot);
+ virQEMUCapsPtr qemuCaps);
 int
 qemuBuildStorageSourceAttachPrepareCommon(virStorageSourcePtr src,
   qemuBlockStorageSourceAttachDataPtr 
data,
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 1488f0a7c2..5b52fe9edc 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -509,7 +509,7 @@ qemuHotplugDiskSourceAttachPrepare(virDomainDiskDefPtr disk,
 if (VIR_ALLOC(data) < 0)
 return NULL;

-if (!(backend = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps, 
false)))
+if (!(backend = qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps)))
 goto cleanup;

 if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, backend, 
qemuCaps) < 0)
-- 
2.16.2

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


[libvirt] [PATCH 5/6] qemu: command: Don't format -device isa-fdc, ... twice with two floppy drives

2018-08-09 Thread Peter Krempa
Fix regression introduced in 42fd5a58adb. With q35 machine type which
requires the explicitly specified FDC we'd format two  isa-fdc
controllers to the command line as the code was moved to a place where
it's called per-disk.

Move the call back after formatting all disks and reiterate the disks to
find the floppy controllers.

This also moves the '-global' directive which sets up the default
ISA-FDC to the end after all the disks but since we are modifying the
properties it is safe to do so.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_command.c| 100 +
 tests/qemuxml2argvdata/boot-complex-bootindex.args |   2 +-
 tests/qemuxml2argvdata/boot-complex.args   |   2 +-
 tests/qemuxml2argvdata/boot-strict.args|   2 +-
 .../disk-floppy-q35-2_11.x86_64-latest.args|   2 +-
 .../disk-floppy-q35-2_9.x86_64-latest.args |   3 +-
 tests/qemuxml2argvdata/disk-floppy-tray.args   |   2 +-
 tests/qemuxml2argvdata/disk-floppy.args|   2 +-
 .../disk-floppy.x86_64-latest.args |   2 +-
 tests/qemuxml2argvdata/user-aliases.args   |   2 +-
 10 files changed, 71 insertions(+), 48 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index daf037328f..1169164a39 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2143,50 +2143,78 @@ qemuBuildDiskDeviceStr(const virDomainDef *def,


 static int
-qemuBuildFloppyCommandLineOptions(virCommandPtr cmd,
-  const virDomainDef *def,
-  virDomainDiskDefPtr disk,
-  virQEMUCapsPtr qemuCaps,
-  unsigned int bootindex)
+qemuBuildFloppyCommandLineControllerOptions(virCommandPtr cmd,
+const virDomainDef *def,
+virQEMUCapsPtr qemuCaps,
+unsigned int bootFloppy)
 {
 virBuffer fdc_opts = VIR_BUFFER_INITIALIZER;
+bool explicitfdc = qemuDomainNeedsFDC(def);
+bool hasfloppy = false;
+unsigned int bootindex;
 char driveLetter;
 char *backendAlias = NULL;
 char *backendStr = NULL;
 char *bootindexStr = NULL;
+size_t i;
 int ret = -1;

-if (disk->info.addr.drive.unit)
-driveLetter = 'B';
-else
-driveLetter = 'A';
+virBufferAddLit(_opts, "isa-fdc,");

-if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, ) < 0)
-goto cleanup;
+for (i = 0; i < def->ndisks; i++) {
+virDomainDiskDefPtr disk = def->disks[i];

-if (backendAlias &&
-virAsprintf(, "drive%c=%s", driveLetter, backendAlias) < 0)
-goto cleanup;
+if (disk->bus != VIR_DOMAIN_DISK_BUS_FDC)
+continue;

-if (bootindex &&
-virAsprintf(, "bootindex%c=%u", driveLetter, bootindex) < 
0)
-goto cleanup;
+hasfloppy = true;

-if (!qemuDomainNeedsFDC(def)) {
-if (backendStr) {
-virCommandAddArg(cmd, "-global");
-virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
-}
+if (disk->info.bootIndex)
+bootindex = disk->info.bootIndex;
+else
+bootindex = bootFloppy;

-if (bootindexStr) {
-virCommandAddArg(cmd, "-global");
-virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
+bootFloppy = 0;
+
+if (disk->info.addr.drive.unit)
+driveLetter = 'B';
+else
+driveLetter = 'A';
+
+if (qemuDomainDiskGetBackendAlias(disk, qemuCaps, ) < 0)
+goto cleanup;
+
+if (backendAlias &&
+virAsprintf(, "drive%c=%s", driveLetter, backendAlias) 
< 0)
+goto cleanup;
+
+if (bootindex &&
+virAsprintf(, "bootindex%c=%u", driveLetter, 
bootindex) < 0)
+goto cleanup;
+
+if (!explicitfdc) {
+if (backendStr) {
+virCommandAddArg(cmd, "-global");
+virCommandAddArgFormat(cmd, "isa-fdc.%s", backendStr);
+}
+
+if (bootindexStr) {
+virCommandAddArg(cmd, "-global");
+virCommandAddArgFormat(cmd, "isa-fdc.%s", bootindexStr);
+}
+} else {
+virBufferStrcat(_opts, backendStr, ",", NULL);
+virBufferStrcat(_opts, bootindexStr, ",", NULL);
 }
-} else {
+
+VIR_FREE(backendAlias);
+VIR_FREE(backendStr);
+VIR_FREE(bootindexStr);
+}
+
+
+if (explicitfdc && hasfloppy) {
 /* Newer Q35 machine types require an explicit FDC controller */
-virBufferAddLit(_opts, "isa-fdc,");
-virBufferStrcat(_opts, backendStr, ",", NULL);
-virBufferStrcat(_opts, bootindexStr, NULL);
 virBufferTrim(_opts, ",", -1);
 virCommandAddArg(cmd, "-device");
 

[libvirt] [PATCH 4/6] tests: qemuxml2argv: Add 2 floppy drive tests for q35 with 2.9 and 2.11 machine

2018-08-09 Thread Peter Krempa
The floppy drive command line is different on the q35 machine. Make sure
to test that both drives are supported and also multiple machine
versions as we generate the commandline differently.

Note that both output files show wrong command line which will be fixed
subsequently.

Signed-off-by: Peter Krempa 
---
 .../disk-floppy-q35-2_11.x86_64-latest.args| 37 +
 tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml| 38 ++
 .../disk-floppy-q35-2_9.x86_64-latest.args | 36 
 tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml | 38 ++
 tests/qemuxml2argvtest.c   |  2 ++
 5 files changed, 151 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml
 create mode 100644 
tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
 create mode 100644 tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml

diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args 
b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
new file mode 100644
index 00..3c3d99f1d5
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
@@ -0,0 +1,37 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc-q35-2.11,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device 
pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
+addr=0x1 \
+-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
+-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
+-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
+-global isa-fdc.driveA=drive-fdc0-0-0 \
+-global isa-fdc.bootindexA=1 \
+-drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
+-global isa-fdc.driveB=drive-fdc0-0-1 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml 
b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml
new file mode 100644
index 00..6f51691a5c
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.xml
@@ -0,0 +1,38 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-x86_64
+
+  
+  
+  
+  
+
+
+  
+  
+  
+  
+
+
+  
+
+
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args 
b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
new file mode 100644
index 00..69be8616de
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.x86_64-latest.args
@@ -0,0 +1,36 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc-q35-2.9,accel=tcg,usb=off,dump-guest-core=off \
+-m 214 \
+-realtime mlock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device 
pcie-root-port,port=0x8,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\
+addr=0x1 \
+-device pcie-root-port,port=0x9,chassis=2,id=pci.2,bus=pcie.0,addr=0x1.0x1 \
+-device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
+-drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
+-device isa-fdc,driveA=drive-fdc0-0-0,bootindexA=1 \
+-drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
+-device isa-fdc,driveB=drive-fdc0-0-1 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml 
b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml
new file mode 100644
index 00..5301759279
--- /dev/null
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_9.xml
@@ -0,0 +1,38 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  219100
+  219100
+  1
+  
+

[libvirt] [PATCH 6/6] qemu: domain: Fix machine type version check for 'isa-fdc' usage

2018-08-09 Thread Peter Krempa
Starting from pc-q35-2.4 the floppy controller is not enabled by
default. Fix the version check so that it does not match 2.11 as being
2.1.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_domain.c   | 12 
 .../qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args |  4 +---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a5d81f863b..654cd4b872 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -9427,10 +9427,14 @@ qemuDomainMachineNeedsFDC(const char *machine)

 if (p) {
 if (STRPREFIX(p, "1.") ||
-STRPREFIX(p, "2.0") ||
-STRPREFIX(p, "2.1") ||
-STRPREFIX(p, "2.2") ||
-STRPREFIX(p, "2.3"))
+STREQ(p, "2.0") ||
+STRPREFIX(p, "2.0-") ||
+STREQ(p, "2.1") ||
+STRPREFIX(p, "2.1-") ||
+STREQ(p, "2.2") ||
+STRPREFIX(p, "2.2-") ||
+STREQ(p, "2.3") ||
+STRPREFIX(p, "2.3-"))
 return false;
 return true;
 }
diff --git a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args 
b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
index e38f7040ec..17abe9a989 100644
--- a/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-floppy-q35-2_11.x86_64-latest.args
@@ -29,9 +29,7 @@ addr=0x1 \
 -device qemu-xhci,id=usb,bus=pci.1,addr=0x0 \
 -drive file=/tmp/firmware.img,format=raw,if=none,id=drive-fdc0-0-0 \
 -drive file=/tmp/data.img,format=qcow2,if=none,id=drive-fdc0-0-1 \
--global isa-fdc.driveA=drive-fdc0-0-0 \
--global isa-fdc.bootindexA=1 \
--global isa-fdc.driveB=drive-fdc0-0-1 \
+-device isa-fdc,driveA=drive-fdc0-0-0,bootindexA=1,driveB=drive-fdc0-0-1 \
 -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
 resourcecontrol=deny \
 -msg timestamp=on
-- 
2.16.2

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


[libvirt] [PATCH 2/6] qemu: capabilities: Remove unused QEMU_CAPS_DRIVE_BOOT

2018-08-09 Thread Peter Krempa
The capability was never set except for (stale) tests. Remove it.

Signed-off-by: Peter Krempa 
---
 src/qemu/qemu_capabilities.h |  2 +-
 src/qemu/qemu_command.c  | 19 +--
 tests/qemuxml2argvtest.c | 26 +-
 3 files changed, 11 insertions(+), 36 deletions(-)

diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index f48de7d89f..26813a908c 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -52,7 +52,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for 
syntax-check */
 X_QEMU_CAPS_VNC_COLON, /* VNC takes or address + display */
 X_QEMU_CAPS_NO_REBOOT, /* Is the -no-reboot flag available */
 X_QEMU_CAPS_DRIVE, /* Is the new -drive arg available */
-QEMU_CAPS_DRIVE_BOOT, /* Does -drive support boot=on */
+X_QEMU_CAPS_DRIVE_BOOT, /* Does -drive support boot=on */

 /* 5 */
 X_QEMU_CAPS_NAME, /* Is the -name flag available */
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index d507e957a5..78090898be 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1632,7 +1632,7 @@ qemuBuildDiskFrontendAttributes(virDomainDiskDefPtr disk,

 static char *
 qemuBuildDriveStr(virDomainDiskDefPtr disk,
-  bool bootable,
+  bool bootable ATTRIBUTE_UNUSED,
   virQEMUCapsPtr qemuCaps)
 {
 virBuffer opt = VIR_BUFFER_INITIALIZER;
@@ -1689,15 +1689,6 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
 }
 }

-/* This is a frontend attribute which was replaced by bootindex passed in
- * with -device arguments. */
-if (bootable &&
-virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_BOOT) &&
-(disk->device == VIR_DOMAIN_DISK_DEVICE_DISK ||
- disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) &&
-disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
-virBufferAddLit(, ",boot=on");
-
 if (disk->src->readonly)
 virBufferAddLit(, ",readonly=on");

@@ -10243,14 +10234,6 @@ qemuBuildCommandLine(virQEMUDriverPtr driver,
 if (qemuBuildCommandLineValidate(driver, def) < 0)
 goto error;

-/*
- * do not use boot=on for drives when not using KVM since this
- * is not supported at all in upstream QEMU.
- */
-if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM) &&
-(def->virtType == VIR_DOMAIN_VIRT_QEMU))
-virQEMUCapsClear(qemuCaps, QEMU_CAPS_DRIVE_BOOT);
-
 cmd = virCommandNew(def->emulator);

 virCommandAddEnvPassCommon(cmd);
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b9dc6850e2..2860a53f00 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -882,13 +882,10 @@ mymain(void)
 DO_TEST("boot-order",
 QEMU_CAPS_VIRTIO_BLK_SCSI);
 DO_TEST("boot-complex",
-QEMU_CAPS_DRIVE_BOOT,
 QEMU_CAPS_VIRTIO_BLK_SCSI);
 DO_TEST("boot-complex-bootindex",
-QEMU_CAPS_DRIVE_BOOT,
 QEMU_CAPS_VIRTIO_BLK_SCSI);
 DO_TEST("boot-strict",
-QEMU_CAPS_DRIVE_BOOT,
 QEMU_CAPS_BOOT_STRICT,
 QEMU_CAPS_VIRTIO_BLK_SCSI);

@@ -1012,31 +1009,26 @@ mymain(void)
 DO_TEST("disk-floppy-tray", NONE);
 DO_TEST("disk-virtio-s390",
 QEMU_CAPS_VIRTIO_S390);
-DO_TEST("disk-virtio", QEMU_CAPS_DRIVE_BOOT);
+DO_TEST("disk-virtio", NONE);
 DO_TEST("disk-virtio-ccw",
 QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
 DO_TEST("disk-virtio-ccw-many",
 QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
 DO_TEST("disk-virtio-scsi-ccw", QEMU_CAPS_VIRTIO_SCSI,
 QEMU_CAPS_CCW, QEMU_CAPS_VIRTIO_S390);
-DO_TEST("disk-order",
-QEMU_CAPS_DRIVE_BOOT, QEMU_CAPS_VIRTIO_BLK_SCSI);
+DO_TEST("disk-order", QEMU_CAPS_VIRTIO_BLK_SCSI);
 DO_TEST("disk-virtio-queues",
 QEMU_CAPS_VIRTIO_BLK_NUM_QUEUES);
-DO_TEST("disk-boot-disk",
-QEMU_CAPS_DRIVE_BOOT);
-DO_TEST("disk-boot-cdrom",
-QEMU_CAPS_DRIVE_BOOT);
-DO_TEST("floppy-drive-fat",
-QEMU_CAPS_DRIVE_BOOT);
+DO_TEST("disk-boot-disk", NONE);
+DO_TEST("disk-boot-cdrom", NONE);
+DO_TEST("floppy-drive-fat", NONE);
 DO_TEST_CAPS_LATEST("floppy-drive-fat");
 DO_TEST("disk-readonly-disk", NONE);
 DO_TEST_CAPS_LATEST("disk-readonly-disk");
-DO_TEST("disk-fmt-qcow",
-QEMU_CAPS_DRIVE_BOOT);
-DO_TEST_PARSE_ERROR("disk-fmt-cow", QEMU_CAPS_DRIVE_BOOT);
-DO_TEST_PARSE_ERROR("disk-fmt-dir", QEMU_CAPS_DRIVE_BOOT);
-DO_TEST_PARSE_ERROR("disk-fmt-iso", QEMU_CAPS_DRIVE_BOOT);
+DO_TEST("disk-fmt-qcow", NONE);
+DO_TEST_PARSE_ERROR("disk-fmt-cow", NONE);
+DO_TEST_PARSE_ERROR("disk-fmt-dir", NONE);
+DO_TEST_PARSE_ERROR("disk-fmt-iso", NONE);
 DO_TEST("disk-shared", NONE);
 DO_TEST_CAPS_LATEST("disk-shared");
 DO_TEST_PARSE_ERROR("disk-shared-qcow", NONE);
-- 
2.16.2

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

[libvirt] [PATCH 0/6] qemu: Fix handling of floppy controller setup

2018-08-09 Thread Peter Krempa
Cleanup always present capability QEMU_CAPS_BOOTINDEX and unused
capability QEMU_CAPS_DRIVE_BOOT as a preparation/cleanup step and
fix two bugs in setup of the floppy controller for the q35 machine type.

Peter Krempa (6):
  qemu: capabilities: Always assume QEMU_CAPS_BOOTINDEX
  qemu: capabilities: Remove unused QEMU_CAPS_DRIVE_BOOT
  qemu: Remove unused argument 'bootable' from qemuBuildDriveStr
  tests: qemuxml2argv: Add 2 floppy drive tests for q35 with 2.9 and
2.11 machine
  qemu: command: Don't format -device isa-fdc,... twice with two floppy
drives
  qemu: domain: Fix machine type version check for 'isa-fdc' usage

 src/qemu/qemu_capabilities.c   |   4 +-
 src/qemu/qemu_capabilities.h   |   4 +-
 src/qemu/qemu_command.c| 233 -
 src/qemu/qemu_command.h|   3 +-
 src/qemu/qemu_domain.c |  12 +-
 src/qemu/qemu_hotplug.c|   2 +-
 tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_1.7.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.10.0.aarch64.xml |   1 -
 tests/qemucapabilitiesdata/caps_2.10.0.ppc64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.10.0.x86_64.xml  |   1 -
 tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.11.0.x86_64.xml  |   1 -
 tests/qemucapabilitiesdata/caps_2.12.0.aarch64.xml |   1 -
 tests/qemucapabilitiesdata/caps_2.12.0.ppc64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml  |   1 -
 tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.6.0.aarch64.xml  |   1 -
 tests/qemucapabilitiesdata/caps_2.6.0.ppc64.xml|   1 -
 tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.7.0.s390x.xml|   1 -
 tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml|   1 -
 tests/qemucapabilitiesdata/caps_2.8.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_2.9.0.ppc64.xml|   1 -
 tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml|   1 -
 tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml   |   1 -
 tests/qemucapabilitiesdata/caps_3.0.0.ppc64.xml|   1 -
 tests/qemucapabilitiesdata/caps_3.0.0.x86_64.xml   |   1 -
 .../aarch64-aavmf-virtio-mmio.args |   3 +-
 tests/qemuxml2argvdata/aarch64-acpi-uefi.args  |   3 +-
 .../qemuxml2argvdata/aarch64-cpu-passthrough.args  |   3 +-
 tests/qemuxml2argvdata/aarch64-gic-host.args   |   3 +-
 tests/qemuxml2argvdata/aarch64-gic-none-tcg.args   |   3 +-
 tests/qemuxml2argvdata/aarch64-gic-v2.args |   3 +-
 tests/qemuxml2argvdata/aarch64-gic-v3.args |   3 +-
 tests/qemuxml2argvdata/aarch64-kvm-32-on-64.args   |   3 +-
 tests/qemuxml2argvdata/aarch64-noacpi-nouefi.args  |   1 -
 tests/qemuxml2argvdata/aarch64-noacpi-uefi.args|   3 +-
 tests/qemuxml2argvdata/aarch64-pci-serial.args |   1 -
 .../qemuxml2argvdata/aarch64-traditional-pci.args  |   1 -
 .../aarch64-usb-controller-nec-xhci.args   |   1 -
 .../aarch64-usb-controller-qemu-xhci.args  |   1 -
 tests/qemuxml2argvdata/aarch64-video-default.args  |   1 -
 .../aarch64-virt-2.6-virtio-pci-default.args   |   3 +-
 .../qemuxml2argvdata/aarch64-virt-default-nic.args |   1 -
 tests/qemuxml2argvdata/aarch64-virt-virtio.args|   3 +-
 .../aarch64-virtio-pci-default.args|   3 +-
 .../aarch64-virtio-pci-manual-addresses.args   |   3 +-
 tests/qemuxml2argvdata/acpi-table.args |   1 -
 tests/qemuxml2argvdata/arm-vexpressa9-basic.args   |   1 -
 tests/qemuxml2argvdata/arm-vexpressa9-nodevs.args  |   1 -
 tests/qemuxml2argvdata/arm-vexpressa9-virtio.args  |   3 +-
 tests/qemuxml2argvdata/arm-virt-virtio.args|   3 +-
 tests/qemuxml2argvdata/autoindex.args  |   3 +-
 tests/qemuxml2argvdata/balloon-ccw-deflate.args|   1 -
 tests/qemuxml2argvdata/balloon-device-auto.args|   4 +-
 .../balloon-device-deflate-off.args|   4 +-
 tests/qemuxml2argvdata/balloon-device-deflate.args |   4 +-
 tests/qemuxml2argvdata/balloon-device-period.args  |   4 +-
 tests/qemuxml2argvdata/balloon-device.args |   4 +-
 tests/qemuxml2argvdata/balloon-mmio-deflate.args   |   1 -
 tests/qemuxml2argvdata/bios-nvram-secure.args  |   4 +-
 tests/qemuxml2argvdata/bios-nvram.args |   5 +-
 tests/qemuxml2argvdata/bios.args   |   5 +-
 tests/qemuxml2argvdata/blkdeviotune-group-num.args |   4 +-
 .../qemuxml2argvdata/blkdeviotune-max-length.args 

Re: [libvirt] [PATCH v3 11/11] util: qemu: use VIR_AUTOPTR for aggregate types

2018-08-09 Thread Erik Skultety
On Thu, Aug 09, 2018 at 09:42:19AM +0530, Sukrit Bhatnagar wrote:
> By making use of GNU C's cleanup attribute handled by the
> VIR_AUTOPTR macro for declaring aggregate pointer variables,
> majority of the calls to *Free functions can be dropped, which
> in turn leads to getting rid of most of our cleanup sections.
>
> Signed-off-by: Sukrit Bhatnagar 
> ---
>  src/util/virqemu.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/src/util/virqemu.c b/src/util/virqemu.c
> index bc78853..1cd2b93 100644
> --- a/src/util/virqemu.c
> +++ b/src/util/virqemu.c
> @@ -281,6 +281,7 @@ virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr 
> srcdef)
>   cleanup:
>  virBufferFreeAndReset();
>  return ret;
> +

I'm sure you wanted to add some more into the commit, right? :)

Erik

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


[libvirt] [PATCH v2 20/20] qemu: ensure that memory 'discard' is used if specified in XML

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/qemu/qemu_command.c|  4 +++-
 .../pages-discard-hugepages.args   | 11 +++
 tests/qemuxml2argvdata/pages-discard.args  | 18 ++
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index dbeb3a54f6..a7859feae6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3147,6 +3147,7 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
 return -1;
 
 if (useHugepage || mem->nvdimmPath || memAccess ||
+discard == VIR_TRISTATE_BOOL_YES ||
 def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_FILE) {
 
 if (useHugepage) {
@@ -3228,7 +3229,8 @@ qemuBuildMemoryBackendProps(virJSONValuePtr *backendProps,
 if (!needHugepage && !mem->sourceNodes && !nodeSpecified &&
 !mem->nvdimmPath &&
 memAccess == VIR_DOMAIN_MEMORY_ACCESS_DEFAULT &&
-def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_FILE && !force) {
+def->mem.source != VIR_DOMAIN_MEMORY_SOURCE_FILE && !force &&
+discard != VIR_TRISTATE_BOOL_YES) {
 /* report back that using the new backend is not necessary
  * to achieve the desired configuration */
 ret = 1;
diff --git a/tests/qemuxml2argvdata/pages-discard-hugepages.args 
b/tests/qemuxml2argvdata/pages-discard-hugepages.args
index 2dfacefe4a..d859480c26 100644
--- a/tests/qemuxml2argvdata/pages-discard-hugepages.args
+++ b/tests/qemuxml2argvdata/pages-discard-hugepages.args
@@ -10,10 +10,13 @@ QEMU_AUDIO_DRV=none \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 1024 \
 -smp 2,sockets=2,cores=1,threads=1 \
--mem-prealloc \
--mem-path /dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu \
--numa node,nodeid=0,cpus=0,mem=256 \
--numa node,nodeid=1,cpus=1,mem=768 \
+-object memory-backend-file,id=ram-node0,prealloc=yes,\
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu,size=268435456 \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-object memory-backend-file,id=ram-node1,prealloc=yes,\
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu,\
+discard-data=yes,size=805306368 \
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
 -uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
 -display none \
 -no-user-config \
diff --git a/tests/qemuxml2argvdata/pages-discard.args 
b/tests/qemuxml2argvdata/pages-discard.args
index 9db8c72a22..4ae20f531f 100644
--- a/tests/qemuxml2argvdata/pages-discard.args
+++ b/tests/qemuxml2argvdata/pages-discard.args
@@ -10,10 +10,20 @@ QEMU_AUDIO_DRV=none \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
 -m 4096 \
 -smp 4,sockets=4,cores=1,threads=1 \
--numa node,nodeid=0,cpus=0,mem=1024 \
--numa node,nodeid=1,cpus=1,mem=1024 \
--numa node,nodeid=2,cpus=2,mem=1024 \
--numa node,nodeid=3,cpus=3,mem=1024 \
+-object memory-backend-file,id=ram-node0,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node0,\
+discard-data=yes,size=1073741824 \
+-numa node,nodeid=0,cpus=0,memdev=ram-node0 \
+-object memory-backend-ram,id=ram-node1,size=1073741824 \
+-numa node,nodeid=1,cpus=1,memdev=ram-node1 \
+-object memory-backend-file,id=ram-node2,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node2,\
+discard-data=yes,size=1073741824 \
+-numa node,nodeid=2,cpus=2,memdev=ram-node2 \
+-object memory-backend-file,id=ram-node3,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-QEMUGuest1/ram-node3,\
+discard-data=yes,size=1073741824 \
+-numa node,nodeid=3,cpus=3,memdev=ram-node3 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
 -display none \
 -no-user-config \
-- 
2.17.1

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


[libvirt] [PATCH v2 10/20] tests: rename hugepages-pages4 into hugepages-numa-nodeset-nonexist

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 xml => hugepages-numa-nodeset-nonexist.xml} | 17 +
 tests/qemuxml2argvtest.c|  5 +++--
 .../hugepages-numa-nodeset-nonexist.xml |  1 +
 tests/qemuxml2xmloutdata/hugepages-pages4.xml   |  1 -
 tests/qemuxml2xmltest.c |  2 +-
 5 files changed, 6 insertions(+), 20 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages4.xml => 
hugepages-numa-nodeset-nonexist.xml} (66%)
 create mode 12 tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-pages4.xml

diff --git a/tests/qemuxml2argvdata/hugepages-pages4.xml 
b/tests/qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml
similarity index 66%
rename from tests/qemuxml2argvdata/hugepages-pages4.xml
rename to tests/qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml
index 9f79881a59..8211d72be9 100644
--- a/tests/qemuxml2argvdata/hugepages-pages4.xml
+++ b/tests/qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml
@@ -10,10 +10,6 @@
 
   
   4
-  
-
-
-  
   
 hvm
 
@@ -32,23 +28,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b2ee1fe6bb..d4a6738b98 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -982,12 +982,13 @@ mymain(void)
 DO_TEST("hugepages-numa-nodeset-part",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
+DO_TEST_FAILURE("hugepages-numa-nodeset-nonexist",
+QEMU_CAPS_OBJECT_MEMORY_RAM,
+QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-shared",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
-DO_TEST_FAILURE("hugepages-pages4",
-QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-pages5", NONE);
 DO_TEST("hugepages-pages6", NONE);
 DO_TEST("hugepages-pages7",
diff --git a/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml 
b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
new file mode 12
index 00..d490edca69
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/hugepages-numa-nodeset-nonexist.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages4.xml 
b/tests/qemuxml2xmloutdata/hugepages-pages4.xml
deleted file mode 12
index 127e66e64f..00
--- a/tests/qemuxml2xmloutdata/hugepages-pages4.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-pages4.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 29dc03e805..92dfa87e24 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -336,7 +336,7 @@ mymain(void)
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
 DO_TEST("hugepages-numa-nodeset-part", NONE);
-DO_TEST("hugepages-pages4", NONE);
+DO_TEST("hugepages-numa-nodeset-nonexist", NONE);
 DO_TEST("hugepages-pages5", NONE);
 DO_TEST("hugepages-pages6", NONE);
 DO_TEST("hugepages-pages7", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 08/20] tests: extract pages-discard-hugepages out of hugepages-pages3

2018-08-09 Thread Pavel Hrdina
Similar thing happens as for pages-discard, it is not passed to QEMU.

Signed-off-by: Pavel Hrdina 
---
 tests/qemuxml2argvdata/hugepages-pages3.args  |  3 +-
 tests/qemuxml2argvdata/hugepages-pages3.xml   |  4 +--
 .../pages-discard-hugepages.args  | 28 +++
 .../pages-discard-hugepages.xml   | 34 +++
 tests/qemuxml2argvtest.c  |  7 ++--
 tests/qemuxml2xmloutdata/hugepages-pages3.xml |  4 +--
 .../pages-discard-hugepages.xml   |  1 +
 tests/qemuxml2xmltest.c   |  1 +
 8 files changed, 74 insertions(+), 8 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/pages-discard-hugepages.args
 create mode 100644 tests/qemuxml2argvdata/pages-discard-hugepages.xml
 create mode 12 tests/qemuxml2xmloutdata/pages-discard-hugepages.xml

diff --git a/tests/qemuxml2argvdata/hugepages-pages3.args 
b/tests/qemuxml2argvdata/hugepages-pages3.args
index d55265cdd8..2fc701ca22 100644
--- a/tests/qemuxml2argvdata/hugepages-pages3.args
+++ b/tests/qemuxml2argvdata/hugepages-pages3.args
@@ -13,8 +13,7 @@ QEMU_AUDIO_DRV=none \
 -object memory-backend-ram,id=ram-node0,size=268435456 \
 -numa node,nodeid=0,cpus=0,memdev=ram-node0 \
 -object memory-backend-file,id=ram-node1,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-SomeDummyHugepagesGu,\
-discard-data=yes,size=805306368 \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-SomeDummyHugepagesGu,size=805306368 \
 -numa node,nodeid=1,cpus=1,memdev=ram-node1 \
 -uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
 -display none \
diff --git a/tests/qemuxml2argvdata/hugepages-pages3.xml 
b/tests/qemuxml2argvdata/hugepages-pages3.xml
index 147acc4c95..3d3b3f3cc3 100644
--- a/tests/qemuxml2argvdata/hugepages-pages3.xml
+++ b/tests/qemuxml2argvdata/hugepages-pages3.xml
@@ -15,8 +15,8 @@
   
   
 
-  
-  
+  
+  
 
   
   
diff --git a/tests/qemuxml2argvdata/pages-discard-hugepages.args 
b/tests/qemuxml2argvdata/pages-discard-hugepages.args
new file mode 100644
index 00..2dfacefe4a
--- /dev/null
+++ b/tests/qemuxml2argvdata/pages-discard-hugepages.args
@@ -0,0 +1,28 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name SomeDummyHugepagesGuest \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 1024 \
+-smp 2,sockets=2,cores=1,threads=1 \
+-mem-prealloc \
+-mem-path /dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu \
+-numa node,nodeid=0,cpus=0,mem=256 \
+-numa node,nodeid=1,cpus=1,mem=768 \
+-uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,\
+path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb
diff --git a/tests/qemuxml2argvdata/pages-discard-hugepages.xml 
b/tests/qemuxml2argvdata/pages-discard-hugepages.xml
new file mode 100644
index 00..d1620d1946
--- /dev/null
+++ b/tests/qemuxml2argvdata/pages-discard-hugepages.xml
@@ -0,0 +1,34 @@
+
+  SomeDummyHugepagesGuest
+  ef1bdff4-27f3-4e85-a807-5fb4d58463cc
+  1048576
+  1048576
+  
+
+  
+  2
+  
+hvm
+
+  
+  
+
+  
+  
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-i686
+
+  
+
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 697f3436c6..4f1c583327 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -963,6 +963,10 @@ mymain(void)
 DO_TEST("pages-discard",
 QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
+DO_TEST("pages-discard-hugepages",
+QEMU_CAPS_OBJECT_MEMORY_RAM,
+QEMU_CAPS_OBJECT_MEMORY_FILE,
+QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-numa-default",
 QEMU_CAPS_OBJECT_MEMORY_FILE);
@@ -976,8 +980,7 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-pages3", QEMU_CAPS_OBJECT_MEMORY_RAM,
-QEMU_CAPS_OBJECT_MEMORY_FILE,
-QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
+QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-shared",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages3.xml 
b/tests/qemuxml2xmloutdata/hugepages-pages3.xml
index 90e6efa5ea..be21c3eddd 100644
--- a/tests/qemuxml2xmloutdata/hugepages-pages3.xml
+++ b/tests/qemuxml2xmloutdata/hugepages-pages3.xml
@@ -15,8 +15,8 @@
   
   
 
-  
-  
+  
+  
 
   
   
diff --git a/tests/qemuxml2xmloutdata/pages-discard-hugepages.xml 
b/tests/qemuxml2xmloutdata/pages-discard-hugepages.xml
new file mode 12
index 

[libvirt] [PATCH v2 19/20] conf: Introduce virDomainDefPostParseMemtune

2018-08-09 Thread Pavel Hrdina
Previously we were ignoring "nodeset" attribute for hugepage pages
if there was no guest NUMA topology configured in the domain XML.
Commit  partially fixed
that issue but it introduced a somehow valid regression.

In case that there is no guest NUMA topology configured and the
"nodeset" attribute is set to "0" it was accepted and was working
properly even though it was not completely valid XML.

This patch introduces a workaround that it will ignore the nodeset="0"
only in case that there is no guest NUMA topology in order not to
hit the validation error.

After this commit the following XML configuration is valid:

  

  

  

but this configuration remains invalid:

  

  
  

  

The issue with the second configuration is that it was originally
working, however changing the order of the  elements resolved
into using different page size for the guest.  The code is written
in a way that it expect only one page configured and always uses only
the first page in case that there is no guest NUMA topology configured.
See qemuBuildMemPathStr() function for details.

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

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c| 27 +
 tests/qemuxml2argvdata/hugepages-nodeset.args | 26 
 tests/qemuxml2argvtest.c  |  2 +-
 .../qemuxml2xmloutdata/hugepages-nodeset.xml  | 30 +++
 tests/qemuxml2xmltest.c   |  1 +
 5 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/hugepages-nodeset.args
 create mode 100644 tests/qemuxml2xmloutdata/hugepages-nodeset.xml

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f88576b5cc..f0d44bb75d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4088,6 +4088,31 @@ virDomainDefPostParseMemory(virDomainDefPtr def,
 }
 
 
+static void
+virDomainDefPostParseMemtune(virDomainDefPtr def)
+{
+size_t i;
+
+if (virDomainNumaGetNodeCount(def->numa) == 0) {
+/* If guest NUMA is not configured and any hugepage page has nodemask
+ * set to "0" free and clear that nodemas, otherwise we would rise
+ * an error that there is no guest NUMA node configured. */
+for (i = 0; i < def->mem.nhugepages; i++) {
+ssize_t nextBit;
+
+if (!def->mem.hugepages[i].nodemask)
+continue;
+
+nextBit = virBitmapNextSetBit(def->mem.hugepages[i].nodemask, 0);
+if (nextBit < 0) {
+virBitmapFree(def->mem.hugepages[i].nodemask);
+def->mem.hugepages[i].nodemask = NULL;
+}
+}
+}
+}
+
+
 static int
 virDomainDefAddConsoleCompat(virDomainDefPtr def)
 {
@@ -5145,6 +5170,8 @@ virDomainDefPostParseCommon(virDomainDefPtr def,
 if (virDomainDefPostParseMemory(def, data->parseFlags) < 0)
 return -1;
 
+virDomainDefPostParseMemtune(def);
+
 if (virDomainDefRejectDuplicateControllers(def) < 0)
 return -1;
 
diff --git a/tests/qemuxml2argvdata/hugepages-nodeset.args 
b/tests/qemuxml2argvdata/hugepages-nodeset.args
new file mode 100644
index 00..d094be1252
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-nodeset.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name SomeDummyHugepagesGuest \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 1024 \
+-mem-prealloc \
+-mem-path /dev/hugepages2M/libvirt/qemu/-1-SomeDummyHugepagesGu \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,\
+path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9e2e59ec44..cec0fa5b33 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -975,7 +975,7 @@ mymain(void)
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
 DO_TEST_PARSE_ERROR("hugepages-default-1G-nodeset-2M", NONE);
-DO_TEST_PARSE_ERROR("hugepages-nodeset", NONE);
+DO_TEST("hugepages-nodeset", NONE);
 DO_TEST_PARSE_ERROR("hugepages-nodeset-nonexist",
 QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_OBJECT_MEMORY_FILE,
diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml 
b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
new file mode 100644
index 00..ac219a7800
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
@@ -0,0 +1,30 @@
+
+  SomeDummyHugepagesGuest
+  ef1bdff4-27f3-4e85-a807-5fb4d58463cc
+  1048576
+  1048576
+  
+
+  
+
+  
+  2
+  
+hvm
+
+ 

[libvirt] [PATCH v2 16/20] tests: introduce hugepages-nodeset

2018-08-09 Thread Pavel Hrdina
This use-case was broken by commit
.

We allowed this configuration and it was working as expected therefore
we can consider it as regression.  We should have never allowed such
configuration so now the best solution is in case of non-numa guest
silently ignore the 'nodeset' attribute if it's set to '0'.

That will be fixed by following patches.

Signed-off-by: Pavel Hrdina 
---
 tests/qemuxml2argvdata/hugepages-nodeset.xml  | 30 +++
 tests/qemuxml2argvtest.c  |  1 +
 .../qemuxml2xmloutdata/hugepages-nodeset.xml  |  1 +
 tests/qemuxml2xmltest.c   |  1 +
 4 files changed, 33 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/hugepages-nodeset.xml
 create mode 12 tests/qemuxml2xmloutdata/hugepages-nodeset.xml

diff --git a/tests/qemuxml2argvdata/hugepages-nodeset.xml 
b/tests/qemuxml2argvdata/hugepages-nodeset.xml
new file mode 100644
index 00..4a85ddffad
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-nodeset.xml
@@ -0,0 +1,30 @@
+
+  SomeDummyHugepagesGuest
+  ef1bdff4-27f3-4e85-a807-5fb4d58463cc
+  1048576
+  1048576
+  
+
+  
+
+  
+  2
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-i686
+
+  
+
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 273be61db3..606f710f20 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -975,6 +975,7 @@ mymain(void)
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
 DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
+DO_TEST_FAILURE("hugepages-nodeset", NONE);
 DO_TEST_FAILURE("hugepages-nodeset-nonexist",
 QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_OBJECT_MEMORY_FILE,
diff --git a/tests/qemuxml2xmloutdata/hugepages-nodeset.xml 
b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
new file mode 12
index 00..b55838b780
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-nodeset.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/hugepages-nodeset.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 958b955810..8af023f6b7 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -336,6 +336,7 @@ mymain(void)
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
 DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
+DO_TEST("hugepages-nodeset", NONE);
 DO_TEST("hugepages-numa-default-2M", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 07/20] tests: rename hugepages-pages2 into hugepages-numa-default-2M

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 ...s-pages2.args => hugepages-numa-default-2M.args} |  5 +
 ...ges-pages2.xml => hugepages-numa-default-2M.xml} |  8 +---
 tests/qemuxml2argvtest.c|  5 +++--
 ...ges-pages2.xml => hugepages-numa-default-2M.xml} | 13 +
 tests/qemuxml2xmltest.c |  2 +-
 5 files changed, 7 insertions(+), 26 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages2.args => 
hugepages-numa-default-2M.args} (77%)
 rename tests/qemuxml2argvdata/{hugepages-pages2.xml => 
hugepages-numa-default-2M.xml} (77%)
 rename tests/qemuxml2xmloutdata/{hugepages-pages2.xml => 
hugepages-numa-default-2M.xml} (67%)

diff --git a/tests/qemuxml2argvdata/hugepages-pages2.args 
b/tests/qemuxml2argvdata/hugepages-numa-default-2M.args
similarity index 77%
rename from tests/qemuxml2argvdata/hugepages-pages2.args
rename to tests/qemuxml2argvdata/hugepages-numa-default-2M.args
index 21105ef844..2dfacefe4a 100644
--- a/tests/qemuxml2argvdata/hugepages-pages2.args
+++ b/tests/qemuxml2argvdata/hugepages-numa-default-2M.args
@@ -25,7 +25,4 @@ 
path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
 -no-shutdown \
 -no-acpi \
 -boot c \
--usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-pages2.xml 
b/tests/qemuxml2argvdata/hugepages-numa-default-2M.xml
similarity index 77%
rename from tests/qemuxml2argvdata/hugepages-pages2.xml
rename to tests/qemuxml2argvdata/hugepages-numa-default-2M.xml
index 3b2d72ef3c..357c77da2a 100644
--- a/tests/qemuxml2argvdata/hugepages-pages2.xml
+++ b/tests/qemuxml2argvdata/hugepages-numa-default-2M.xml
@@ -25,16 +25,10 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-
 
-
 
 
 
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 2d94c20f40..697f3436c6 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -966,14 +966,15 @@ mymain(void)
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-numa-default",
 QEMU_CAPS_OBJECT_MEMORY_FILE);
+DO_TEST("hugepages-numa-default-2M",
+QEMU_CAPS_OBJECT_MEMORY_RAM,
+QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-numa-default-dimm",
 QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-numa-nodeset",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
-DO_TEST("hugepages-pages2", QEMU_CAPS_OBJECT_MEMORY_RAM,
-QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-pages3", QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages2.xml 
b/tests/qemuxml2xmloutdata/hugepages-numa-default-2M.xml
similarity index 67%
rename from tests/qemuxml2xmloutdata/hugepages-pages2.xml
rename to tests/qemuxml2xmloutdata/hugepages-numa-default-2M.xml
index cd79960f1b..3777824e1a 100644
--- a/tests/qemuxml2xmloutdata/hugepages-pages2.xml
+++ b/tests/qemuxml2xmloutdata/hugepages-numa-default-2M.xml
@@ -25,23 +25,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 1484c3176f..1e6aca2a90 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -331,9 +331,9 @@ mymain(void)
 
 DO_TEST("pages-discard", NONE);
 DO_TEST("hugepages-default", NONE);
+DO_TEST("hugepages-numa-default-2M", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
-DO_TEST("hugepages-pages2", NONE);
 DO_TEST("hugepages-pages3", NONE);
 DO_TEST("hugepages-pages4", NONE);
 DO_TEST("hugepages-pages5", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 18/20] conf: Move hugepages validation out of XML parser

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c | 75 ++
 1 file changed, 40 insertions(+), 35 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index be9c08626a..f88576b5cc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6191,9 +6191,49 @@ virDomainDefMemtuneValidate(const virDomainDef *def)
 size_t i;
 ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1;
 
+if (mem->nhugepages == 0)
+return 0;
+
+if (mem->allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("hugepages are not allowed with memory "
+ "allocation ondemand"));
+return -1;
+}
+
+if (mem->source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("hugepages are not allowed with anonymous "
+ "memory source"));
+return -1;
+}
+
 for (i = 0; i < mem->nhugepages; i++) {
+size_t j;
 ssize_t nextBit;
 
+for (j = 0; j < i; j++) {
+if (mem->hugepages[i].nodemask &&
+mem->hugepages[j].nodemask &&
+virBitmapOverlaps(mem->hugepages[i].nodemask,
+  mem->hugepages[j].nodemask)) {
+virReportError(VIR_ERR_XML_DETAIL,
+   _("nodeset attribute of hugepages "
+ "of sizes %llu and %llu intersect"),
+   mem->hugepages[i].size,
+   mem->hugepages[j].size);
+return -1;
+} else if (!mem->hugepages[i].nodemask &&
+   !mem->hugepages[j].nodemask) {
+virReportError(VIR_ERR_XML_DETAIL,
+   _("two master hugepages detected: "
+ "%llu and %llu"),
+   mem->hugepages[i].size,
+   mem->hugepages[j].size);
+return -1;
+}
+}
+
 if (!mem->hugepages[i].nodemask) {
 /* This is the master hugepage to use. Skip it as it has no
  * nodemask anyway. */
@@ -19466,19 +19506,6 @@ virDomainDefParseXML(xmlDocPtr xml,
 
 if (virXPathNode("./memoryBacking/hugepages", ctxt)) {
 /* hugepages will be used */
-
-if (def->mem.allocation == VIR_DOMAIN_MEMORY_ALLOCATION_ONDEMAND) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("hugepages are not allowed with memory allocation 
ondemand"));
-goto error;
-}
-
-if (def->mem.source == VIR_DOMAIN_MEMORY_SOURCE_ANONYMOUS) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-   _("hugepages are not allowed with anonymous memory 
source"));
-goto error;
-}
-
 if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, 
)) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot extract hugepages nodes"));
@@ -19494,28 +19521,6 @@ virDomainDefParseXML(xmlDocPtr xml,
>mem.hugepages[i]) < 0)
 goto error;
 def->mem.nhugepages++;
-
-for (j = 0; j < i; j++) {
-if (def->mem.hugepages[i].nodemask &&
-def->mem.hugepages[j].nodemask &&
-virBitmapOverlaps(def->mem.hugepages[i].nodemask,
-  def->mem.hugepages[j].nodemask)) {
-virReportError(VIR_ERR_XML_DETAIL,
-   _("nodeset attribute of hugepages "
- "of sizes %llu and %llu intersect"),
-   def->mem.hugepages[i].size,
-   def->mem.hugepages[j].size);
-goto error;
-} else if (!def->mem.hugepages[i].nodemask &&
-   !def->mem.hugepages[j].nodemask) {
-virReportError(VIR_ERR_XML_DETAIL,
-   _("two master hugepages detected: "
- "%llu and %llu"),
-   def->mem.hugepages[i].size,
-   def->mem.hugepages[j].size);
-goto error;
-}
-}
 }
 
 VIR_FREE(nodes);
-- 
2.17.1

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


[libvirt] [PATCH v2 17/20] conf: Move hugepage XML validation check out of qemu_command

2018-08-09 Thread Pavel Hrdina
We can safely validate the hugepage nodeset attribute at a define time.
This validation is not done for already existing domains when the daemon
is restarted.

All the changes to the tests are necessary because we move the error
from domain start into XML parse.

Signed-off-by: Pavel Hrdina 
---
 src/conf/domain_conf.c| 32 +
 src/qemu/qemu_command.c   | 34 ---
 .../seclabel-dynamic-none-relabel.xml |  2 +-
 tests/qemuxml2argvtest.c  | 18 +-
 .../hugepages-default-1G-nodeset-2M.xml   |  1 -
 .../qemuxml2xmloutdata/hugepages-nodeset.xml  |  1 -
 .../hugepages-numa-nodeset-nonexist.xml   |  1 -
 .../seclabel-dynamic-none-relabel.xml |  2 +-
 tests/qemuxml2xmltest.c   |  3 --
 9 files changed, 43 insertions(+), 51 deletions(-)
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-nodeset.xml
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-numa-nodeset-nonexist.xml

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8fd774b531..be9c08626a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6184,6 +6184,35 @@ virDomainDefLifecycleActionValidate(const virDomainDef 
*def)
 }
 
 
+static int
+virDomainDefMemtuneValidate(const virDomainDef *def)
+{
+const virDomainMemtune *mem = &(def->mem);
+size_t i;
+ssize_t pos = virDomainNumaGetNodeCount(def->numa) - 1;
+
+for (i = 0; i < mem->nhugepages; i++) {
+ssize_t nextBit;
+
+if (!mem->hugepages[i].nodemask) {
+/* This is the master hugepage to use. Skip it as it has no
+ * nodemask anyway. */
+continue;
+}
+
+nextBit = virBitmapNextSetBit(mem->hugepages[i].nodemask, pos);
+if (nextBit >= 0) {
+virReportError(VIR_ERR_XML_DETAIL,
+   _("hugepages: node %zd not found"),
+   nextBit);
+return -1;
+}
+}
+
+return 0;
+}
+
+
 static int
 virDomainDefValidateInternal(const virDomainDef *def)
 {
@@ -6219,6 +6248,9 @@ virDomainDefValidateInternal(const virDomainDef *def)
 if (virDomainDefLifecycleActionValidate(def) < 0)
 return -1;
 
+if (virDomainDefMemtuneValidate(def) < 0)
+return -1;
+
 return 0;
 }
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9e8f2f4c9c..dbeb3a54f6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7489,16 +7489,6 @@ qemuBuildMemPathStr(virQEMUDriverConfigPtr cfg,
 if (!def->mem.nhugepages)
 return 0;
 
-if (def->mem.hugepages[0].nodemask) {
-ssize_t next_bit = virBitmapNextSetBit(def->mem.hugepages[0].nodemask, 
-1);
-if (next_bit >= 0) {
-virReportError(VIR_ERR_XML_DETAIL,
-   _("hugepages: node %zd not found"),
-   next_bit);
-return -1;
-}
-}
-
 /* There is one special case: if user specified "huge"
  * pages of regular system pages size.
  * And there is nothing to do in this case.
@@ -7631,30 +7621,6 @@ qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg,
 if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset))
 goto cleanup;
 
-for (i = 0; i < def->mem.nhugepages; i++) {
-ssize_t next_bit, pos = 0;
-
-if (!def->mem.hugepages[i].nodemask) {
-/* This is the master hugepage to use. Skip it as it has no
- * nodemask anyway. */
-continue;
-}
-
-if (ncells) {
-/* Fortunately, we allow only guest NUMA nodes to be continuous
- * starting from zero. */
-pos = ncells - 1;
-}
-
-next_bit = virBitmapNextSetBit(def->mem.hugepages[i].nodemask, pos);
-if (next_bit >= 0) {
-virReportError(VIR_ERR_XML_DETAIL,
-   _("hugepages: node %zd not found"),
-   next_bit);
-goto cleanup;
-}
-}
-
 if (VIR_ALLOC_N(nodeBackends, ncells) < 0)
 goto cleanup;
 
diff --git a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml 
b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
index 47f253b5f7..e954250009 100644
--- a/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
+++ b/tests/qemuxml2argvdata/seclabel-dynamic-none-relabel.xml
@@ -5,7 +5,7 @@
   262144
   
 
-  
+  
 
   
   4
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 606f710f20..9e2e59ec44 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -974,12 +974,12 @@ mymain(void)
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
-DO_TEST("hugepages-default-1G-nodeset-2M", NONE);

[libvirt] [PATCH v2 06/20] tests: rename hugepages-pages into hugepages-numa-nodeset

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

 for numa guest is tested by numatune-memnode test.

Signed-off-by: Pavel Hrdina 
---
 ...s-pages.args => hugepages-numa-nodeset.args} | 17 +
 ...ges-pages.xml => hugepages-numa-nodeset.xml} | 12 +---
 tests/qemuxml2argvtest.c|  2 +-
 ...ges-pages.xml => hugepages-numa-nodeset.xml} | 17 +
 tests/qemuxml2xmltest.c |  2 +-
 5 files changed, 9 insertions(+), 41 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages.args => 
hugepages-numa-nodeset.args} (77%)
 rename tests/qemuxml2argvdata/{hugepages-pages.xml => 
hugepages-numa-nodeset.xml} (74%)
 rename tests/qemuxml2xmloutdata/{hugepages-pages.xml => 
hugepages-numa-nodeset.xml} (66%)

diff --git a/tests/qemuxml2argvdata/hugepages-pages.args 
b/tests/qemuxml2argvdata/hugepages-numa-nodeset.args
similarity index 77%
rename from tests/qemuxml2argvdata/hugepages-pages.args
rename to tests/qemuxml2argvdata/hugepages-numa-nodeset.args
index 7ece0272a0..22f0e605fe 100644
--- a/tests/qemuxml2argvdata/hugepages-pages.args
+++ b/tests/qemuxml2argvdata/hugepages-numa-nodeset.args
@@ -11,20 +11,16 @@ QEMU_AUDIO_DRV=none \
 -m 4096 \
 -smp 4,sockets=4,cores=1,threads=1 \
 -object memory-backend-file,id=ram-node0,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
-host-nodes=0-3,policy=bind \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824 \
 -numa node,nodeid=0,cpus=0,memdev=ram-node0 \
 -object memory-backend-file,id=ram-node1,prealloc=yes,\
-mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
-host-nodes=0-3,policy=bind \
+mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,size=1073741824 \
 -numa node,nodeid=1,cpus=1,memdev=ram-node1 \
 -object memory-backend-file,id=ram-node2,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
-host-nodes=0-3,policy=bind \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824 \
 -numa node,nodeid=2,cpus=2,memdev=ram-node2 \
 -object memory-backend-file,id=ram-node3,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
-host-nodes=3,policy=bind \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824 \
 -numa node,nodeid=3,cpus=3,memdev=ram-node3 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
 -display none \
@@ -37,7 +33,4 @@ server,nowait \
 -no-shutdown \
 -no-acpi \
 -boot c \
--usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-pages.xml 
b/tests/qemuxml2argvdata/hugepages-numa-nodeset.xml
similarity index 74%
rename from tests/qemuxml2argvdata/hugepages-pages.xml
rename to tests/qemuxml2argvdata/hugepages-numa-nodeset.xml
index f9270782d4..e81fa44d58 100644
--- a/tests/qemuxml2argvdata/hugepages-pages.xml
+++ b/tests/qemuxml2argvdata/hugepages-numa-nodeset.xml
@@ -10,10 +10,6 @@
 
   
   4
-  
-
-
-  
   
 hvm
 
@@ -32,16 +28,10 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-
 
-
 
 
 
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b72d4217ea..2d94c20f40 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -969,7 +969,7 @@ mymain(void)
 DO_TEST("hugepages-numa-default-dimm",
 QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
-DO_TEST("hugepages-pages",
+DO_TEST("hugepages-numa-nodeset",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-pages2", QEMU_CAPS_OBJECT_MEMORY_RAM,
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages.xml 
b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset.xml
similarity index 66%
rename from tests/qemuxml2xmloutdata/hugepages-pages.xml
rename to tests/qemuxml2xmloutdata/hugepages-numa-nodeset.xml
index 498610a217..affd124048 100644
--- a/tests/qemuxml2xmloutdata/hugepages-pages.xml
+++ b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset.xml
@@ -10,10 +10,6 @@
 
   
   4
-  
-
-
-  
   
 hvm
 
@@ -32,23 +28,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 2d85084d4a..1484c3176f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -332,7 +332,7 @@ mymain(void)
 DO_TEST("pages-discard", NONE);
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
-DO_TEST("hugepages-pages", NONE);
+DO_TEST("hugepages-numa-nodeset", NONE);
 DO_TEST("hugepages-pages2", NONE);

[libvirt] [PATCH v2 12/20] tests: rename hugepages-pages6 into hugepages-default-system-size

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 ...ges6.args => hugepages-default-system-size.args} |  5 +
 ...pages6.xml => hugepages-default-system-size.xml} | 13 +
 tests/qemuxml2argvtest.c|  2 +-
 .../hugepages-default-system-size.xml   |  1 +
 tests/qemuxml2xmloutdata/hugepages-pages6.xml   |  1 -
 tests/qemuxml2xmltest.c |  2 +-
 6 files changed, 5 insertions(+), 19 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages6.args => 
hugepages-default-system-size.args} (72%)
 rename tests/qemuxml2argvdata/{hugepages-pages6.xml => 
hugepages-default-system-size.xml} (63%)
 create mode 12 tests/qemuxml2xmloutdata/hugepages-default-system-size.xml
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-pages6.xml

diff --git a/tests/qemuxml2argvdata/hugepages-pages6.args 
b/tests/qemuxml2argvdata/hugepages-default-system-size.args
similarity index 72%
rename from tests/qemuxml2argvdata/hugepages-pages6.args
rename to tests/qemuxml2argvdata/hugepages-default-system-size.args
index 51467c0ae1..eeb7d142ce 100644
--- a/tests/qemuxml2argvdata/hugepages-pages6.args
+++ b/tests/qemuxml2argvdata/hugepages-default-system-size.args
@@ -21,7 +21,4 @@ 
path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
 -no-shutdown \
 -no-acpi \
 -boot c \
--usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-pages6.xml 
b/tests/qemuxml2argvdata/hugepages-default-system-size.xml
similarity index 63%
rename from tests/qemuxml2argvdata/hugepages-pages6.xml
rename to tests/qemuxml2argvdata/hugepages-default-system-size.xml
index fc4f57fbc0..8a809ead5e 100644
--- a/tests/qemuxml2argvdata/hugepages-pages6.xml
+++ b/tests/qemuxml2argvdata/hugepages-default-system-size.xml
@@ -19,23 +19,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 5ce77cb69e..ea7103f93c 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -969,6 +969,7 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
+DO_TEST("hugepages-default-system-size", NONE);
 DO_TEST("hugepages-numa-default",
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-numa-default-2M",
@@ -990,7 +991,6 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
-DO_TEST("hugepages-pages6", NONE);
 DO_TEST("hugepages-pages7",
 QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
diff --git a/tests/qemuxml2xmloutdata/hugepages-default-system-size.xml 
b/tests/qemuxml2xmloutdata/hugepages-default-system-size.xml
new file mode 12
index 00..e64e3fb282
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-default-system-size.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/hugepages-default-system-size.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages6.xml 
b/tests/qemuxml2xmloutdata/hugepages-pages6.xml
deleted file mode 12
index 584b7c92c8..00
--- a/tests/qemuxml2xmloutdata/hugepages-pages6.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-pages6.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0949c45092..8b8ab1d939 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -333,12 +333,12 @@ mymain(void)
 DO_TEST("pages-discard-hugepages", NONE);
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
+DO_TEST("hugepages-default-system-size", NONE);
 DO_TEST("hugepages-numa-default-2M", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
 DO_TEST("hugepages-numa-nodeset-part", NONE);
 DO_TEST("hugepages-numa-nodeset-nonexist", NONE);
-DO_TEST("hugepages-pages6", NONE);
 DO_TEST("hugepages-pages7", NONE);
 DO_TEST("hugepages-shared", NONE);
 DO_TEST("hugepages-memaccess", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 15/20] tests: introduce hugepages-default-1G-nodeset-2M

2018-08-09 Thread Pavel Hrdina
This test case is currently working but it uncovers existing issue
in our code that the generated QEMU commandline uses the default 1G
hugepage instead of the 2M hugepage specified for exact node.

The issue in our code is that for non-numa guests we take into account
only the first hugepage.  This will be fixed as invalid configuration
since it doesn't make any sense to set default and specific hugepage
for non-numa guest.

Signed-off-by: Pavel Hrdina 
---
 .../hugepages-default-1G-nodeset-2M.args  | 26 
 .../hugepages-default-1G-nodeset-2M.xml   | 31 +++
 tests/qemuxml2argvtest.c  |  1 +
 .../hugepages-default-1G-nodeset-2M.xml   |  1 +
 tests/qemuxml2xmltest.c   |  1 +
 5 files changed, 60 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.args
 create mode 100644 tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
 create mode 12 tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml

diff --git a/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.args 
b/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.args
new file mode 100644
index 00..d1f8974032
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.args
@@ -0,0 +1,26 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name SomeDummyHugepagesGuest \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 1024 \
+-mem-prealloc \
+-mem-path /dev/hugepages1G/libvirt/qemu/-1-SomeDummyHugepagesGu \
+-smp 2,sockets=2,cores=1,threads=1 \
+-uuid ef1bdff4-27f3-4e85-a807-5fb4d58463cc \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,\
+path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml 
b/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
new file mode 100644
index 00..eb0943b105
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
@@ -0,0 +1,31 @@
+
+  SomeDummyHugepagesGuest
+  ef1bdff4-27f3-4e85-a807-5fb4d58463cc
+  1048576
+  1048576
+  
+
+  
+  
+
+  
+  2
+  
+hvm
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-i686
+
+  
+
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 54bcfdf3f7..273be61db3 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -974,6 +974,7 @@ mymain(void)
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
+DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
 DO_TEST_FAILURE("hugepages-nodeset-nonexist",
 QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_OBJECT_MEMORY_FILE,
diff --git a/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml 
b/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
new file mode 12
index 00..3d8eb7616e
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-default-1G-nodeset-2M.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 0b965d3401..958b955810 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -335,6 +335,7 @@ mymain(void)
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
+DO_TEST("hugepages-default-1G-nodeset-2M", NONE);
 DO_TEST("hugepages-numa-default-2M", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 05/20] tests: extract pages-discard out of hugepages-pages

2018-08-09 Thread Pavel Hrdina
>From the args output you can see that the 'discard' feature is not
honored if you don't use hugepages, that is a bug, following patche
will fix it.

Signed-off-by: Pavel Hrdina 
---
 tests/qemuxml2argvdata/hugepages-pages.args  | 12 +++
 tests/qemuxml2argvdata/hugepages-pages.xml   |  3 +-
 tests/qemuxml2argvdata/pages-discard.args| 28 +++
 tests/qemuxml2argvdata/pages-discard.xml | 36 
 tests/qemuxml2argvtest.c |  6 ++--
 tests/qemuxml2xmloutdata/hugepages-pages.xml |  3 +-
 tests/qemuxml2xmloutdata/pages-discard.xml   |  1 +
 tests/qemuxml2xmltest.c  |  1 +
 8 files changed, 78 insertions(+), 12 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/pages-discard.args
 create mode 100644 tests/qemuxml2argvdata/pages-discard.xml
 create mode 12 tests/qemuxml2xmloutdata/pages-discard.xml

diff --git a/tests/qemuxml2argvdata/hugepages-pages.args 
b/tests/qemuxml2argvdata/hugepages-pages.args
index b52cd581d5..7ece0272a0 100644
--- a/tests/qemuxml2argvdata/hugepages-pages.args
+++ b/tests/qemuxml2argvdata/hugepages-pages.args
@@ -11,20 +11,20 @@ QEMU_AUDIO_DRV=none \
 -m 4096 \
 -smp 4,sockets=4,cores=1,threads=1 \
 -object memory-backend-file,id=ram-node0,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,discard-data=yes,\
-size=1073741824,host-nodes=0-3,policy=bind \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
+host-nodes=0-3,policy=bind \
 -numa node,nodeid=0,cpus=0,memdev=ram-node0 \
 -object memory-backend-file,id=ram-node1,prealloc=yes,\
 mem-path=/dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
 host-nodes=0-3,policy=bind \
 -numa node,nodeid=1,cpus=1,memdev=ram-node1 \
 -object memory-backend-file,id=ram-node2,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,discard-data=yes,\
-size=1073741824,host-nodes=0-3,policy=bind \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
+host-nodes=0-3,policy=bind \
 -numa node,nodeid=2,cpus=2,memdev=ram-node2 \
 -object memory-backend-file,id=ram-node3,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,discard-data=yes,\
-size=1073741824,host-nodes=3,policy=bind \
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-QEMUGuest1,size=1073741824,\
+host-nodes=3,policy=bind \
 -numa node,nodeid=3,cpus=3,memdev=ram-node3 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
 -display none \
diff --git a/tests/qemuxml2argvdata/hugepages-pages.xml 
b/tests/qemuxml2argvdata/hugepages-pages.xml
index cba83e754c..f9270782d4 100644
--- a/tests/qemuxml2argvdata/hugepages-pages.xml
+++ b/tests/qemuxml2argvdata/hugepages-pages.xml
@@ -8,7 +8,6 @@
   
   
 
-
   
   4
   
@@ -22,7 +21,7 @@
   
 
   
-  
+  
   
   
 
diff --git a/tests/qemuxml2argvdata/pages-discard.args 
b/tests/qemuxml2argvdata/pages-discard.args
new file mode 100644
index 00..9db8c72a22
--- /dev/null
+++ b/tests/qemuxml2argvdata/pages-discard.args
@@ -0,0 +1,28 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
+-m 4096 \
+-smp 4,sockets=4,cores=1,threads=1 \
+-numa node,nodeid=0,cpus=0,mem=1024 \
+-numa node,nodeid=1,cpus=1,mem=1024 \
+-numa node,nodeid=2,cpus=2,mem=1024 \
+-numa node,nodeid=3,cpus=3,mem=1024 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev 
socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb
diff --git a/tests/qemuxml2argvdata/pages-discard.xml 
b/tests/qemuxml2argvdata/pages-discard.xml
new file mode 100644
index 00..a8c6b74d95
--- /dev/null
+++ b/tests/qemuxml2argvdata/pages-discard.xml
@@ -0,0 +1,36 @@
+
+  QEMUGuest1
+  c7a5fdbd-edaf-9455-926a-d65c16db1809
+  4194304
+  4194304
+  
+
+  
+  4
+  
+hvm
+
+  
+  
+
+  
+  
+  
+  
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-i686
+
+  
+
+
+
+
+
+  
+
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index f36058272f..b72d4217ea 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -960,6 +960,9 @@ mymain(void)
 DO_TEST("pmu-feature", NONE);
 DO_TEST("pmu-feature-off", NONE);
 
+DO_TEST("pages-discard",
+QEMU_CAPS_OBJECT_MEMORY_FILE,
+QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-numa-default",
 QEMU_CAPS_OBJECT_MEMORY_FILE);
@@ -968,8 +971,7 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-pages",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
-

[libvirt] [PATCH v2 13/20] tests: rename hugepages-pages7 into pages-dimm-discard

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 ...ges-pages7.args => pages-dimm-discard.args} | 16 +---
 ...pages-pages7.xml => pages-dimm-discard.xml} | 18 +-
 tests/qemuxml2argvtest.c   |  7 ---
 tests/qemuxml2xmloutdata/hugepages-pages7.xml  |  1 -
 .../qemuxml2xmloutdata/pages-dimm-discard.xml  |  1 +
 tests/qemuxml2xmltest.c|  2 +-
 6 files changed, 12 insertions(+), 33 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages7.args => 
pages-dimm-discard.args} (65%)
 rename tests/qemuxml2argvdata/{hugepages-pages7.xml => pages-dimm-discard.xml} 
(73%)
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-pages7.xml
 create mode 12 tests/qemuxml2xmloutdata/pages-dimm-discard.xml

diff --git a/tests/qemuxml2argvdata/hugepages-pages7.args 
b/tests/qemuxml2argvdata/pages-dimm-discard.args
similarity index 65%
rename from tests/qemuxml2argvdata/hugepages-pages7.args
rename to tests/qemuxml2argvdata/pages-dimm-discard.args
index 02a98026eb..97184e074a 100644
--- a/tests/qemuxml2argvdata/hugepages-pages7.args
+++ b/tests/qemuxml2argvdata/pages-dimm-discard.args
@@ -10,16 +10,14 @@ QEMU_AUDIO_DRV=none \
 -machine pc-i440fx-2.3,accel=tcg,usb=off,dump-guest-core=off \
 -m size=1048576k,slots=16,maxmem=1099511627776k \
 -smp 2,sockets=2,cores=1,threads=1 \
--mem-prealloc \
--mem-path /dev/hugepages2M/libvirt/qemu/-1-fedora \
 -numa node,nodeid=0,cpus=0-1,mem=1024 \
 -object memory-backend-file,id=memdimm0,prealloc=yes,\
 mem-path=/dev/hugepages1G/libvirt/qemu/-1-fedora,size=1073741824,\
 host-nodes=1-3,policy=bind \
 -device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0 \
--object memory-backend-file,id=memdimm1,prealloc=yes,\
-mem-path=/dev/hugepages2M/libvirt/qemu/-1-fedora,discard-data=yes,share=no,\
-size=536870912 \
+-object memory-backend-file,id=memdimm1,\
+mem-path=/var/lib/libvirt/qemu/ram/libvirt/qemu/-1-fedora/dimm1,\
+discard-data=yes,share=no,size=536870912 \
 -device pc-dimm,node=0,memdev=memdimm1,id=dimm1,slot=1 \
 -uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \
 -display none \
@@ -30,10 +28,6 @@ server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=control \
 -rtc base=utc \
 -no-shutdown \
+-no-acpi \
 -boot c \
--usb \
--drive file=/var/lib/libvirt/images/fedora.qcow2,format=qcow2,if=none,\
-id=drive-virtio-disk0 \
--device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,\
-id=virtio-disk0 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-pages7.xml 
b/tests/qemuxml2argvdata/pages-dimm-discard.xml
similarity index 73%
rename from tests/qemuxml2argvdata/hugepages-pages7.xml
rename to tests/qemuxml2argvdata/pages-dimm-discard.xml
index 28c72f85a7..3d233687e1 100644
--- a/tests/qemuxml2argvdata/hugepages-pages7.xml
+++ b/tests/qemuxml2argvdata/pages-dimm-discard.xml
@@ -4,19 +4,11 @@
   1099511627776
   2621439
   2621439
-  
-
-  
   2
   
 hvm
 
   
-  
-
-
-
-  
   
 
   
@@ -28,21 +20,13 @@
   restart
   
 /usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
 
   
 
 
 
 
-
-  
-
+
 
   
 1-3
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ea7103f93c..2c1473f3f8 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -967,6 +967,10 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
+DO_TEST("pages-dimm-discard",
+QEMU_CAPS_DEVICE_PC_DIMM,
+QEMU_CAPS_OBJECT_MEMORY_FILE,
+QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
@@ -991,9 +995,6 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
-DO_TEST("hugepages-pages7",
-QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
-QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST_FAILURE("hugepages-pages8",
 QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages7.xml 
b/tests/qemuxml2xmloutdata/hugepages-pages7.xml
deleted file mode 12
index b4ce4defda..00
--- a/tests/qemuxml2xmloutdata/hugepages-pages7.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-pages7.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/pages-dimm-discard.xml 
b/tests/qemuxml2xmloutdata/pages-dimm-discard.xml
new file mode 12
index 00..05bbef8d65
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/pages-dimm-discard.xml
@@ -0,0 +1 @@

[libvirt] [PATCH v2 14/20] tests: rename hugepages-pages8 into hugepages-nodeset-nonexist

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 ...es-pages8.xml => hugepages-nodeset-nonexist.xml} | 13 +
 tests/qemuxml2argvtest.c|  7 ---
 2 files changed, 5 insertions(+), 15 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages8.xml => 
hugepages-nodeset-nonexist.xml} (64%)

diff --git a/tests/qemuxml2argvdata/hugepages-pages8.xml 
b/tests/qemuxml2argvdata/hugepages-nodeset-nonexist.xml
similarity index 64%
rename from tests/qemuxml2argvdata/hugepages-pages8.xml
rename to tests/qemuxml2argvdata/hugepages-nodeset-nonexist.xml
index 4cf4c1a8ad..477d3f1f2b 100644
--- a/tests/qemuxml2argvdata/hugepages-pages8.xml
+++ b/tests/qemuxml2argvdata/hugepages-nodeset-nonexist.xml
@@ -19,23 +19,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 2c1473f3f8..54bcfdf3f7 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -974,6 +974,10 @@ mymain(void)
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-default-system-size", NONE);
+DO_TEST_FAILURE("hugepages-nodeset-nonexist",
+QEMU_CAPS_DEVICE_PC_DIMM,
+QEMU_CAPS_OBJECT_MEMORY_FILE,
+QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-numa-default",
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-numa-default-2M",
@@ -995,9 +999,6 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
-DO_TEST_FAILURE("hugepages-pages8",
-QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
-QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-memaccess", QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_RAM, QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_NUMA);
-- 
2.17.1

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


[libvirt] [PATCH v2 04/20] tests: remove unnecessary XML elements from hugepages-numa-default

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 .../hugepages-numa-default.args   | 42 ++-
 .../hugepages-numa-default.xml| 74 +--
 tests/qemuxml2argvtest.c  |  6 --
 3 files changed, 7 insertions(+), 115 deletions(-)

diff --git a/tests/qemuxml2argvdata/hugepages-numa-default.args 
b/tests/qemuxml2argvdata/hugepages-numa-default.args
index 20c7802fd8..cc2223aee1 100644
--- a/tests/qemuxml2argvdata/hugepages-numa-default.args
+++ b/tests/qemuxml2argvdata/hugepages-numa-default.args
@@ -3,7 +3,7 @@ PATH=/bin \
 HOME=/home/test \
 USER=test \
 LOGNAME=test \
-QEMU_AUDIO_DRV=spice \
+QEMU_AUDIO_DRV=none \
 /usr/bin/qemu-system-x86_64 \
 -name fedora \
 -S \
@@ -14,46 +14,14 @@ QEMU_AUDIO_DRV=spice \
 -mem-path /dev/hugepages2M/libvirt/qemu/-1-fedora \
 -numa node,nodeid=0,cpus=0-1,mem=1024 \
 -uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \
+-display none \
 -no-user-config \
 -nodefaults \
 -chardev socket,id=charmonitor,path=/tmp/lib/domain--1-fedora/monitor.sock,\
 server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=control \
--rtc base=utc,driftfix=slew \
--no-hpet \
+-rtc base=utc \
 -no-shutdown \
--global PIIX4_PM.disable_s3=1 \
--global PIIX4_PM.disable_s4=1 \
+-no-acpi \
 -boot c \
--device ich9-usb-ehci1,id=usb,bus=pci.0,addr=0x6.0x7 \
--device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,\
-addr=0x6 \
--device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x6.0x1 \
--device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x6.0x2 \
--device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5 \
--drive file=/var/lib/libvirt/images/fedora.qcow2,format=qcow2,if=none,\
-id=drive-virtio-disk0 \
--device virtio-blk-pci,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,\
-id=virtio-disk0 \
--drive if=none,id=drive-ide0-0-0,media=cdrom,readonly=on \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--chardev socket,id=charchannel0,\
-path=/var/lib/libvirt/qemu/channel/target/fedora.org.qemu.guest_agent.0,server,\
-nowait \
--device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\
-id=channel0,name=org.qemu.guest_agent.0 \
--chardev spicevmc,id=charchannel1,name=vdagent \
--device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\
-id=channel1,name=com.redhat.spice.0 \
--device usb-tablet,id=input0,bus=usb.0,port=1 \
--spice port=5901,tls-port=5902,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \
--vga qxl \
--global qxl-vga.ram_size=67108864 \
--global qxl-vga.vram_size=67108864 \
--device intel-hda,id=sound0,bus=pci.0,addr=0x4 \
--device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \
--chardev spicevmc,id=charredir0,name=usbredir \
--device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 \
--chardev spicevmc,id=charredir1,name=usbredir \
--device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-numa-default.xml 
b/tests/qemuxml2argvdata/hugepages-numa-default.xml
index d3c6308be0..6bbd80d515 100644
--- a/tests/qemuxml2argvdata/hugepages-numa-default.xml
+++ b/tests/qemuxml2argvdata/hugepages-numa-default.xml
@@ -11,90 +11,20 @@
 hvm
 
   
-  
-
-
-
-  
   
 
   
 
   
-  
-
-
-
-  
   destroy
   restart
   restart
-  
-
-
-  
   
 /usr/bin/qemu-system-x86_64
-
-  
-  
-  
-  
-
-
-  
-  
-  
-  
-
-
-  
-
-
-  
-  
-
-
-  
-  
-
-
-  
-  
-
+
 
-
-  
-
-
-  
-
-
-  
-  
-  
-
-
-  
-  
-
-
 
 
-
-
-  
-
-
-  
-  
-
-
-
-
-
-
-  
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0c311e0906..f36058272f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -962,12 +962,6 @@ mymain(void)
 
 DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-numa-default",
-QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
-QEMU_CAPS_VIRTIO_SCSI,
-QEMU_CAPS_ICH9_USB_EHCI1,
-QEMU_CAPS_SPICE,
-QEMU_CAPS_DEVICE_QXL,
-QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-numa-default-dimm",
 QEMU_CAPS_DEVICE_PC_DIMM,
-- 
2.17.1

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


[libvirt] [PATCH v2 09/20] tests: rename hugepages-pages3 into hugepages-numa-nodeset-part

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 ...pages3.args => hugepages-numa-nodeset-part.args} |  5 +
 ...s-pages3.xml => hugepages-numa-nodeset-part.xml} |  8 +---
 tests/qemuxml2argvtest.c|  3 ++-
 ...s-pages3.xml => hugepages-numa-nodeset-part.xml} | 13 +
 tests/qemuxml2xmltest.c |  2 +-
 5 files changed, 6 insertions(+), 25 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages3.args => 
hugepages-numa-nodeset-part.args} (80%)
 rename tests/qemuxml2argvdata/{hugepages-pages3.xml => 
hugepages-numa-nodeset-part.xml} (77%)
 rename tests/qemuxml2xmloutdata/{hugepages-pages3.xml => 
hugepages-numa-nodeset-part.xml} (67%)

diff --git a/tests/qemuxml2argvdata/hugepages-pages3.args 
b/tests/qemuxml2argvdata/hugepages-numa-nodeset-part.args
similarity index 80%
rename from tests/qemuxml2argvdata/hugepages-pages3.args
rename to tests/qemuxml2argvdata/hugepages-numa-nodeset-part.args
index 2fc701ca22..071176 100644
--- a/tests/qemuxml2argvdata/hugepages-pages3.args
+++ b/tests/qemuxml2argvdata/hugepages-numa-nodeset-part.args
@@ -26,7 +26,4 @@ 
path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
 -no-shutdown \
 -no-acpi \
 -boot c \
--usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-pages3.xml 
b/tests/qemuxml2argvdata/hugepages-numa-nodeset-part.xml
similarity index 77%
rename from tests/qemuxml2argvdata/hugepages-pages3.xml
rename to tests/qemuxml2argvdata/hugepages-numa-nodeset-part.xml
index 3d3b3f3cc3..b19bdedb36 100644
--- a/tests/qemuxml2argvdata/hugepages-pages3.xml
+++ b/tests/qemuxml2argvdata/hugepages-numa-nodeset-part.xml
@@ -25,16 +25,10 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-
 
-
 
 
 
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4f1c583327..b2ee1fe6bb 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -979,7 +979,8 @@ mymain(void)
 DO_TEST("hugepages-numa-nodeset",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
-DO_TEST("hugepages-pages3", QEMU_CAPS_OBJECT_MEMORY_RAM,
+DO_TEST("hugepages-numa-nodeset-part",
+QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-shared",
 QEMU_CAPS_OBJECT_MEMORY_RAM,
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages3.xml 
b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-part.xml
similarity index 67%
rename from tests/qemuxml2xmloutdata/hugepages-pages3.xml
rename to tests/qemuxml2xmloutdata/hugepages-numa-nodeset-part.xml
index be21c3eddd..1230edfd02 100644
--- a/tests/qemuxml2xmloutdata/hugepages-pages3.xml
+++ b/tests/qemuxml2xmloutdata/hugepages-numa-nodeset-part.xml
@@ -25,23 +25,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 186cd6c2e5..29dc03e805 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -335,7 +335,7 @@ mymain(void)
 DO_TEST("hugepages-numa-default-2M", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
-DO_TEST("hugepages-pages3", NONE);
+DO_TEST("hugepages-numa-nodeset-part", NONE);
 DO_TEST("hugepages-pages4", NONE);
 DO_TEST("hugepages-pages5", NONE);
 DO_TEST("hugepages-pages6", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 03/20] tests: rename hugepages-numa into hugepages-numa-default

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 .../{hugepages-numa.args => hugepages-numa-default.args}| 0
 .../{hugepages-numa.xml => hugepages-numa-default.xml}  | 0
 tests/qemuxml2argvtest.c| 2 +-
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename tests/qemuxml2argvdata/{hugepages-numa.args => 
hugepages-numa-default.args} (100%)
 rename tests/qemuxml2argvdata/{hugepages-numa.xml => 
hugepages-numa-default.xml} (100%)

diff --git a/tests/qemuxml2argvdata/hugepages-numa.args 
b/tests/qemuxml2argvdata/hugepages-numa-default.args
similarity index 100%
rename from tests/qemuxml2argvdata/hugepages-numa.args
rename to tests/qemuxml2argvdata/hugepages-numa-default.args
diff --git a/tests/qemuxml2argvdata/hugepages-numa.xml 
b/tests/qemuxml2argvdata/hugepages-numa-default.xml
similarity index 100%
rename from tests/qemuxml2argvdata/hugepages-numa.xml
rename to tests/qemuxml2argvdata/hugepages-numa-default.xml
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 1631663bc6..0c311e0906 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -961,7 +961,7 @@ mymain(void)
 DO_TEST("pmu-feature-off", NONE);
 
 DO_TEST("hugepages-default", NONE);
-DO_TEST("hugepages-numa",
+DO_TEST("hugepages-numa-default",
 QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
 QEMU_CAPS_VIRTIO_SCSI,
 QEMU_CAPS_ICH9_USB_EHCI1,
-- 
2.17.1

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


[libvirt] [PATCH v2 02/20] tests: extract hugepages-numa-default-dimm out of hugepages-numa

2018-08-09 Thread Pavel Hrdina
Signed-off-by: Pavel Hrdina 
---
 .../hugepages-numa-default-dimm.args  | 31 +
 .../hugepages-numa-default-dimm.xml   | 45 +++
 tests/qemuxml2argvdata/hugepages-numa.args|  6 +--
 tests/qemuxml2argvdata/hugepages-numa.xml | 11 -
 tests/qemuxml2argvtest.c  |  2 +
 .../hugepages-numa-default-dimm.xml   |  1 +
 tests/qemuxml2xmltest.c   |  1 +
 7 files changed, 81 insertions(+), 16 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/hugepages-numa-default-dimm.args
 create mode 100644 tests/qemuxml2argvdata/hugepages-numa-default-dimm.xml
 create mode 12 tests/qemuxml2xmloutdata/hugepages-numa-default-dimm.xml

diff --git a/tests/qemuxml2argvdata/hugepages-numa-default-dimm.args 
b/tests/qemuxml2argvdata/hugepages-numa-default-dimm.args
new file mode 100644
index 00..855966a137
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-numa-default-dimm.args
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name fedora \
+-S \
+-machine pc-i440fx-2.3,accel=tcg,usb=off,dump-guest-core=off \
+-m size=1048576k,slots=16,maxmem=1099511627776k \
+-smp 2,sockets=2,cores=1,threads=1 \
+-mem-prealloc \
+-mem-path /dev/hugepages2M/libvirt/qemu/-1-fedora \
+-numa node,nodeid=0,cpus=0-1,mem=1024 \
+-object memory-backend-file,id=memdimm0,prealloc=yes,\
+mem-path=/dev/hugepages1G/libvirt/qemu/-1-fedora,size=1073741824,\
+host-nodes=1-3,policy=bind \
+-device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0 \
+-uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-fedora/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot c \
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-numa-default-dimm.xml 
b/tests/qemuxml2argvdata/hugepages-numa-default-dimm.xml
new file mode 100644
index 00..14a3368678
--- /dev/null
+++ b/tests/qemuxml2argvdata/hugepages-numa-default-dimm.xml
@@ -0,0 +1,45 @@
+
+  fedora
+  63840878-0deb-4095-97e6-fc444d9bc9fa
+  1099511627776
+  1572863
+  1048576
+  
+
+  
+  2
+  
+hvm
+
+  
+  
+
+  
+
+  
+  
+  destroy
+  restart
+  destroy
+  
+/usr/bin/qemu-system-x86_64
+
+  
+
+
+
+
+
+
+  
+1-3
+1048576
+  
+  
+1048576
+0
+  
+  
+
+  
+
diff --git a/tests/qemuxml2argvdata/hugepages-numa.args 
b/tests/qemuxml2argvdata/hugepages-numa.args
index aa834f5511..20c7802fd8 100644
--- a/tests/qemuxml2argvdata/hugepages-numa.args
+++ b/tests/qemuxml2argvdata/hugepages-numa.args
@@ -8,15 +8,11 @@ QEMU_AUDIO_DRV=spice \
 -name fedora \
 -S \
 -machine pc-i440fx-2.3,accel=tcg,usb=off,dump-guest-core=off \
--m size=1048576k,slots=16,maxmem=1099511627776k \
+-m 1024 \
 -smp 2,sockets=2,cores=1,threads=1 \
 -mem-prealloc \
 -mem-path /dev/hugepages2M/libvirt/qemu/-1-fedora \
 -numa node,nodeid=0,cpus=0-1,mem=1024 \
--object memory-backend-file,id=memdimm0,prealloc=yes,\
-mem-path=/dev/hugepages1G/libvirt/qemu/-1-fedora,size=1073741824,\
-host-nodes=1-3,policy=bind \
--device pc-dimm,node=0,memdev=memdimm0,id=dimm0,slot=0 \
 -uuid 63840878-0deb-4095-97e6-fc444d9bc9fa \
 -no-user-config \
 -nodefaults \
diff --git a/tests/qemuxml2argvdata/hugepages-numa.xml 
b/tests/qemuxml2argvdata/hugepages-numa.xml
index eef471b4ec..d3c6308be0 100644
--- a/tests/qemuxml2argvdata/hugepages-numa.xml
+++ b/tests/qemuxml2argvdata/hugepages-numa.xml
@@ -1,7 +1,6 @@
 
   fedora
   63840878-0deb-4095-97e6-fc444d9bc9fa
-  1099511627776
   1572863
   1048576
   
@@ -97,15 +96,5 @@
 
   
 
-
-  
-1-3
-1048576
-  
-  
-1048576
-0
-  
-
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index cfebf364fb..1631663bc6 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -968,6 +968,8 @@ mymain(void)
 QEMU_CAPS_SPICE,
 QEMU_CAPS_DEVICE_QXL,
 QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR,
+QEMU_CAPS_OBJECT_MEMORY_FILE);
+DO_TEST("hugepages-numa-default-dimm",
 QEMU_CAPS_DEVICE_PC_DIMM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-pages",
diff --git a/tests/qemuxml2xmloutdata/hugepages-numa-default-dimm.xml 
b/tests/qemuxml2xmloutdata/hugepages-numa-default-dimm.xml
new file mode 12
index 00..8fa2b323aa
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-numa-default-dimm.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/hugepages-numa-default-dimm.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index ff6e611421..a943975ada 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -330,6 +330,7 

[libvirt] [PATCH v2 11/20] tests: rename hugepages-pages5 into hugepages-default-2M

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 ...epages-pages5.args => hugepages-default-2M.args} |  5 +
 ...ugepages-pages5.xml => hugepages-default-2M.xml} | 13 +
 tests/qemuxml2argvtest.c|  2 +-
 tests/qemuxml2xmloutdata/hugepages-default-2M.xml   |  1 +
 tests/qemuxml2xmloutdata/hugepages-pages5.xml   |  1 -
 tests/qemuxml2xmltest.c |  2 +-
 6 files changed, 5 insertions(+), 19 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages5.args => 
hugepages-default-2M.args} (75%)
 rename tests/qemuxml2argvdata/{hugepages-pages5.xml => 
hugepages-default-2M.xml} (63%)
 create mode 12 tests/qemuxml2xmloutdata/hugepages-default-2M.xml
 delete mode 12 tests/qemuxml2xmloutdata/hugepages-pages5.xml

diff --git a/tests/qemuxml2argvdata/hugepages-pages5.args 
b/tests/qemuxml2argvdata/hugepages-default-2M.args
similarity index 75%
rename from tests/qemuxml2argvdata/hugepages-pages5.args
rename to tests/qemuxml2argvdata/hugepages-default-2M.args
index dc13abed10..d094be1252 100644
--- a/tests/qemuxml2argvdata/hugepages-pages5.args
+++ b/tests/qemuxml2argvdata/hugepages-default-2M.args
@@ -23,7 +23,4 @@ 
path=/tmp/lib/domain--1-SomeDummyHugepagesGu/monitor.sock,server,nowait \
 -no-shutdown \
 -no-acpi \
 -boot c \
--usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
--device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+-usb
diff --git a/tests/qemuxml2argvdata/hugepages-pages5.xml 
b/tests/qemuxml2argvdata/hugepages-default-2M.xml
similarity index 63%
rename from tests/qemuxml2argvdata/hugepages-pages5.xml
rename to tests/qemuxml2argvdata/hugepages-default-2M.xml
index f636c186de..ac219a7800 100644
--- a/tests/qemuxml2argvdata/hugepages-pages5.xml
+++ b/tests/qemuxml2argvdata/hugepages-default-2M.xml
@@ -19,23 +19,12 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
-
-  
-
 
 
 
-
-  
-
+
   
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d4a6738b98..5ce77cb69e 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -968,6 +968,7 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_FILE,
 QEMU_CAPS_OBJECT_MEMORY_FILE_DISCARD);
 DO_TEST("hugepages-default", NONE);
+DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-numa-default",
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST("hugepages-numa-default-2M",
@@ -989,7 +990,6 @@ mymain(void)
 QEMU_CAPS_OBJECT_MEMORY_RAM,
 QEMU_CAPS_OBJECT_MEMORY_FILE);
 DO_TEST_PARSE_ERROR("hugepages-memaccess-invalid", NONE);
-DO_TEST("hugepages-pages5", NONE);
 DO_TEST("hugepages-pages6", NONE);
 DO_TEST("hugepages-pages7",
 QEMU_CAPS_DEVICE_PC_DIMM, QEMU_CAPS_OBJECT_MEMORY_FILE,
diff --git a/tests/qemuxml2xmloutdata/hugepages-default-2M.xml 
b/tests/qemuxml2xmloutdata/hugepages-default-2M.xml
new file mode 12
index 00..8786948fdd
--- /dev/null
+++ b/tests/qemuxml2xmloutdata/hugepages-default-2M.xml
@@ -0,0 +1 @@
+../qemuxml2argvdata/hugepages-default-2M.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmloutdata/hugepages-pages5.xml 
b/tests/qemuxml2xmloutdata/hugepages-pages5.xml
deleted file mode 12
index cfead1c317..00
--- a/tests/qemuxml2xmloutdata/hugepages-pages5.xml
+++ /dev/null
@@ -1 +0,0 @@
-../qemuxml2argvdata/hugepages-pages5.xml
\ No newline at end of file
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 92dfa87e24..0949c45092 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -332,12 +332,12 @@ mymain(void)
 DO_TEST("pages-discard", NONE);
 DO_TEST("pages-discard-hugepages", NONE);
 DO_TEST("hugepages-default", NONE);
+DO_TEST("hugepages-default-2M", NONE);
 DO_TEST("hugepages-numa-default-2M", NONE);
 DO_TEST("hugepages-numa-default-dimm", NONE);
 DO_TEST("hugepages-numa-nodeset", NONE);
 DO_TEST("hugepages-numa-nodeset-part", NONE);
 DO_TEST("hugepages-numa-nodeset-nonexist", NONE);
-DO_TEST("hugepages-pages5", NONE);
 DO_TEST("hugepages-pages6", NONE);
 DO_TEST("hugepages-pages7", NONE);
 DO_TEST("hugepages-shared", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v2 00/20] Fix and improve hugepage code

2018-08-09 Thread Pavel Hrdina
changes in v2:
- renamed existing test cases to sensible names
- split of some existing test cases
- fixed uncovered issue with memory discard

v1: https://www.redhat.com/archives/libvir-list/2018-July/msg00667.html

Pavel Hrdina (20):
  tests: rename hugepages to hugepages-default
  tests: extract hugepages-numa-default-dimm out of hugepages-numa
  tests: rename hugepages-numa into hugepages-numa-default
  tests: remove unnecessary XML elements from hugepages-numa-default
  tests: extract pages-discard out of hugepages-pages
  tests: rename hugepages-pages into hugepages-numa-nodeset
  tests: rename hugepages-pages2 into hugepages-numa-default-2M
  tests: extract pages-discard-hugepages out of hugepages-pages3
  tests: rename hugepages-pages3 into hugepages-numa-nodeset-part
  tests: rename hugepages-pages4 into hugepages-numa-nodeset-nonexist
  tests: rename hugepages-pages5 into hugepages-default-2M
  tests: rename hugepages-pages6 into hugepages-default-system-size
  tests: rename hugepages-pages7 into pages-dimm-discard
  tests: rename hugepages-pages8 into hugepages-nodeset-nonexist
  tests: introduce hugepages-default-1G-nodeset-2M
  tests: introduce hugepages-nodeset
  conf: Move hugepage XML validation check out of qemu_command
  conf: Move hugepages validation out of XML parser
  conf: Introduce virDomainDefPostParseMemtune
  qemu: ensure that memory 'discard' is used if specified in XML

 src/conf/domain_conf.c| 134 +-
 src/qemu/qemu_command.c   |  38 +
 ...s => hugepages-default-1G-nodeset-2M.args} |   7 +-
 .../hugepages-default-1G-nodeset-2M.xml   |  31 
 ...-pages5.args => hugepages-default-2M.args} |   5 +-
 ...es-pages5.xml => hugepages-default-2M.xml} |  13 +-
 .../hugepages-default-system-size.args|  24 
 xml => hugepages-default-system-size.xml} |  13 +-
 ...{hugepages.args => hugepages-default.args} |   2 -
 .../{hugepages.xml => hugepages-default.xml}  |   5 -
 ...es8.xml => hugepages-nodeset-nonexist.xml} |  13 +-
 tests/qemuxml2argvdata/hugepages-nodeset.args |  26 
 tests/qemuxml2argvdata/hugepages-nodeset.xml  |  30 
 ...s2.args => hugepages-numa-default-2M.args} |   5 +-
 ...ges2.xml => hugepages-numa-default-2M.xml} |   8 +-
 args => hugepages-numa-default-dimm.args} |  12 +-
 .../hugepages-numa-default-dimm.xml   |  45 ++
 .../hugepages-numa-default.args   |  27 
 .../hugepages-numa-default.xml|  30 
 ...ml => hugepages-numa-nodeset-nonexist.xml} |  17 +--
 args => hugepages-numa-nodeset-part.args} |   8 +-
 .../hugepages-numa-nodeset-part.xml   |  34 +
 ...pages.args => hugepages-numa-nodeset.args} |  17 +--
 ...s-pages.xml => hugepages-numa-nodeset.xml} |  15 +-
 tests/qemuxml2argvdata/hugepages-numa.args|  63 
 tests/qemuxml2argvdata/hugepages-numa.xml | 111 ---
 .../qemuxml2argvdata/pages-dimm-discard.args  |  33 +
 ...ages-pages7.xml => pages-dimm-discard.xml} |  18 +--
 .../pages-discard-hugepages.args  |  31 
 ...pages3.xml => pages-discard-hugepages.xml} |  16 +--
 tests/qemuxml2argvdata/pages-discard.args |  38 +
 tests/qemuxml2argvdata/pages-discard.xml  |  36 +
 .../seclabel-dynamic-none-relabel.xml |   2 +-
 tests/qemuxml2argvtest.c  |  56 
 .../hugepages-default-2M.xml  |   1 +
 .../hugepages-default-system-size.xml |   1 +
 .../{hugepages.xml => hugepages-default.xml}  |   6 -
 .../qemuxml2xmloutdata/hugepages-nodeset.xml  |  30 
 ...ges2.xml => hugepages-numa-default-2M.xml} |  13 +-
 .../hugepages-numa-default-dimm.xml   |   1 +
 .../hugepages-numa-nodeset-part.xml   |  36 +
 ...s-pages.xml => hugepages-numa-nodeset.xml} |  20 +--
 tests/qemuxml2xmloutdata/hugepages-pages3.xml |  47 --
 tests/qemuxml2xmloutdata/hugepages-pages4.xml |   1 -
 tests/qemuxml2xmloutdata/hugepages-pages5.xml |   1 -
 tests/qemuxml2xmloutdata/hugepages-pages6.xml |   1 -
 tests/qemuxml2xmloutdata/hugepages-pages7.xml |   1 -
 .../qemuxml2xmloutdata/pages-dimm-discard.xml |   1 +
 .../pages-discard-hugepages.xml   |   1 +
 tests/qemuxml2xmloutdata/pages-discard.xml|   1 +
 .../seclabel-dynamic-none-relabel.xml |   2 +-
 tests/qemuxml2xmltest.c   |  19 +--
 52 files changed, 634 insertions(+), 512 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages-pages6.args => 
hugepages-default-1G-nodeset-2M.args} (72%)
 create mode 100644 tests/qemuxml2argvdata/hugepages-default-1G-nodeset-2M.xml
 rename tests/qemuxml2argvdata/{hugepages-pages5.args => 
hugepages-default-2M.args} (75%)
 rename tests/qemuxml2argvdata/{hugepages-pages5.xml => 
hugepages-default-2M.xml} (63%)
 create mode 100644 tests/qemuxml2argvdata/hugepages-default-system-size.args
 rename tests/qemuxml2argvdata/{hugepages-pages6.xml => 

[libvirt] [PATCH v2 01/20] tests: rename hugepages to hugepages-default

2018-08-09 Thread Pavel Hrdina
Remove unnecessary XML elements as well.

Signed-off-by: Pavel Hrdina 
---
 .../{hugepages.args => hugepages-default.args}  | 2 --
 .../{hugepages.xml => hugepages-default.xml}| 5 -
 tests/qemuxml2argvtest.c| 2 +-
 .../{hugepages.xml => hugepages-default.xml}| 6 --
 tests/qemuxml2xmltest.c | 2 +-
 5 files changed, 2 insertions(+), 15 deletions(-)
 rename tests/qemuxml2argvdata/{hugepages.args => hugepages-default.args} (82%)
 rename tests/qemuxml2argvdata/{hugepages.xml => hugepages-default.xml} (79%)
 rename tests/qemuxml2xmloutdata/{hugepages.xml => hugepages-default.xml} (82%)

diff --git a/tests/qemuxml2argvdata/hugepages.args 
b/tests/qemuxml2argvdata/hugepages-default.args
similarity index 82%
rename from tests/qemuxml2argvdata/hugepages.args
rename to tests/qemuxml2argvdata/hugepages-default.args
index ea61ba930e..115da3ea35 100644
--- a/tests/qemuxml2argvdata/hugepages.args
+++ b/tests/qemuxml2argvdata/hugepages-default.args
@@ -24,6 +24,4 @@ server,nowait \
 -no-acpi \
 -boot c \
 -usb \
--drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \
--device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/hugepages.xml 
b/tests/qemuxml2argvdata/hugepages-default.xml
similarity index 79%
rename from tests/qemuxml2argvdata/hugepages.xml
rename to tests/qemuxml2argvdata/hugepages-default.xml
index 2e65902f1c..99f53828fe 100644
--- a/tests/qemuxml2argvdata/hugepages.xml
+++ b/tests/qemuxml2argvdata/hugepages-default.xml
@@ -17,11 +17,6 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-
 
 
 
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 16000ca59d..cfebf364fb 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -960,7 +960,7 @@ mymain(void)
 DO_TEST("pmu-feature", NONE);
 DO_TEST("pmu-feature-off", NONE);
 
-DO_TEST("hugepages", NONE);
+DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-numa",
 QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
 QEMU_CAPS_VIRTIO_SCSI,
diff --git a/tests/qemuxml2xmloutdata/hugepages.xml 
b/tests/qemuxml2xmloutdata/hugepages-default.xml
similarity index 82%
rename from tests/qemuxml2xmloutdata/hugepages.xml
rename to tests/qemuxml2xmloutdata/hugepages-default.xml
index f78ca95c1b..40043434ee 100644
--- a/tests/qemuxml2xmloutdata/hugepages.xml
+++ b/tests/qemuxml2xmloutdata/hugepages-default.xml
@@ -17,12 +17,6 @@
   destroy
   
 /usr/bin/qemu-system-i686
-
-  
-  
-  
-  
-
 
   
 
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 6c4f96e505..ff6e611421 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -329,7 +329,7 @@ mymain(void)
 DO_TEST("pmu-feature", NONE);
 DO_TEST("pmu-feature-off", NONE);
 
-DO_TEST("hugepages", NONE);
+DO_TEST("hugepages-default", NONE);
 DO_TEST("hugepages-pages", NONE);
 DO_TEST("hugepages-pages2", NONE);
 DO_TEST("hugepages-pages3", NONE);
-- 
2.17.1

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


[libvirt] [PATCH v3 09/11] util: netdevip: use VIR_AUTOPTR for aggregate types

2018-08-09 Thread Sukrit Bhatnagar
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar 
---
 src/util/virnetdevip.c | 130 +++--
 1 file changed, 51 insertions(+), 79 deletions(-)

diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index c6d6175..4a38a54 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -168,10 +168,9 @@ virNetDevIPAddrAdd(const char *ifname,
virSocketAddr *peer,
unsigned int prefix)
 {
-virSocketAddr *broadcast = NULL;
-int ret = -1;
-struct nl_msg *nlmsg = NULL;
 unsigned int recvbuflen;
+VIR_AUTOPTR(virNlMsg) nlmsg = NULL;
+VIR_AUTOPTR(virSocketAddr) broadcast = NULL;
 VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
 VIR_AUTOFREE(char *) ipStr = NULL;
 VIR_AUTOFREE(char *) peerStr = NULL;
@@ -186,13 +185,13 @@ virNetDevIPAddrAdd(const char *ifname,
 !(peer && VIR_SOCKET_ADDR_VALID(peer))) {
 /* compute a broadcast address if this is IPv4 */
 if (VIR_ALLOC(broadcast) < 0)
-goto cleanup;
+return -1;
 
 if (virSocketAddrBroadcastByPrefix(addr, prefix, broadcast) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("Failed to determine broadcast address for '%s/%d'"),
-   ipStr, prefix);
-goto cleanup;
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Failed to determine broadcast address for 
'%s/%d'"),
+   ipStr, prefix);
+return -1;
 }
 bcastStr = virSocketAddrFormat(broadcast);
 }
@@ -206,11 +205,11 @@ virNetDevIPAddrAdd(const char *ifname,
 if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_NEWADDR, ifname,
addr, prefix,
broadcast, peer)))
-goto cleanup;
+return -1;
 
 if (virNetlinkCommand(nlmsg, , ,
   0, 0, NETLINK_ROUTE, 0) < 0)
-goto cleanup;
+return -1;
 
 
 if (virNetlinkGetErrorCode(resp, recvbuflen) < 0) {
@@ -220,14 +219,10 @@ virNetDevIPAddrAdd(const char *ifname,
peerStr ? " peer " : "", peerStr ? peerStr : "",
bcastStr ? " bcast " : "", bcastStr ? bcastStr : "",
ifname);
-goto cleanup;
+return -1;
 }
 
-ret = 0;
- cleanup:
-nlmsg_free(nlmsg);
-VIR_FREE(broadcast);
-return ret;
+return 0;
 }
 
 
@@ -246,30 +241,26 @@ virNetDevIPAddrDel(const char *ifname,
virSocketAddr *addr,
unsigned int prefix)
 {
-int ret = -1;
-struct nl_msg *nlmsg = NULL;
 unsigned int recvbuflen;
+VIR_AUTOPTR(virNlMsg) nlmsg = NULL;
 VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
 
 if (!(nlmsg = virNetDevCreateNetlinkAddressMessage(RTM_DELADDR, ifname,
addr, prefix,
NULL, NULL)))
-goto cleanup;
+return -1;
 
 if (virNetlinkCommand(nlmsg, , , 0, 0,
   NETLINK_ROUTE, 0) < 0)
-goto cleanup;
+return -1;
 
 if (virNetlinkGetErrorCode(resp, recvbuflen) < 0) {
 virReportError(VIR_ERR_SYSTEM_ERROR,
_("Error removing IP address from %s"), ifname);
-goto cleanup;
+return -1;
 }
 
-ret = 0;
- cleanup:
-nlmsg_free(nlmsg);
-return ret;
+return 0;
 }
 
 
@@ -292,8 +283,6 @@ virNetDevIPRouteAdd(const char *ifname,
 virSocketAddrPtr gateway,
 unsigned int metric)
 {
-int ret = -1;
-struct nl_msg *nlmsg = NULL;
 struct nlmsghdr *resp = NULL;
 unsigned int recvbuflen;
 unsigned int ifindex;
@@ -304,6 +293,7 @@ virNetDevIPRouteAdd(const char *ifname,
 int errCode;
 virSocketAddr defaultAddr;
 virSocketAddrPtr actualAddr;
+VIR_AUTOPTR(virNlMsg) nlmsg = NULL;
 VIR_AUTOFREE(char *) toStr = NULL;
 VIR_AUTOFREE(char *) viaStr = NULL;
 
@@ -315,10 +305,10 @@ virNetDevIPRouteAdd(const char *ifname,
 int family = VIR_SOCKET_ADDR_FAMILY(gateway);
 if (family == AF_INET) {
 if (virSocketAddrParseIPv4(, VIR_SOCKET_ADDR_IPV4_ALL) 
< 0)
-goto cleanup;
+return -1;
 } else {
 if (virSocketAddrParseIPv6(, VIR_SOCKET_ADDR_IPV6_ALL) 
< 0)
-goto cleanup;
+return -1;
 }
 
 actualAddr = 
@@ -330,17 +320,17 @@ virNetDevIPRouteAdd(const char *ifname,
 
 if (virNetDevGetIPAddressBinary(actualAddr, , ) < 0 ||
   

[libvirt] [PATCH v3 06/11] util: netdevbridge: use VIR_AUTOPTR for aggregate types

2018-08-09 Thread Sukrit Bhatnagar
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar 
---
 src/util/virnetdevbridge.c | 35 +--
 1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index fe3697b..089da78 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -417,12 +417,11 @@ virNetDevBridgeCreate(const char *brname)
 {
 /* use a netlink RTM_NEWLINK message to create the bridge */
 const char *type = "bridge";
-int rc = -1;
 struct nlmsgerr *err;
 struct ifinfomsg ifinfo = { .ifi_family = AF_UNSPEC };
 unsigned int recvbuflen;
-struct nl_msg *nl_msg;
 struct nlattr *linkinfo;
+VIR_AUTOPTR(virNlMsg) nl_msg = NULL;
 VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
 
 nl_msg = nlmsg_alloc_simple(RTM_NEWLINK,
@@ -444,7 +443,7 @@ virNetDevBridgeCreate(const char *brname)
 
 if (virNetlinkCommand(nl_msg, , , 0, 0,
   NETLINK_ROUTE, 0) < 0) {
-goto cleanup;
+return -1;
 }
 
 if (recvbuflen < NLMSG_LENGTH(0) || resp == NULL)
@@ -462,15 +461,14 @@ virNetDevBridgeCreate(const char *brname)
 /* fallback to ioctl if netlink doesn't support creating
  * bridges
  */
-rc = virNetDevBridgeCreateWithIoctl(brname);
-goto cleanup;
+return virNetDevBridgeCreateWithIoctl(brname);
 }
 # endif
 
 virReportSystemError(-err->error,
  _("error creating bridge interface %s"),
  brname);
-goto cleanup;
+return -1;
 }
 break;
 
@@ -480,19 +478,16 @@ virNetDevBridgeCreate(const char *brname)
 goto malformed_resp;
 }
 
-rc = 0;
- cleanup:
-nlmsg_free(nl_msg);
-return rc;
+return 0;
 
  malformed_resp:
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
-goto cleanup;
+return -1;
  buffer_too_small:
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
-goto cleanup;
+return -1;
 }
 
 
@@ -1055,11 +1050,10 @@ static int
 virNetDevBridgeFDBAddDel(const virMacAddr *mac, const char *ifname,
  unsigned int flags, bool isAdd)
 {
-int ret = -1;
 struct nlmsgerr *err;
 unsigned int recvbuflen;
-struct nl_msg *nl_msg;
 struct ndmsg ndm = { .ndm_family = PF_BRIDGE, .ndm_state = NUD_NOARP };
+VIR_AUTOPTR(virNlMsg) nl_msg = NULL;
 VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
 
 if (virNetDevGetIndex(ifname, _ifindex) < 0)
@@ -1103,7 +1097,7 @@ virNetDevBridgeFDBAddDel(const virMacAddr *mac, const 
char *ifname,
 
 if (virNetlinkCommand(nl_msg, , , 0, 0,
   NETLINK_ROUTE, 0) < 0) {
-goto cleanup;
+return -1;
 }
 if (recvbuflen < NLMSG_LENGTH(0) || resp == NULL)
 goto malformed_resp;
@@ -1116,7 +1110,7 @@ virNetDevBridgeFDBAddDel(const virMacAddr *mac, const 
char *ifname,
 if (err->error) {
 virReportSystemError(-err->error,
  _("error adding fdb entry for %s"), ifname);
-goto cleanup;
+return -1;
 }
 break;
 case NLMSG_DONE:
@@ -1126,20 +1120,17 @@ virNetDevBridgeFDBAddDel(const virMacAddr *mac, const 
char *ifname,
 goto malformed_resp;
 }
 
-ret = 0;
- cleanup:
-nlmsg_free(nl_msg);
-return ret;
+return 0;
 
  malformed_resp:
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed netlink response message"));
-goto cleanup;
+return -1;
 
  buffer_too_small:
 virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("allocated netlink buffer is too small"));
-goto cleanup;
+return -1;
 }
 
 
-- 
1.8.3.1

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


[libvirt] [PATCH v3 10/11] util: netdevopenvswitch: use VIR_AUTOPTR for aggregate types

2018-08-09 Thread Sukrit Bhatnagar
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar 
---
 src/util/virnetdevopenvswitch.c | 80 ++---
 1 file changed, 27 insertions(+), 53 deletions(-)

diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 9a9435f..a5de541 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -144,11 +144,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
virNetDevVPortProfilePtr ovsport,
virNetDevVlanPtr virtVlan)
 {
-int ret = -1;
-virCommandPtr cmd = NULL;
 char macaddrstr[VIR_MAC_STRING_BUFLEN];
 char ifuuidstr[VIR_UUID_STRING_BUFLEN];
 char vmuuidstr[VIR_UUID_STRING_BUFLEN];
+VIR_AUTOPTR(virCommand) cmd = NULL;
 VIR_AUTOFREE(char *) attachedmac_ex_id = NULL;
 VIR_AUTOFREE(char *) ifaceid_ex_id = NULL;
 VIR_AUTOFREE(char *) profile_ex_id = NULL;
@@ -160,17 +159,17 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
 
 if (virAsprintf(_ex_id, "external-ids:attached-mac=\"%s\"",
 macaddrstr) < 0)
-goto cleanup;
+return -1;
 if (virAsprintf(_ex_id, "external-ids:iface-id=\"%s\"",
 ifuuidstr) < 0)
-goto cleanup;
+return -1;
 if (virAsprintf(_ex_id, "external-ids:vm-id=\"%s\"",
 vmuuidstr) < 0)
-goto cleanup;
+return -1;
 if (ovsport->profileID[0] != '\0') {
 if (virAsprintf(_ex_id, "external-ids:port-profile=\"%s\"",
 ovsport->profileID) < 0)
-goto cleanup;
+return -1;
 }
 
 cmd = virCommandNew(OVSVSCTL);
@@ -179,7 +178,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
  ifname, "--", "add-port", brname, ifname, NULL);
 
 if (virNetDevOpenvswitchConstructVlans(cmd, virtVlan) < 0)
-goto cleanup;
+return -1;
 
 if (ovsport->profileID[0] == '\0') {
 virCommandAddArgList(cmd,
@@ -204,13 +203,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to add port %s to OVS bridge %s"),
ifname, brname);
-goto cleanup;
+return -1;
 }
 
-ret = 0;
- cleanup:
-virCommandFree(cmd);
-return ret;
+return 0;
 }
 
 /**
@@ -223,8 +219,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const 
char *ifname,
  */
 int virNetDevOpenvswitchRemovePort(const char *brname ATTRIBUTE_UNUSED, const 
char *ifname)
 {
-int ret = -1;
-virCommandPtr cmd = NULL;
+VIR_AUTOPTR(virCommand) cmd = NULL;
 
 cmd = virCommandNew(OVSVSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
@@ -233,13 +228,10 @@ int virNetDevOpenvswitchRemovePort(const char *brname 
ATTRIBUTE_UNUSED, const ch
 if (virCommandRun(cmd, NULL) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to delete port %s from OVS"), ifname);
-goto cleanup;
+return -1;
 }
 
-ret = 0;
- cleanup:
-virCommandFree(cmd);
-return ret;
+return 0;
 }
 
 /**
@@ -253,9 +245,8 @@ int virNetDevOpenvswitchRemovePort(const char *brname 
ATTRIBUTE_UNUSED, const ch
  */
 int virNetDevOpenvswitchGetMigrateData(char **migrate, const char *ifname)
 {
-virCommandPtr cmd = NULL;
 size_t len;
-int ret = -1;
+VIR_AUTOPTR(virCommand) cmd = NULL;
 
 cmd = virCommandNew(OVSVSCTL);
 virNetDevOpenvswitchAddTimeout(cmd);
@@ -269,7 +260,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, 
const char *ifname)
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to run command to get OVS port data for "
  "interface %s"), ifname);
-goto cleanup;
+return -1;
 }
 
 /* Wipeout the newline, if it exists */
@@ -277,10 +268,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, 
const char *ifname)
 if (len > 0)
 (*migrate)[len - 1] = '\0';
 
-ret = 0;
- cleanup:
-virCommandFree(cmd);
-return ret;
+return 0;
 }
 
 /**
@@ -294,8 +282,7 @@ int virNetDevOpenvswitchGetMigrateData(char **migrate, 
const char *ifname)
  */
 int virNetDevOpenvswitchSetMigrateData(char *migrate, const char *ifname)
 {
-virCommandPtr cmd = NULL;
-int ret = -1;
+VIR_AUTOPTR(virCommand) cmd = NULL;
 
 if (!migrate) {
 VIR_DEBUG("No OVS port data for interface %s", ifname);
@@ -312,13 +299,10 @@ int virNetDevOpenvswitchSetMigrateData(char *migrate, 
const char *ifname)
 

[libvirt] [PATCH v3 08/11] util: netdev: use VIR_AUTOPTR for aggregate types

2018-08-09 Thread Sukrit Bhatnagar
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar 
---
 src/util/virnetdev.c | 249 +--
 1 file changed, 103 insertions(+), 146 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index edb7393..d5aa94c 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1182,27 +1182,21 @@ virNetDevIsPCIDevice(const char *devpath)
 static virPCIDevicePtr
 virNetDevGetPCIDevice(const char *devName)
 {
-virPCIDeviceAddressPtr vfPCIAddr = NULL;
-virPCIDevicePtr vfPCIDevice = NULL;
+VIR_AUTOPTR(virPCIDeviceAddress) vfPCIAddr = NULL;
 VIR_AUTOFREE(char *) vfSysfsDevicePath = NULL;
 
 if (virNetDevSysfsFile(, devName, "device") < 0)
-goto cleanup;
+return NULL;
 
 if (!virNetDevIsPCIDevice(vfSysfsDevicePath))
-goto cleanup;
+return NULL;
 
 vfPCIAddr = virPCIGetDeviceAddressFromSysfsLink(vfSysfsDevicePath);
 if (!vfPCIAddr)
-goto cleanup;
+return NULL;
 
-vfPCIDevice = virPCIDeviceNew(vfPCIAddr->domain, vfPCIAddr->bus,
-  vfPCIAddr->slot, vfPCIAddr->function);
-
- cleanup:
-VIR_FREE(vfPCIAddr);
-
-return vfPCIDevice;
+return virPCIDeviceNew(vfPCIAddr->domain, vfPCIAddr->bus,
+   vfPCIAddr->slot, vfPCIAddr->function);
 }
 
 
@@ -1601,12 +1595,12 @@ virNetDevSetVfConfig(const char *ifname, int vf,
 char macstr[VIR_MAC_STRING_BUFLEN];
 struct nlmsgerr *err;
 unsigned int recvbuflen = 0;
-struct nl_msg *nl_msg;
 struct nlattr *vfinfolist, *vfinfo;
 struct ifinfomsg ifinfo = {
 .ifi_family = AF_UNSPEC,
 .ifi_index  = -1,
 };
+VIR_AUTOPTR(virNlMsg) nl_msg = NULL;
 VIR_AUTOFREE(struct nlmsghdr *) resp = NULL;
 
 if (!macaddr && vlanid < 0)
@@ -1710,7 +1704,6 @@ virNetDevSetVfConfig(const char *ifname, int vf,
   macaddr ? virMacAddrFormat(macaddr, macstr) : "(unchanged)",
   vlanid, rc < 0 ? "Fail" : "Success");
 
-nlmsg_free(nl_msg);
 return rc;
 
  malformed_resp:
@@ -1849,12 +1842,11 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
const char *stateDir,
bool saveVlan)
 {
-int ret = -1;
 const char *pfDevName = NULL;
 virMacAddr oldMAC;
 char MACStr[VIR_MAC_STRING_BUFLEN];
 int oldVlanTag = -1;
-virJSONValuePtr configJSON = NULL;
+VIR_AUTOPTR(virJSONValue) configJSON = NULL;
 VIR_AUTOFREE(char *) pfDevOrig = NULL;
 VIR_AUTOFREE(char *) vfDevOrig = NULL;
 VIR_AUTOFREE(char *) filePath = NULL;
@@ -1866,7 +1858,7 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
 
 /* linkdev should get the VF's netdev name (or NULL if none) */
 if (virNetDevPFGetVF(pfDevName, vf, ) < 0)
-goto cleanup;
+return -1;
 
 linkdev = vfDevOrig;
 saveVlan = true;
@@ -1878,12 +1870,12 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
  */
 
 if (virNetDevGetPhysicalFunction(linkdev, ) < 0)
-goto cleanup;
+return -1;
 
 pfDevName = pfDevOrig;
 
 if (virNetDevGetVirtualFunctionIndex(pfDevName, linkdev, ) < 0)
-goto cleanup;
+return -1;
 }
 
 if (pfDevName) {
@@ -1901,7 +1893,7 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
  * explicitly enable the PF in the host system network config.
  */
 if (virNetDevGetOnline(pfDevName, ) < 0)
-goto cleanup;
+return -1;
 
 if (!pfIsOnline) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1910,12 +1902,12 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
  "change host network config to put the "
  "PF online."),
vf, pfDevName);
-goto cleanup;
+return -1;
 }
 }
 
 if (!(configJSON = virJSONValueNewObject()))
-goto cleanup;
+return -1;
 
 /* if there is a PF, it's now in pfDevName, and linkdev is either
  * the VF's name, or NULL (if the VF isn't bound to a net driver
@@ -1924,11 +1916,11 @@ virNetDevSaveNetConfig(const char *linkdev, int vf,
 
 if (pfDevName && saveVlan) {
 if (virAsprintf(, "%s/%s_vf%d", stateDir, pfDevName, vf) < 0)
-goto cleanup;
+return -1;
 
 /* get admin MAC and vlan tag */
 if (virNetDevGetVfConfig(pfDevName, vf, , ) < 0)
-goto cleanup;
+return -1;
 
 if (virJSONValueObjectAppendString(configJSON,
VIR_NETDEV_KEYNAME_ADMIN_MAC,
@@ -1936,39 +1928,36 @@ 

[libvirt] [PATCH v3 07/11] util: netdev: use VIR_AUTOFREE instead of VIR_FREE for scalar types

2018-08-09 Thread Sukrit Bhatnagar
By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar 
---
 src/util/virnetdev.c | 343 +++
 1 file changed, 125 insertions(+), 218 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 8eac419..edb7393 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -535,18 +535,17 @@ int virNetDevSetMTUFromDevice(const char *ifname,
  */
 int virNetDevSetNamespace(const char *ifname, pid_t pidInNs)
 {
-int ret = -1;
-char *pid = NULL;
-char *phy = NULL;
-char *phy_path = NULL;
 int len;
+VIR_AUTOFREE(char *) pid = NULL;
+VIR_AUTOFREE(char *) phy = NULL;
+VIR_AUTOFREE(char *) phy_path = NULL;
 
 if (virAsprintf(, "%lld", (long long) pidInNs) == -1)
 return -1;
 
 /* The 802.11 wireless devices only move together with their PHY. */
 if (virNetDevSysfsFile(_path, ifname, "phy80211/name") < 0)
-goto cleanup;
+return -1;
 
 if ((len = virFileReadAllQuiet(phy_path, 1024, )) <= 0) {
 /* Not a wireless device. */
@@ -556,7 +555,7 @@ int virNetDevSetNamespace(const char *ifname, pid_t pidInNs)
 
 argv[5] = pid;
 if (virRun(argv, NULL) < 0)
-goto cleanup;
+return -1;
 
 } else {
 const char *argv[] = {
@@ -569,15 +568,10 @@ int virNetDevSetNamespace(const char *ifname, pid_t 
pidInNs)
 argv[2] = phy;
 argv[5] = pid;
 if (virRun(argv, NULL) < 0)
-goto cleanup;
+return -1;
 }
 
-ret = 0;
- cleanup:
-VIR_FREE(phy_path);
-VIR_FREE(phy);
-VIR_FREE(pid);
-return ret;
+return 0;
 }
 
 #if defined(SIOCSIFNAME) && defined(HAVE_STRUCT_IFREQ)
@@ -969,25 +963,21 @@ int virNetDevGetIndex(const char *ifname ATTRIBUTE_UNUSED,
 int
 virNetDevGetMaster(const char *ifname, char **master)
 {
-int ret = -1;
-void *nlData = NULL;
 struct nlattr *tb[IFLA_MAX + 1] = {NULL, };
+VIR_AUTOFREE(void *) nlData = NULL;
 
 *master = NULL;
 
 if (virNetlinkDumpLink(ifname, -1, , tb, 0, 0) < 0)
-goto cleanup;
+return -1;
 
 if (tb[IFLA_MASTER]) {
 if (!(*master = virNetDevGetName(*(int *)RTA_DATA(tb[IFLA_MASTER]
-goto cleanup;
+return -1;
 }
 
 VIR_DEBUG("IFLA_MASTER for %s is %s", ifname, *master ? *master : 
"(none)");
-ret = 0;
- cleanup:
-VIR_FREE(nlData);
-return ret;
+return 0;
 }
 
 
@@ -1168,39 +1158,33 @@ virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, 
const char *ifname,
 static bool
 virNetDevIsPCIDevice(const char *devpath)
 {
-char *subsys_link = NULL;
-char *abs_path = NULL;
 char *subsys = NULL;
-bool ret = false;
+VIR_AUTOFREE(char *) subsys_link = NULL;
+VIR_AUTOFREE(char *) abs_path = NULL;
 
 if (virAsprintf(_link, "%s/subsystem", devpath) < 0)
 return false;
 
 if (!virFileExists(subsys_link))
-goto cleanup;
+return false;
 
 if (virFileResolveLink(subsys_link, _path) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to resolve device subsystem symlink %s"),
subsys_link);
-goto cleanup;
+return false;
 }
 
 subsys = last_component(abs_path);
-ret = STRPREFIX(subsys, "pci");
-
- cleanup:
-VIR_FREE(subsys_link);
-VIR_FREE(abs_path);
-return ret;
+return STRPREFIX(subsys, "pci");
 }
 
 static virPCIDevicePtr
 virNetDevGetPCIDevice(const char *devName)
 {
-char *vfSysfsDevicePath = NULL;
 virPCIDeviceAddressPtr vfPCIAddr = NULL;
 virPCIDevicePtr vfPCIDevice = NULL;
+VIR_AUTOFREE(char *) vfSysfsDevicePath = NULL;
 
 if (virNetDevSysfsFile(, devName, "device") < 0)
 goto cleanup;
@@ -1216,7 +1200,6 @@ virNetDevGetPCIDevice(const char *devName)
   vfPCIAddr->slot, vfPCIAddr->function);
 
  cleanup:
-VIR_FREE(vfSysfsDevicePath);
 VIR_FREE(vfPCIAddr);
 
 return vfPCIDevice;
@@ -1241,25 +1224,20 @@ int
 virNetDevGetPhysPortID(const char *ifname,
char **physPortID)
 {
-int ret = -1;
-char *physPortIDFile = NULL;
+VIR_AUTOFREE(char *) physPortIDFile = NULL;
 
 *physPortID = NULL;
 
 if (virNetDevSysfsFile(, ifname, "phys_port_id") < 0)
-goto cleanup;
+return -1;
 
 /* a failure to read just means the driver doesn't support
- * phys_port_id, so set success now and ignore the return from
- * virFileReadAllQuiet().
+ * phys_port_id, so ignore the return from virFileReadAllQuiet()
+ * and return success.
  */
-ret = 0;
-
 ignore_value(virFileReadAllQuiet(physPortIDFile, 1024, physPortID));
 
- cleanup:
-VIR_FREE(physPortIDFile);
-

  1   2   >