[libvirt] [PATCH] interfaces: Convert virInterfaceObjList to virObjectRWLockable

2017-10-09 Thread John Ferlan
Rather than a forward linked list, let's use the ObjectRWLockable object
in order to manage the data.

Requires numerous changes from List to Object management similar to
many other drivers/vir*obj.c modules

Signed-off-by: John Ferlan 
---

 For some reason I thought I had already done this, but guess I hadn't,
 so figured I may as well. Uses the RWLockable too.

 Passed the avocado test suite too.

 src/conf/virinterfaceobj.c | 341 ++---
 src/libvirt_private.syms   |   1 -
 src/test/test_driver.c |   6 +-
 3 files changed, 229 insertions(+), 119 deletions(-)

diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c
index e993b929d7..4bd371bb1e 100644
--- a/src/conf/virinterfaceobj.c
+++ b/src/conf/virinterfaceobj.c
@@ -25,6 +25,7 @@
 #include "viralloc.h"
 #include "virerror.h"
 #include "virinterfaceobj.h"
+#include "virhash.h"
 #include "virlog.h"
 #include "virstring.h"
 
@@ -40,14 +41,19 @@ struct _virInterfaceObj {
 };
 
 struct _virInterfaceObjList {
-size_t count;
-virInterfaceObjPtr *objs;
+virObjectRWLockable parent;
+
+/* name string -> virInterfaceObj  mapping
+ * for O(1), lockless lookup-by-name */
+virHashTable *objsName;
 };
 
 /* virInterfaceObj manipulation */
 
 static virClassPtr virInterfaceObjClass;
+static virClassPtr virInterfaceObjListClass;
 static void virInterfaceObjDispose(void *obj);
+static void virInterfaceObjListDispose(void *obj);
 
 static int
 virInterfaceObjOnceInit(void)
@@ -58,6 +64,12 @@ virInterfaceObjOnceInit(void)
  virInterfaceObjDispose)))
 return -1;
 
+if (!(virInterfaceObjListClass = virClassNew(virClassForObjectRWLockable(),
+ "virInterfaceObjList",
+ sizeof(virInterfaceObjList),
+ virInterfaceObjListDispose)))
+return -1;
+
 return 0;
 }
 
@@ -130,119 +142,189 @@ virInterfaceObjListNew(void)
 {
 virInterfaceObjListPtr interfaces;
 
-if (VIR_ALLOC(interfaces) < 0)
+if (virInterfaceObjInitialize() < 0)
 return NULL;
+
+if (!(interfaces = virObjectRWLockableNew(virInterfaceObjListClass)))
+return NULL;
+
+if (!(interfaces->objsName = virHashCreate(10, virObjectFreeHashData))) {
+virObjectUnref(interfaces);
+return NULL;
+}
+
 return interfaces;
 }
 
 
+struct _virInterfaceObjForEachData {
+bool wantActive;
+const char *matchStr;
+bool error;
+int nElems;
+int maxElems;
+char **const elems;
+};
+
+static int
+virInterfaceObjListFindByMACStringCb(void *payload,
+ const void *name ATTRIBUTE_UNUSED,
+ void *opaque)
+{
+virInterfaceObjPtr obj = payload;
+struct _virInterfaceObjForEachData *data = opaque;
+
+if (data->error)
+return 0;
+
+if (data->nElems == data->maxElems)
+return 0;
+
+virObjectLock(obj);
+
+if (STRCASEEQ(obj->def->mac, data->matchStr)) {
+if (VIR_STRDUP(data->elems[data->nElems], data->matchStr) < 0) {
+data->error = true;
+goto cleanup;
+}
+data->nElems++;
+}
+
+ cleanup:
+virObjectUnlock(obj);
+return 0;
+}
+
+
 int
 virInterfaceObjListFindByMACString(virInterfaceObjListPtr interfaces,
const char *mac,
char **const matches,
int maxmatches)
 {
-size_t i;
-int matchct = 0;
+struct _virInterfaceObjForEachData data = { .matchStr = mac,
+.error = false,
+.nElems = 0,
+.maxElems = maxmatches,
+.elems = matches };
 
-for (i = 0; i < interfaces->count; i++) {
-virInterfaceObjPtr obj = interfaces->objs[i];
-virInterfaceDefPtr def;
+virObjectRWLockRead(interfaces);
+virHashForEach(interfaces->objsName, virInterfaceObjListFindByMACStringCb,
+   );
+virObjectRWUnlock(interfaces);
 
-virObjectLock(obj);
-def = obj->def;
-if (STRCASEEQ(def->mac, mac)) {
-if (matchct < maxmatches) {
-if (VIR_STRDUP(matches[matchct], def->name) < 0) {
-virObjectUnlock(obj);
-goto error;
-}
-matchct++;
-}
-}
-virObjectUnlock(obj);
-}
-return matchct;
+if (data.error)
+goto error;
+
+return data.nElems;
 
  error:
-while (--matchct >= 0)
-VIR_FREE(matches[matchct]);
+while (--data.nElems >= 0)
+VIR_FREE(data.elems[data.nElems]);
 
 return -1;
 }
 
 
+static 

[libvirt] [PATCH 3/6] docs: Add info about ide model attribute.

2017-10-09 Thread Dawid Zamirski
From: Dawid Zamirski 

---
 docs/formatdomain.html.in | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c0e3c2221..ddcc9f1b1 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3596,6 +3596,9 @@
  Since 1.3.5, USB controllers accept a
  ports attribute to configure how many devices can be
  connected to the controller.
+ide
+An ide controller has an optional attribute
+model, which is one of "piix3", "piix4" or "ich6".
   
 
 
-- 
2.14.2

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


[libvirt] [PATCH 5/6] vbox: Process controller definitions from xml.

2017-10-09 Thread Dawid Zamirski
From: Dawid Zamirski 

Until now the vbox driver was completely ignoring  element
for storage in the XML definition. This patch adds support for
interpretting  element for storage devices. With this the
following other changes were made to the whole storage attachment code:

* vboxAttachDrives no longer "computes" deviceSlot and devicePort
  values based on the disk device name. This was causing the driver to
  ignore the values set by  element of the  device. If
  that element is omitted in XML, the values produced by default by
  virDomainDiskDefAssign address should work well.
* if any part of storage attachment code fails, i.e wherever we call
  virReportError, we also fail the DefineXML caller rather than ignoring
  those issues and moving on.
* the DefineXML cleanup part of the code was changed to make sure that
  any critical failure in device attachment code does not leave any
  partially defined VM behind.
* do not require disk source for removable drives so that "empty"
  drives can be created for cdrom and floppy types.
---
 src/vbox/vbox_common.c | 535 ++---
 src/vbox/vbox_common.h |   8 +
 src/vbox/vbox_tmpl.c   |  43 ++--
 3 files changed, 310 insertions(+), 276 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 92ee37164..7645b29a0 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -324,6 +324,9 @@ static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox,
 gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
  StorageBus_SCSI,
  
[StorageBus_SCSI]);
+gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
+ StorageBus_SAS,
+ 
[StorageBus_SAS]);
 gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
  StorageBus_Floppy,
  
[StorageBus_Floppy]);
@@ -337,6 +340,9 @@ static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox,
 gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
   
StorageBus_SCSI,
   
[StorageBus_SCSI]);
+gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
+  
StorageBus_SAS,
+  
[StorageBus_SAS]);
 gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
   
StorageBus_Floppy,
   
[StorageBus_Floppy]);
@@ -346,68 +352,6 @@ static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox,
 return true;
 }
 
-/**
- * function to get the StorageBus, Port number
- * and Device number for the given devicename
- * e.g: hda has StorageBus = IDE, port = 0,
- *  device = 0
- *
- * @returns true on Success, false on failure.
- * @param   deviceName  Input device name
- * @param   aMaxPortPerInst Input array of max port per device instance
- * @param   aMaxSlotPerPort Input array of max slot per device port
- * @param   storageBus  Input storage bus type
- * @param   deviceInst  Output device instance number
- * @param   devicePort  Output port number
- * @param   deviceSlot  Output slot number
- *
- */
-static bool vboxGetDeviceDetails(const char *deviceName,
- PRUint32 *aMaxPortPerInst,
- PRUint32 *aMaxSlotPerPort,
- PRUint32 storageBus,
- PRInt32 *deviceInst,
- PRInt32 *devicePort,
- PRInt32 *deviceSlot)
-{
-int total = 0;
-PRUint32 maxPortPerInst = 0;
-PRUint32 maxSlotPerPort = 0;
-
-if (!deviceName ||
-!deviceInst ||
-!devicePort ||
-!deviceSlot ||
-!aMaxPortPerInst ||
-!aMaxSlotPerPort)
-return false;
-
-if ((storageBus < StorageBus_IDE) ||
-(storageBus > StorageBus_Floppy))
-return false;
-
-total = virDiskNameToIndex(deviceName);
-
-maxPortPerInst = aMaxPortPerInst[storageBus];
-maxSlotPerPort = aMaxSlotPerPort[storageBus];
-
-if (!maxPortPerInst ||
-!maxSlotPerPort ||
-(total < 0))
-return false;
-
-*deviceInst = total / (maxPortPerInst * maxSlotPerPort);
-*devicePort = (total % (maxPortPerInst * maxSlotPerPort)) / maxSlotPerPort;
-*deviceSlot = (total % 

[libvirt] [PATCH 6/6] vbox: Update XML dump of storage devices.

2017-10-09 Thread Dawid Zamirski
From: Dawid Zamirski 

* added vboxDumpStorageControllers
* replaced vboxDumpIDEHDDs with vboxDumpDisks which has been refectored
  quite a bit to handle removable devices, the new SAS controller
  support etc.
* align the logic in vboxSnapshotGetReadWriteDisks and
  vboxSnapshotGetReadOnlyDisks to more closely resemble vboxDumpDisks.
* vboxGenerateMediumName was simplified to no longer "compute" the
  device name value as deviePort/deviceSlot and their upper bound
  values are no longer enough to do this accurately due to the added
  SAS bus support which does not "map" directly into libvirt XML
  semantics
* vboxGetMaxPortSlotValues is now removed as it's no longer used
---
 src/vbox/vbox_common.c | 691 -
 1 file changed, 393 insertions(+), 298 deletions(-)

diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 7645b29a0..dd876645a 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -290,126 +290,44 @@ static int openSessionForMachine(vboxDriverPtr data, 
const unsigned char *dom_uu
 return 0;
 }
 
-/**
- * function to get the values for max port per
- * instance and max slots per port for the devices
- *
- * @returns true on Success, false on failure.
- * @param   vboxInput IVirtualBox pointer
- * @param   maxPortPerInst  Output array of max port per instance
- * @param   maxSlotPerPort  Output array of max slot per port
- *
- */
-
-static bool vboxGetMaxPortSlotValues(IVirtualBox *vbox,
- PRUint32 *maxPortPerInst,
- PRUint32 *maxSlotPerPort)
-{
-ISystemProperties *sysProps = NULL;
-
-if (!vbox)
-return false;
-
-gVBoxAPI.UIVirtualBox.GetSystemProperties(vbox, );
-
-if (!sysProps)
-return false;
-
-gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
- StorageBus_IDE,
- 
[StorageBus_IDE]);
-gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
- StorageBus_SATA,
- 
[StorageBus_SATA]);
-gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
- StorageBus_SCSI,
- 
[StorageBus_SCSI]);
-gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
- StorageBus_SAS,
- 
[StorageBus_SAS]);
-gVBoxAPI.UISystemProperties.GetMaxPortCountForStorageBus(sysProps,
- StorageBus_Floppy,
- 
[StorageBus_Floppy]);
-
-gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
-  
StorageBus_IDE,
-  
[StorageBus_IDE]);
-gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
-  
StorageBus_SATA,
-  
[StorageBus_SATA]);
-gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
-  
StorageBus_SCSI,
-  
[StorageBus_SCSI]);
-gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
-  
StorageBus_SAS,
-  
[StorageBus_SAS]);
-gVBoxAPI.UISystemProperties.GetMaxDevicesPerPortForStorageBus(sysProps,
-  
StorageBus_Floppy,
-  
[StorageBus_Floppy]);
-
-VBOX_RELEASE(sysProps);
-
-return true;
-}
-
 /**
  * function to generate the name for medium,
  * for e.g: hda, sda, etc
  *
  * @returns null terminated string with device name or NULL
  *  for failures
- * @param   connInput Connection Pointer
  * @param   storageBus  Input storage bus type
- * @param   deviceInst  Input device instance number
  * @param   devicePort  Input port number
  * @param   deviceSlot  Input slot number
- * @param   aMaxPortPerInst Input array of max port per device instance
- * @param   aMaxSlotPerPort Input array of max slot per device port
- *
+ * @param   sdCount Running total of 

[libvirt] [PATCH 2/6] domain: Allow 'model' attribute for ide controller.

2017-10-09 Thread Dawid Zamirski
From: Dawid Zamirski 

The optional values are 'piix3', 'piix4' or 'ich6'. Those will be
needed to allow setting IDE controller model in VirtualBox driver.
---
 docs/schemas/domaincommon.rng | 18 --
 src/conf/domain_conf.c|  9 +
 src/conf/domain_conf.h|  9 +
 src/libvirt_private.syms  |  2 ++
 4 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4dbda6932..c3f1557f0 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1927,12 +1927,11 @@
   
 
 
-  
+  
   
 
   
 fdc
-ide
 sata
 ccid
   
@@ -1993,6 +1992,21 @@
   
 
   
+  
+  
+
+  ide
+
+
+  
+
+  piix3
+  piix4
+  ich6
+
+  
+
+  
   
   
 
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 54be9028d..493bf83ff 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -378,6 +378,11 @@ VIR_ENUM_IMPL(virDomainControllerModelUSB, 
VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
   "qemu-xhci",
   "none")
 
+VIR_ENUM_IMPL(virDomainControllerModelIDE, 
VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST,
+  "piix3",
+  "piix4",
+  "ich6")
+
 VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
   "mount",
   "block",
@@ -9467,6 +9472,8 @@ virDomainControllerModelTypeFromString(const 
virDomainControllerDef *def,
 return virDomainControllerModelUSBTypeFromString(model);
 else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
 return virDomainControllerModelPCITypeFromString(model);
+else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
+return virDomainControllerModelIDETypeFromString(model);
 
 return -1;
 }
@@ -9482,6 +9489,8 @@ 
virDomainControllerModelTypeToString(virDomainControllerDefPtr def,
 return virDomainControllerModelUSBTypeToString(model);
 else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI)
 return virDomainControllerModelPCITypeToString(model);
+else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE)
+return virDomainControllerModelIDETypeToString(model);
 
 return NULL;
 }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a42efcfa6..d7f4c3f1e 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -748,6 +748,14 @@ typedef enum {
 VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST
 } virDomainControllerModelUSB;
 
+typedef enum {
+VIR_DOMAIN_CONTROLLER_MODEL_IDE_PIIX3,
+VIR_DOMAIN_CONTROLLER_MODEL_IDE_PIIX4,
+VIR_DOMAIN_CONTROLLER_MODEL_IDE_ICH6,
+
+VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST
+} virDomainControllerModelIDE;
+
 # define IS_USB2_CONTROLLER(ctrl) \
 (((ctrl)->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) && \
  ((ctrl)->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1 || \
@@ -3231,6 +3239,7 @@ VIR_ENUM_DECL(virDomainControllerModelPCI)
 VIR_ENUM_DECL(virDomainControllerPCIModelName)
 VIR_ENUM_DECL(virDomainControllerModelSCSI)
 VIR_ENUM_DECL(virDomainControllerModelUSB)
+VIR_ENUM_DECL(virDomainControllerModelIDE)
 VIR_ENUM_DECL(virDomainFS)
 VIR_ENUM_DECL(virDomainFSDriver)
 VIR_ENUM_DECL(virDomainFSAccessMode)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9243c5591..616b14f82 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -231,6 +231,8 @@ virDomainControllerFindUnusedIndex;
 virDomainControllerInsert;
 virDomainControllerInsertPreAlloced;
 virDomainControllerIsPSeriesPHB;
+virDomainControllerModelIDETypeFromString;
+virDomainControllerModelIDETypeToString;
 virDomainControllerModelPCITypeToString;
 virDomainControllerModelSCSITypeFromString;
 virDomainControllerModelSCSITypeToString;
-- 
2.14.2

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


[libvirt] [PATCH 4/6] vbox: Add more IStorageController API mappings.

2017-10-09 Thread Dawid Zamirski
From: Dawid Zamirski 

This patch 'maps' additonal methods for VBOX API to the libvirt unified
vbox API to deal with IStorageController. The 'mapped' methods are:

* IStorageController->GetStorageControllerType()
* IStorageController->SetStorageControllerType()
* IMachine->GetStorageControllers()
---
 src/vbox/vbox_common.h| 13 +
 src/vbox/vbox_tmpl.c  | 20 
 src/vbox/vbox_uniformed_api.h |  3 +++
 3 files changed, 36 insertions(+)

diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h
index c6da8929d..b08ad1e3e 100644
--- a/src/vbox/vbox_common.h
+++ b/src/vbox/vbox_common.h
@@ -235,6 +235,19 @@ enum StorageBus
 StorageBus_SAS = 5
 };
 
+enum StorageControllerType
+{
+StorageControllerType_Null = 0,
+StorageControllerType_LsiLogic = 1,
+StorageControllerType_BusLogic = 2,
+StorageControllerType_IntelAhci = 3,
+StorageControllerType_PIIX3 = 4,
+StorageControllerType_PIIX4 = 5,
+StorageControllerType_ICH6 = 6,
+StorageControllerType_I82078 = 7,
+StorageControllerType_LsiLogicSas = 8
+};
+
 enum AccessMode
 {
 AccessMode_ReadOnly = 1,
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index ac3b8fa00..6592cbd63 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -550,6 +550,11 @@ static void* _handleUSBGetDeviceFilters(IUSBCommon 
*USBCommon)
 return USBCommon->vtbl->GetDeviceFilters;
 }
 
+static void* _handleMachineGetStorageControllers(IMachine *machine)
+{
+return machine->vtbl->GetStorageControllers;
+}
+
 static void* _handleMachineGetMediumAttachments(IMachine *machine)
 {
 return machine->vtbl->GetMediumAttachments;
@@ -1919,6 +1924,18 @@ _storageControllerGetBus(IStorageController 
*storageController, PRUint32 *bus)
 return storageController->vtbl->GetBus(storageController, bus);
 }
 
+static nsresult
+_storageControllerGetControllerType(IStorageController *storageController, 
PRUint32 *controllerType)
+{
+return storageController->vtbl->GetControllerType(storageController, 
controllerType);
+}
+
+static nsresult
+_storageControllerSetControllerType(IStorageController *storageController, 
PRUint32 controllerType)
+{
+return storageController->vtbl->SetControllerType(storageController, 
controllerType);
+}
+
 static nsresult
 _sharedFolderGetHostPath(ISharedFolder *sharedFolder, PRUnichar **hostPath)
 {
@@ -2268,6 +2285,7 @@ static vboxUniformedArray _UArray = {
 .handleGetMachines = _handleGetMachines,
 .handleGetHardDisks = _handleGetHardDisks,
 .handleUSBGetDeviceFilters = _handleUSBGetDeviceFilters,
+.handleMachineGetStorageControllers = _handleMachineGetStorageControllers,
 .handleMachineGetMediumAttachments = _handleMachineGetMediumAttachments,
 .handleMachineGetSharedFolders = _handleMachineGetSharedFolders,
 .handleSnapshotGetChildren = _handleSnapshotGetChildren,
@@ -2499,6 +2517,8 @@ static vboxUniformedIMediumAttachment _UIMediumAttachment 
= {
 
 static vboxUniformedIStorageController _UIStorageController = {
 .GetBus = _storageControllerGetBus,
+.GetControllerType = _storageControllerGetControllerType,
+.SetControllerType = _storageControllerSetControllerType,
 };
 
 static vboxUniformedISharedFolder _UISharedFolder = {
diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
index 2ccaf43e8..dc0b391b2 100644
--- a/src/vbox/vbox_uniformed_api.h
+++ b/src/vbox/vbox_uniformed_api.h
@@ -135,6 +135,7 @@ typedef struct {
 void* (*handleGetMachines)(IVirtualBox *vboxObj);
 void* (*handleGetHardDisks)(IVirtualBox *vboxObj);
 void* (*handleUSBGetDeviceFilters)(IUSBCommon *USBCommon);
+void* (*handleMachineGetStorageControllers)(IMachine *machine);
 void* (*handleMachineGetMediumAttachments)(IMachine *machine);
 void* (*handleMachineGetSharedFolders)(IMachine *machine);
 void* (*handleSnapshotGetChildren)(ISnapshot *snapshot);
@@ -410,6 +411,8 @@ typedef struct {
 /* Functions for IStorageController */
 typedef struct {
 nsresult (*GetBus)(IStorageController *storageController, PRUint32 *bus);
+nsresult (*SetControllerType)(IStorageController *storageController, 
PRUint32 controllerType);
+nsresult (*GetControllerType)(IStorageController *storageController, 
PRUint32 *controllerType);
 } vboxUniformedIStorageController;
 
 /* Functions for ISharedFolder */
-- 
2.14.2

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


[libvirt] [PATCH 0/6] vbox: Improve handling of storage devices.

2017-10-09 Thread Dawid Zamirski
Hello,

This patch series reworks the VirtualBox storage device handling code,
brief summary:

* Extend libvirt schema to specify IDE controller model as VBox supports
  changing IDE model to PIIX3, PIIX4 or ICH6 and there are known cases
  of legacy guest OSes being very sensitive to that.
* Make the driver recognize  element at define time which
  allows to specify controller model. Previously the driver was
  completely ignoring that element.
* Allow to create vbox SAS controllers via
  
* Handle removable devices - define and dump devices without media.
* Make sure media is closed when undefining VMs. Leaving media unclosed
  may cause errors when defining VMs pointing at the same local path.

Dawid Zamirski (6):
  vbox: Close media when undefining domains.
  domain: Allow 'model' attribute for ide controller.
  docs: Add info about ide model attribute.
  vbox: Add more IStorageController API mappings.
  vbox: Process controller definitions from xml.
  vbox: Update XML dump of storage devices.

 docs/formatdomain.html.in |3 +
 docs/schemas/domaincommon.rng |   18 +-
 src/conf/domain_conf.c|9 +
 src/conf/domain_conf.h|9 +
 src/libvirt_private.syms  |2 +
 src/vbox/vbox_common.c| 1212 +++--
 src/vbox/vbox_common.h|   21 +
 src/vbox/vbox_tmpl.c  |   87 +--
 src/vbox/vbox_uniformed_api.h |3 +
 9 files changed, 790 insertions(+), 574 deletions(-)

-- 
2.14.2

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


[libvirt] [PATCH 1/6] vbox: Close media when undefining domains.

2017-10-09 Thread Dawid Zamirski
From: Dawid Zamirski 

When registering a VM we call OpenMedium on each disk image which adds it
to vbox's global media registry. Therefore, we should make sure to call
Close when unregistering VM so we cleanup the media registry entries
after ourselves - this does not remove disk image files. This follows
the behaviour of the VBoxManage unregistervm command.
---
 src/vbox/vbox_tmpl.c | 24 +++-
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index dffeabde0..ac3b8fa00 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -378,6 +378,8 @@ _unregisterMachine(vboxDriverPtr data, vboxIID *iid, 
IMachine **machine)
 {
 nsresult rc;
 vboxArray media = VBOX_ARRAY_INITIALIZER;
+size_t i;
+
 rc = data->vboxObj->vtbl->FindMachine(data->vboxObj, iid->value, machine);
 if (NS_FAILED(rc)) {
 virReportError(VIR_ERR_NO_DOMAIN, "%s",
@@ -385,12 +387,24 @@ _unregisterMachine(vboxDriverPtr data, vboxIID *iid, 
IMachine **machine)
 return rc;
 }
 
-/* We're not interested in the array returned by the Unregister method,
- * but in the side effect of unregistering the virtual machine. In order
- * to call the Unregister method correctly we need to use the vboxArray
- * wrapper here. */
 rc = vboxArrayGetWithUintArg(, *machine, 
(*machine)->vtbl->Unregister,
- CleanupMode_DetachAllReturnNone);
+ CleanupMode_DetachAllReturnHardDisksOnly);
+
+if (NS_FAILED(rc))
+goto cleanup;
+
+/* close each medium attached to VM to remove from media registry */
+for (i = 0; i < media.count; i++) {
+IMedium *medium = media.items[i];
+
+if (!medium)
+continue;
+
+/* it's ok to ignore failure here - e.g. it may be used by another VM 
*/
+medium->vtbl->Close(medium);
+}
+
+ cleanup:
 vboxArrayUnalloc();
 return rc;
 }
-- 
2.14.2

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


Re: [libvirt] [RFC PATCH 3/4] lxc: Fixed a typo

2017-10-09 Thread Cedric Bosdonnat
On Mon, 2017-10-09 at 21:14 +0200, Marc Hartmayer wrote:
> Signed-off-by: Marc Hartmayer 
> Reviewed-by: Bjoern Walk 
> Reviewed-by: Boris Fiuczynski 
> ---
>  src/lxc/lxc_container.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 1f220c602b0a..5791a9b1f958 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -2167,7 +2167,7 @@ static int lxcContainerSetUserGroup(virCommandPtr cmd,
>   * This function is run in the process clone()'d in lxcStartContainer.
>   * Perform a number of container setup tasks:
>   * Setup container file system
> - * mount container /proca
> + * mount container /proc
>   * Then exec's the container init
>   *
>   * Returns 0 on success or -1 in case of error

ACK
--
Cedric

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

Re: [libvirt] [RFC PATCH 1/4] util: Add virCommandGetGID and virCommandGetUID

2017-10-09 Thread Cedric Bosdonnat
On Mon, 2017-10-09 at 21:14 +0200, Marc Hartmayer wrote:
> These functions are used by an upcoming commit.
> 
> Signed-off-by: Marc Hartmayer 
> Reviewed-by: Boris Fiuczynski 
> ---
>  src/libvirt_private.syms |  2 ++
>  src/util/vircommand.c| 14 ++
>  src/util/vircommand.h|  4 
>  3 files changed, 20 insertions(+)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 9243c5591042..26c5ddb40505 100644
> --- a/src/libvirt_private.syms
> +++ b/src/libvirt_private.syms
> @@ -1506,6 +1506,8 @@ virCommandDaemonize;
>  virCommandDoAsyncIO;
>  virCommandExec;
>  virCommandFree;
> +virCommandGetGID;
> +virCommandGetUID;
>  virCommandHandshakeNotify;
>  virCommandHandshakeWait;
>  virCommandNew;
> diff --git a/src/util/vircommand.c b/src/util/vircommand.c
> index 60c1121dafea..fba73ca18eac 100644
> --- a/src/util/vircommand.c
> +++ b/src/util/vircommand.c
> @@ -1073,6 +1073,20 @@ virCommandSetPidFile(virCommandPtr cmd, const char 
> *pidfile)
>  }
>  
>  
> +gid_t
> +virCommandGetGID(virCommandPtr cmd)
> +{
> +return cmd->gid;
> +}
> +
> +
> +uid_t
> +virCommandGetUID(virCommandPtr cmd)
> +{
> +return cmd->uid;
> +}
> +
> +
>  void
>  virCommandSetGID(virCommandPtr cmd, gid_t gid)
>  {
> diff --git a/src/util/vircommand.h b/src/util/vircommand.h
> index e7c2e513bae1..b401d7b238d7 100644
> --- a/src/util/vircommand.h
> +++ b/src/util/vircommand.h
> @@ -68,6 +68,10 @@ int virCommandPassFDGetFDIndex(virCommandPtr cmd,
>  void virCommandSetPidFile(virCommandPtr cmd,
>    const char *pidfile) ATTRIBUTE_NONNULL(2);
>  
> +gid_t virCommandGetGID(virCommandPtr cmd) ATTRIBUTE_NONNULL(1);
> +
> +uid_t virCommandGetUID(virCommandPtr cmd) ATTRIBUTE_NONNULL(1);
> +
>  void virCommandSetGID(virCommandPtr cmd, gid_t gid);
>  
>  void virCommandSetUID(virCommandPtr cmd, uid_t uid);

ACK.
I guess the commit using those is still to come, right?
--
Cedric

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

Re: [libvirt] [RFC PATCH 4/4] lxc: Fixed indentation

2017-10-09 Thread Cedric Bosdonnat
On Mon, 2017-10-09 at 21:14 +0200, Marc Hartmayer wrote:
> Signed-off-by: Marc Hartmayer 
> Reviewed-by: Bjoern Walk 
> Reviewed-by: Boris Fiuczynski 
> ---
>  src/lxc/lxc_container.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index 5791a9b1f958..b7216d6ee863 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -2254,8 +2254,8 @@ static int lxcContainerChild(void *data)
>  
>  if (!virFileExists(vmDef->os.init)) {
>  virReportSystemError(errno,
> -_("cannot find init path '%s' relative to container 
> root"),
> -vmDef->os.init);
> + _("cannot find init path '%s' relative to 
> container root"),
> + vmDef->os.init);
>  goto cleanup;
>  }
>  
> @@ -2275,7 +2275,7 @@ static int lxcContainerChild(void *data)
>  
>  if (lxcContainerSendContinue(argv->handshakefd) < 0) {
>  virReportSystemError(errno, "%s",
> -_("Failed to send continue signal to 
> controller"));
> + _("Failed to send continue signal to 
> controller"));
>  goto cleanup;
>  }
>  

ACK
--
Cedric

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

Re: [libvirt] [RFC PATCH 2/4] util: Fix deadlock across fork()

2017-10-09 Thread Cedric Bosdonnat
The commit looks good to me, but I'ld rather have Dan have a look at it.
I'm not expert enough to tell what's safe and what is not.

--
Cedric

On Mon, 2017-10-09 at 21:14 +0200, Marc Hartmayer wrote:
> This commit fixes the deadlock introduced by commit
> 0980764dee687e8da86dc410c351759867163389. The call getgrouplist() of
> the glibc library isn't safe to be called in between fork and
> exec (see commit 75c125641ac73473ba4b0542524d67a184769c8e).
> 
> Signed-off-by: Marc Hartmayer 
> Fixes: 0980764dee68 ("util: share code between virExec and virCommandExec")
> Reviewed-by: Bjoern Walk 
> Reviewed-by: Boris Fiuczynski 
> ---
>  src/lxc/lxc_container.c | 12 +++-
>  src/util/vircommand.c   | 25 ++---
>  src/util/vircommand.h   |  2 +-
>  tests/commandtest.c | 15 ++-
>  4 files changed, 36 insertions(+), 18 deletions(-)
> 
> diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> index ec6d6a86b0b6..1f220c602b0a 100644
> --- a/src/lxc/lxc_container.c
> +++ b/src/lxc/lxc_container.c
> @@ -2182,6 +2182,8 @@ static int lxcContainerChild(void *data)
>  virDomainFSDefPtr root;
>  virCommandPtr cmd = NULL;
>  int hasReboot;
> +gid_t *groups = NULL;
> +int ngroups;
>  
>  if (NULL == vmDef) {
>  virReportError(VIR_ERR_INTERNAL_ERROR,
> @@ -2297,6 +2299,13 @@ static int lxcContainerChild(void *data)
>  goto cleanup;
>  }
>  
> +/* TODO is it safe to call it here or should this call be moved in
> + * front of the clone() as otherwise there might be a risk for a
> + * deadlock */
> +if ((ngroups = virGetGroupList(virCommandGetUID(cmd), 
> virCommandGetGID(cmd),
> +   )) < 0)
> +goto cleanup;
> +
>  ret = 0;
>   cleanup:
>  VIR_FREE(ttyPath);
> @@ -2307,7 +2316,7 @@ static int lxcContainerChild(void *data)
>  if (ret == 0) {
>  VIR_DEBUG("Executing init binary");
>  /* this function will only return if an error occurred */
> -ret = virCommandExec(cmd);
> +ret = virCommandExec(cmd, groups, ngroups);
>  }
>  
>  if (ret != 0) {
> @@ -2317,6 +2326,7 @@ static int lxcContainerChild(void *data)
>  virGetLastErrorMessage());
>  }
>  
> +VIR_FREE(groups);
>  virCommandFree(cmd);
>  return ret;
>  }
> diff --git a/src/util/vircommand.c b/src/util/vircommand.c
> index fba73ca18eac..41a61da49f82 100644
> --- a/src/util/vircommand.c
> +++ b/src/util/vircommand.c
> @@ -465,15 +465,10 @@ virCommandHandshakeChild(virCommandPtr cmd)
>  }
>  
>  static int
> -virExecCommon(virCommandPtr cmd)
> +virExecCommon(virCommandPtr cmd, gid_t *groups, int ngroups)
>  {
> -gid_t *groups = NULL;
> -int ngroups;
>  int ret = -1;
>  
> -if ((ngroups = virGetGroupList(cmd->uid, cmd->gid, )) < 0)
> -goto cleanup;
> -
>  if (cmd->uid != (uid_t)-1 || cmd->gid != (gid_t)-1 ||
>  cmd->capabilities || (cmd->flags & VIR_EXEC_CLEAR_CAPS)) {
>  VIR_DEBUG("Setting child uid:gid to %d:%d with caps %llx",
> @@ -495,7 +490,6 @@ virExecCommon(virCommandPtr cmd)
>  ret = 0;
>  
>   cleanup:
> -VIR_FREE(groups);
>  return ret;
>  }
>  
> @@ -519,6 +513,8 @@ virExec(virCommandPtr cmd)
>  const char *binary = NULL;
>  int ret;
>  struct sigaction waxon, waxoff;
> +gid_t *groups = NULL;
> +int ngroups;
>  
>  if (cmd->args[0][0] != '/') {
>  if (!(binary = binarystr = virFindFileInPath(cmd->args[0]))) {
> @@ -589,6 +585,9 @@ virExec(virCommandPtr cmd)
>  childerr = null;
>  }
>  
> +if ((ngroups = virGetGroupList(cmd->uid, cmd->gid, )) < 0)
> +goto cleanup;
> +
>  pid = virFork();
>  
>  if (pid < 0)
> @@ -756,7 +755,7 @@ virExec(virCommandPtr cmd)
>  }
>  # endif
>  
> -if (virExecCommon(cmd) < 0)
> +if (virExecCommon(cmd, groups, ngroups) < 0)
>  goto fork_error;
>  
>  if (virCommandHandshakeChild(cmd) < 0)
> @@ -799,6 +798,7 @@ virExec(virCommandPtr cmd)
> should never jump here on error */
>  
>  VIR_FREE(binarystr);
> +VIR_FREE(groups);
>  
>  /* NB we don't virReportError() on any failures here
> because the code which jumped here already raised
> @@ -2167,6 +2167,8 @@ virCommandProcessIO(virCommandPtr cmd)
>  /**
>   * virCommandExec:
>   * @cmd: command to run
> + * @groups: array of supplementary group IDs used for the command
> + * @ngroups: number of group IDs in @groups
>   *
>   * Exec the command, replacing the current process. Meant to be called
>   * in the hook after already forking / cloning, so does not attempt to
> @@ -2176,7 +2178,7 @@ virCommandProcessIO(virCommandPtr cmd)
>   * Will not return on success.
>   */
>  #ifndef WIN32
> -int virCommandExec(virCommandPtr cmd)
> +int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups)
>  {
>  if (!cmd 

[libvirt] [RFC PATCH 2/4] util: Fix deadlock across fork()

2017-10-09 Thread Marc Hartmayer
This commit fixes the deadlock introduced by commit
0980764dee687e8da86dc410c351759867163389. The call getgrouplist() of
the glibc library isn't safe to be called in between fork and
exec (see commit 75c125641ac73473ba4b0542524d67a184769c8e).

Signed-off-by: Marc Hartmayer 
Fixes: 0980764dee68 ("util: share code between virExec and virCommandExec")
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/lxc/lxc_container.c | 12 +++-
 src/util/vircommand.c   | 25 ++---
 src/util/vircommand.h   |  2 +-
 tests/commandtest.c | 15 ++-
 4 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index ec6d6a86b0b6..1f220c602b0a 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -2182,6 +2182,8 @@ static int lxcContainerChild(void *data)
 virDomainFSDefPtr root;
 virCommandPtr cmd = NULL;
 int hasReboot;
+gid_t *groups = NULL;
+int ngroups;
 
 if (NULL == vmDef) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -2297,6 +2299,13 @@ static int lxcContainerChild(void *data)
 goto cleanup;
 }
 
+/* TODO is it safe to call it here or should this call be moved in
+ * front of the clone() as otherwise there might be a risk for a
+ * deadlock */
+if ((ngroups = virGetGroupList(virCommandGetUID(cmd), 
virCommandGetGID(cmd),
+   )) < 0)
+goto cleanup;
+
 ret = 0;
  cleanup:
 VIR_FREE(ttyPath);
@@ -2307,7 +2316,7 @@ static int lxcContainerChild(void *data)
 if (ret == 0) {
 VIR_DEBUG("Executing init binary");
 /* this function will only return if an error occurred */
-ret = virCommandExec(cmd);
+ret = virCommandExec(cmd, groups, ngroups);
 }
 
 if (ret != 0) {
@@ -2317,6 +2326,7 @@ static int lxcContainerChild(void *data)
 virGetLastErrorMessage());
 }
 
+VIR_FREE(groups);
 virCommandFree(cmd);
 return ret;
 }
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index fba73ca18eac..41a61da49f82 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -465,15 +465,10 @@ virCommandHandshakeChild(virCommandPtr cmd)
 }
 
 static int
-virExecCommon(virCommandPtr cmd)
+virExecCommon(virCommandPtr cmd, gid_t *groups, int ngroups)
 {
-gid_t *groups = NULL;
-int ngroups;
 int ret = -1;
 
-if ((ngroups = virGetGroupList(cmd->uid, cmd->gid, )) < 0)
-goto cleanup;
-
 if (cmd->uid != (uid_t)-1 || cmd->gid != (gid_t)-1 ||
 cmd->capabilities || (cmd->flags & VIR_EXEC_CLEAR_CAPS)) {
 VIR_DEBUG("Setting child uid:gid to %d:%d with caps %llx",
@@ -495,7 +490,6 @@ virExecCommon(virCommandPtr cmd)
 ret = 0;
 
  cleanup:
-VIR_FREE(groups);
 return ret;
 }
 
@@ -519,6 +513,8 @@ virExec(virCommandPtr cmd)
 const char *binary = NULL;
 int ret;
 struct sigaction waxon, waxoff;
+gid_t *groups = NULL;
+int ngroups;
 
 if (cmd->args[0][0] != '/') {
 if (!(binary = binarystr = virFindFileInPath(cmd->args[0]))) {
@@ -589,6 +585,9 @@ virExec(virCommandPtr cmd)
 childerr = null;
 }
 
+if ((ngroups = virGetGroupList(cmd->uid, cmd->gid, )) < 0)
+goto cleanup;
+
 pid = virFork();
 
 if (pid < 0)
@@ -756,7 +755,7 @@ virExec(virCommandPtr cmd)
 }
 # endif
 
-if (virExecCommon(cmd) < 0)
+if (virExecCommon(cmd, groups, ngroups) < 0)
 goto fork_error;
 
 if (virCommandHandshakeChild(cmd) < 0)
@@ -799,6 +798,7 @@ virExec(virCommandPtr cmd)
should never jump here on error */
 
 VIR_FREE(binarystr);
+VIR_FREE(groups);
 
 /* NB we don't virReportError() on any failures here
because the code which jumped here already raised
@@ -2167,6 +2167,8 @@ virCommandProcessIO(virCommandPtr cmd)
 /**
  * virCommandExec:
  * @cmd: command to run
+ * @groups: array of supplementary group IDs used for the command
+ * @ngroups: number of group IDs in @groups
  *
  * Exec the command, replacing the current process. Meant to be called
  * in the hook after already forking / cloning, so does not attempt to
@@ -2176,7 +2178,7 @@ virCommandProcessIO(virCommandPtr cmd)
  * Will not return on success.
  */
 #ifndef WIN32
-int virCommandExec(virCommandPtr cmd)
+int virCommandExec(virCommandPtr cmd, gid_t *groups, int ngroups)
 {
 if (!cmd ||cmd->has_error == ENOMEM) {
 virReportOOMError();
@@ -2188,7 +2190,7 @@ int virCommandExec(virCommandPtr cmd)
 return -1;
 }
 
-if (virExecCommon(cmd) < 0)
+if (virExecCommon(cmd, groups, ngroups) < 0)
 return -1;
 
 execve(cmd->args[0], cmd->args, cmd->env);
@@ -2199,7 +2201,8 @@ int virCommandExec(virCommandPtr cmd)
 return -1;
 }
 #else
-int virCommandExec(virCommandPtr cmd ATTRIBUTE_UNUSED)
+int virCommandExec(virCommandPtr cmd 

[libvirt] [RFC PATCH 3/4] lxc: Fixed a typo

2017-10-09 Thread Marc Hartmayer
Signed-off-by: Marc Hartmayer 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/lxc/lxc_container.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 1f220c602b0a..5791a9b1f958 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -2167,7 +2167,7 @@ static int lxcContainerSetUserGroup(virCommandPtr cmd,
  * This function is run in the process clone()'d in lxcStartContainer.
  * Perform a number of container setup tasks:
  * Setup container file system
- * mount container /proca
+ * mount container /proc
  * Then exec's the container init
  *
  * Returns 0 on success or -1 in case of error
-- 
2.5.5

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


[libvirt] [RFC PATCH 0/4] Deadlock fix and some minor fixes

2017-10-09 Thread Marc Hartmayer
The first patch is a preparatory patch for the deadlock fix (patch
2). The cleanup path for 'virExecCommon' may now be superflous. 
Patches 3-4 are only minor fixes.

Important: there may still be a deadlock for LXC (see the TODO in
patch 2)

Marc Hartmayer (4):
  util: Add virCommandGetGID and virCommandGetUID
  util: Fix deadlock across fork()
  lxc: Fixed a typo
  lxc: Fixed indentation

 src/libvirt_private.syms |  2 ++
 src/lxc/lxc_container.c  | 20 +++-
 src/util/vircommand.c| 39 ---
 src/util/vircommand.h|  6 +-
 tests/commandtest.c  | 15 ++-
 5 files changed, 60 insertions(+), 22 deletions(-)

-- 
2.5.5

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


[libvirt] [RFC PATCH 1/4] util: Add virCommandGetGID and virCommandGetUID

2017-10-09 Thread Marc Hartmayer
These functions are used by an upcoming commit.

Signed-off-by: Marc Hartmayer 
Reviewed-by: Boris Fiuczynski 
---
 src/libvirt_private.syms |  2 ++
 src/util/vircommand.c| 14 ++
 src/util/vircommand.h|  4 
 3 files changed, 20 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9243c5591042..26c5ddb40505 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1506,6 +1506,8 @@ virCommandDaemonize;
 virCommandDoAsyncIO;
 virCommandExec;
 virCommandFree;
+virCommandGetGID;
+virCommandGetUID;
 virCommandHandshakeNotify;
 virCommandHandshakeWait;
 virCommandNew;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 60c1121dafea..fba73ca18eac 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -1073,6 +1073,20 @@ virCommandSetPidFile(virCommandPtr cmd, const char 
*pidfile)
 }
 
 
+gid_t
+virCommandGetGID(virCommandPtr cmd)
+{
+return cmd->gid;
+}
+
+
+uid_t
+virCommandGetUID(virCommandPtr cmd)
+{
+return cmd->uid;
+}
+
+
 void
 virCommandSetGID(virCommandPtr cmd, gid_t gid)
 {
diff --git a/src/util/vircommand.h b/src/util/vircommand.h
index e7c2e513bae1..b401d7b238d7 100644
--- a/src/util/vircommand.h
+++ b/src/util/vircommand.h
@@ -68,6 +68,10 @@ int virCommandPassFDGetFDIndex(virCommandPtr cmd,
 void virCommandSetPidFile(virCommandPtr cmd,
   const char *pidfile) ATTRIBUTE_NONNULL(2);
 
+gid_t virCommandGetGID(virCommandPtr cmd) ATTRIBUTE_NONNULL(1);
+
+uid_t virCommandGetUID(virCommandPtr cmd) ATTRIBUTE_NONNULL(1);
+
 void virCommandSetGID(virCommandPtr cmd, gid_t gid);
 
 void virCommandSetUID(virCommandPtr cmd, uid_t uid);
-- 
2.5.5

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


[libvirt] [RFC PATCH 4/4] lxc: Fixed indentation

2017-10-09 Thread Marc Hartmayer
Signed-off-by: Marc Hartmayer 
Reviewed-by: Bjoern Walk 
Reviewed-by: Boris Fiuczynski 
---
 src/lxc/lxc_container.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 5791a9b1f958..b7216d6ee863 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -2254,8 +2254,8 @@ static int lxcContainerChild(void *data)
 
 if (!virFileExists(vmDef->os.init)) {
 virReportSystemError(errno,
-_("cannot find init path '%s' relative to container root"),
-vmDef->os.init);
+ _("cannot find init path '%s' relative to 
container root"),
+ vmDef->os.init);
 goto cleanup;
 }
 
@@ -2275,7 +2275,7 @@ static int lxcContainerChild(void *data)
 
 if (lxcContainerSendContinue(argv->handshakefd) < 0) {
 virReportSystemError(errno, "%s",
-_("Failed to send continue signal to controller"));
+ _("Failed to send continue signal to 
controller"));
 goto cleanup;
 }
 
-- 
2.5.5

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


[libvirt] [PATCH 2/2] secrets: Introduce virSecretObjListForEachCb

2017-10-09 Thread John Ferlan
Rather than separate functions for NumOfSecrets, GetUUIDs, and
ListExport - let's converge the code into one handler.

Signed-off-by: John Ferlan 
---
 src/conf/virsecretobj.c | 167 
 1 file changed, 54 insertions(+), 113 deletions(-)

diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 47e0b28968..6046547875 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -410,64 +410,41 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
 }
 
 
-struct virSecretCountData {
+typedef bool
+(*virSecretObjListMatchFilter)(virSecretObjPtr obj, unsigned int flags);
+struct _virSecretForEachData {
 virConnectPtr conn;
 virSecretObjListACLFilter filter;
-int count;
-};
-
-static int
-virSecretObjListNumOfSecretsCallback(void *payload,
- const void *name ATTRIBUTE_UNUSED,
- void *opaque)
-{
-struct virSecretCountData *data = opaque;
-virSecretObjPtr obj = payload;
-virSecretDefPtr def;
-
-virObjectLock(obj);
-def = obj->def;
-
-if (data->filter && !data->filter(data->conn, def))
-goto cleanup;
-
-data->count++;
-
- cleanup:
-virObjectUnlock(obj);
-return 0;
-}
-
-
-struct virSecretListData {
-virConnectPtr conn;
-virSecretObjListACLFilter filter;
-int nuuids;
-char **uuids;
-int maxuuids;
+virSecretObjListMatchFilter match;
+unsigned int flags;
 bool error;
+int nElems;
+int maxElems;
+char **uuids;
+virSecretPtr *secrets;
 };
 
-
 static int
-virSecretObjListGetUUIDsCallback(void *payload,
- const void *name ATTRIBUTE_UNUSED,
- void *opaque)
+virSecretObjListForEachCb(void *payload,
+  const void *name ATTRIBUTE_UNUSED,
+  void *opaque)
 {
-struct virSecretListData *data = opaque;
+struct _virSecretForEachData *data = opaque;
 virSecretObjPtr obj = payload;
-virSecretDefPtr def;
+virSecretPtr secret = NULL;
 
 if (data->error)
 return 0;
 
-if (data->maxuuids >= 0 && data->nuuids == data->maxuuids)
+if (data->maxElems >= 0 && data->nElems == data->maxElems)
 return 0;
 
 virObjectLock(obj);
-def = obj->def;
 
-if (data->filter && !data->filter(data->conn, def))
+if (data->filter && !data->filter(data->conn, obj->def))
+goto cleanup;
+
+if (data->match && !data->match(obj, data->flags))
 goto cleanup;
 
 if (data->uuids) {
@@ -478,10 +455,20 @@ virSecretObjListGetUUIDsCallback(void *payload,
 goto cleanup;
 }
 
-virUUIDFormat(def->uuid, uuidstr);
-data->uuids[data->nuuids++] = uuidstr;
+virUUIDFormat(obj->def->uuid, uuidstr);
+data->uuids[data->nElems] = uuidstr;
+} else if (data->secrets) {
+if (!(secret = virGetSecret(data->conn, obj->def->uuid,
+obj->def->usage_type,
+obj->def->usage_id))) {
+data->error = true;
+goto cleanup;
+}
+data->secrets[data->nElems] = secret;
 }
 
+data->nElems++;
+
  cleanup:
 virObjectUnlock(obj);
 return 0;
@@ -493,14 +480,16 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secrets,
  virSecretObjListACLFilter filter,
  virConnectPtr conn)
 {
-struct virSecretCountData data = {
-.conn = conn, .filter = filter, .count = 0 };
+struct _virSecretForEachData data = {
+.conn = conn, .filter = filter, .match = NULL,
+.flags = 0, .error = false, .nElems = 0, .maxElems = -1,
+.uuids = NULL, .secrets = NULL };
 
 virObjectRWLockRead(secrets);
-virHashForEach(secrets->objs, virSecretObjListNumOfSecretsCallback, );
+virHashForEach(secrets->objs, virSecretObjListForEachCb, );
 virObjectRWUnlock(secrets);
 
-return data.count;
+return data.nElems;
 }
 
 
@@ -532,57 +521,6 @@ virSecretObjMatchFlags(virSecretObjPtr obj,
 #undef MATCH
 
 
-struct virSecretObjListData {
-virConnectPtr conn;
-virSecretPtr *secrets;
-virSecretObjListACLFilter filter;
-unsigned int flags;
-int nsecrets;
-bool error;
-};
-
-static int
-virSecretObjListExportCallback(void *payload,
-   const void *name ATTRIBUTE_UNUSED,
-   void *opaque)
-{
-struct virSecretObjListData *data = opaque;
-virSecretObjPtr obj = payload;
-virSecretDefPtr def;
-virSecretPtr secret = NULL;
-
-if (data->error)
-return 0;
-
-virObjectLock(obj);
-def = obj->def;
-
-if (data->filter && !data->filter(data->conn, def))
-goto cleanup;
-
-if (!virSecretObjMatchFlags(obj, data->flags))
-goto cleanup;
-
-if (!data->secrets) {
-

[libvirt] [PATCH 1/2] secrets: Convert to use ObjectRWLockable

2017-10-09 Thread John Ferlan
Let's use the ObjectRWLockable for the various list lock mgmt.
Only time need Write lock will be for Add/Remove logic.

Signed-off-by: John Ferlan 
---
 src/conf/virsecretobj.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
index 4dca152d48..47e0b28968 100644
--- a/src/conf/virsecretobj.c
+++ b/src/conf/virsecretobj.c
@@ -52,7 +52,7 @@ static void virSecretObjDispose(void *obj);
 static void virSecretObjListDispose(void *obj);
 
 struct _virSecretObjList {
-virObjectLockable parent;
+virObjectRWLockable parent;
 
 /* uuid string -> virSecretObj  mapping
  * for O(1), lockless lookup-by-uuid */
@@ -74,7 +74,7 @@ virSecretObjOnceInit(void)
   virSecretObjDispose)))
 return -1;
 
-if (!(virSecretObjListClass = virClassNew(virClassForObjectLockable(),
+if (!(virSecretObjListClass = virClassNew(virClassForObjectRWLockable(),
   "virSecretObjList",
   sizeof(virSecretObjList),
   virSecretObjListDispose)))
@@ -123,7 +123,7 @@ virSecretObjListNew(void)
 if (virSecretObjInitialize() < 0)
 return NULL;
 
-if (!(secrets = virObjectLockableNew(virSecretObjListClass)))
+if (!(secrets = virObjectRWLockableNew(virSecretObjListClass)))
 return NULL;
 
 if (!(secrets->objs = virHashCreate(50, virObjectFreeHashData))) {
@@ -193,9 +193,9 @@ virSecretObjListFindByUUID(virSecretObjListPtr secrets,
 {
 virSecretObjPtr obj;
 
-virObjectLock(secrets);
+virObjectRWLockRead(secrets);
 obj = virSecretObjListFindByUUIDLocked(secrets, uuidstr);
-virObjectUnlock(secrets);
+virObjectRWUnlock(secrets);
 if (obj)
 virObjectLock(obj);
 return obj;
@@ -272,9 +272,9 @@ virSecretObjListFindByUsage(virSecretObjListPtr secrets,
 {
 virSecretObjPtr obj;
 
-virObjectLock(secrets);
+virObjectRWLockRead(secrets);
 obj = virSecretObjListFindByUsageLocked(secrets, usageType, usageID);
-virObjectUnlock(secrets);
+virObjectRWUnlock(secrets);
 if (obj)
 virObjectLock(obj);
 return obj;
@@ -305,12 +305,12 @@ virSecretObjListRemove(virSecretObjListPtr secrets,
 virObjectRef(obj);
 virObjectUnlock(obj);
 
-virObjectLock(secrets);
+virObjectRWLockWrite(secrets);
 virObjectLock(obj);
 virHashRemoveEntry(secrets->objs, uuidstr);
 virObjectUnlock(obj);
 virObjectUnref(obj);
-virObjectUnlock(secrets);
+virObjectRWUnlock(secrets);
 }
 
 
@@ -336,7 +336,7 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
 virSecretObjPtr ret = NULL;
 char uuidstr[VIR_UUID_STRING_BUFLEN];
 
-virObjectLock(secrets);
+virObjectRWLockWrite(secrets);
 
 if (oldDef)
 *oldDef = NULL;
@@ -405,7 +405,7 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
 
  cleanup:
 virSecretObjEndAPI();
-virObjectUnlock(secrets);
+virObjectRWUnlock(secrets);
 return ret;
 }
 
@@ -496,9 +496,9 @@ virSecretObjListNumOfSecrets(virSecretObjListPtr secrets,
 struct virSecretCountData data = {
 .conn = conn, .filter = filter, .count = 0 };
 
-virObjectLock(secrets);
+virObjectRWLockRead(secrets);
 virHashForEach(secrets->objs, virSecretObjListNumOfSecretsCallback, );
-virObjectUnlock(secrets);
+virObjectRWUnlock(secrets);
 
 return data.count;
 }
@@ -595,15 +595,15 @@ virSecretObjListExport(virConnectPtr conn,
 .filter = filter, .flags = flags,
 .nsecrets = 0, .error = false };
 
-virObjectLock(secretobjs);
+virObjectRWLockRead(secretobjs);
 if (secrets &&
 VIR_ALLOC_N(data.secrets, virHashSize(secretobjs->objs) + 1) < 0) {
-virObjectUnlock(secretobjs);
+virObjectRWUnlock(secretobjs);
 return -1;
 }
 
 virHashForEach(secretobjs->objs, virSecretObjListExportCallback, );
-virObjectUnlock(secretobjs);
+virObjectRWUnlock(secretobjs);
 
 if (data.error)
 goto error;
@@ -633,9 +633,9 @@ virSecretObjListGetUUIDs(virSecretObjListPtr secrets,
 .conn = conn, .filter = filter, .uuids = uuids, .nuuids = 0,
 .maxuuids = maxuuids, .error = false };
 
-virObjectLock(secrets);
+virObjectRWLockRead(secrets);
 virHashForEach(secrets->objs, virSecretObjListGetUUIDsCallback, );
-virObjectUnlock(secrets);
+virObjectRWUnlock(secrets);
 
 if (data.error)
 goto error;
-- 
2.13.6

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


[libvirt] [PATCH 0/2] Tie up a couple of secretobjs loose ends

2017-10-09 Thread John Ferlan
Patches should speak for themselves.

John Ferlan (2):
  secrets: Convert to use ObjectRWLockable
  secrets: Introduce virSecretObjListForEachCb

 src/conf/virsecretobj.c | 203 +---
 1 file changed, 72 insertions(+), 131 deletions(-)

-- 
2.13.6

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


[libvirt] [PATCH v3] qemu: argv: parse qemu commandline memory arguments

2017-10-09 Thread Kothapally Madhu Pavan
Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
format along with existing format. And adds a testcase to validate the changes.

Signed-off-by: Kothapally Madhu Pavan 
---
 src/qemu/qemu_parse_command.c  | 89 +++---
 .../qemuargv2xml-mem-scale-maxmemory.args  | 22 ++
 .../qemuargv2xml-mem-scale-maxmemory.xml   | 38 +
 tests/qemuargv2xmltest.c   |  1 +
 4 files changed, 138 insertions(+), 12 deletions(-)
 create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
 create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.xml

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 37e1149..cd2a32a 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1629,26 +1629,91 @@ static int
 qemuParseCommandLineMem(virDomainDefPtr dom,
 const char *val)
 {
-unsigned long long mem;
+unsigned long long mem = 0;
+unsigned long long size = 0;
+unsigned long long maxmem = 0;
+unsigned int slots = 0;
 char *end;
+size_t i;
+int nkws;
+char **kws;
+char **vals;
+int n;
+int ret = -1;
 
-if (virStrToLong_ull(val, , 10, ) < 0) {
+if (qemuParseKeywords(val, , , , 1) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot parse memory level '%s'"), val);
-return -1;
+   _("cannot parse memory '%s'"), val);
+goto cleanup;
 }
 
-if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot scale memory: %s"),
-   virGetLastErrorMessage());
-return -1;
+for (i = 0; i < nkws; i++) {
+if (vals[i] == NULL) {
+if (i > 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory '%s'"), val);
+goto cleanup;
+}
+if (virStrToLong_ull(kws[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory level '%s'"), kws[i]);
+goto cleanup;
+}
+if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot scale memory: %s"),
+   virGetLastErrorMessage());
+goto cleanup;
+}
+
+size = mem;
+
+} else {
+if (STREQ(kws[i], "size") || STREQ(kws[i], "maxmem")) {
+if (virStrToLong_ull(vals[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory level '%s'"), 
vals[i]);
+goto cleanup;
+}
+if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot scale memory: %s"),
+   virGetLastErrorMessage());
+goto cleanup;
+}
+
+STREQ(kws[i], "size") ? (size = mem) : (maxmem = mem);
+
+}
+if (STREQ(kws[i], "slots")) {
+if (virStrToLong_i(vals[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse slots value '%s'"), 
vals[i]);
+goto cleanup;
+}
+
+   slots = n;
+
+}
+}
 }
 
-virDomainDefSetMemoryTotal(dom, mem / 1024);
-dom->mem.cur_balloon = mem / 1024;
+virDomainDefSetMemoryTotal(dom, size / 1024);
+dom->mem.cur_balloon = size / 1024;
+dom->mem.memory_slots = slots;
+dom->mem.max_memory = maxmem / 1024;
 
-return 0;
+ret = 0;
+
+ cleanup:
+for (i = 0; i < nkws; i++) {
+VIR_FREE(kws[i]);
+VIR_FREE(vals[i]);
+}
+VIR_FREE(kws);
+VIR_FREE(vals);
+
+return ret;
 }
 
 
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args 
b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
new file mode 100644
index 000..7bce841
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 8G,slots=16,maxmem=16G \
+-smp 1,maxcpus=2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive 

Re: [libvirt] [question]Why libvirt bind all devices with same vendor id and device id to vfio-pci driver, and only unbind devices used by VMs to original driver?

2017-10-09 Thread Alex Williamson
On Mon, 9 Oct 2017 09:28:27 +
"Wuzongyong (Euler Dept)"  wrote:

> Hi,
> 
> As the title says, I thought that it's a bit unreasonable and inconsistent  
> to unbind devices assigned to VMs to original driver
> and leave other devices binding to vfio-pci driver.
> Why not to bind devices we need to vfio-pci driver instead of bind all 
> devices with same type to vfio-pci driver?
> Or, we may can rebind devices unused with same type to original driver.


Because that's the way the kernel's new_id interface works, any
matching device without a driver will probe the new_id driver.  For a
new enough kernel and libvirt, the driver_override interface should be
used instead, which will only bind the target device.  Thanks,

Alex

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


Re: [libvirt] gnulib tests in libvirt broken by newer glibc 2.26

2017-10-09 Thread Bruno Haible
Daniel P. Berrange wrote:
> Tested-by: Daniel P. Berrange 
> 
> 
> Confirmed it fixes the failure on Fedora 28, and does not cause a regression
> on Fedora 26 with older glibc.

Thanks. Pushing it:


2017-10-09  Bruno Haible  

getopt-posix: Fix build failure when using ac_cv_header_getopt_h=no.
Reported by Christian Ehrhardt 
and Daniel P. Berrange .
* lib/unistd.in.h (getopt): Don't attempt to avoid namespace pollution
on glibc systems. The getopt-pfx-core.h file declares exactly what
unistd.h needs, nothing more.

diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index 748112f..b5b6e0e 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -134,9 +134,8 @@
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
 
-/* Get getopt(), optarg, optind, opterr, optopt.
-   But avoid namespace pollution on glibc systems.  */
-#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined 
_GL_SYSTEM_GETOPT
+/* Get getopt(), optarg, optind, opterr, optopt.  */
+#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
 # include 
 # include 
 #endif

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


Re: [libvirt] [PATCH] numa: avoid failure in nodememstats on non-NUMA systems

2017-10-09 Thread Boris Fiuczynski

Looks good to me.

On 09/22/2017 04:12 PM, Viktor Mihajlovski wrote:

libvirt reports a fake NUMA topology in virConnectGetCapabilities
even if built without numactl support. The fake NUMA topology consists
of a single cell representing the host's cpu and memory resources.
Currently this is the case for ARM and s390[x] RPM builds.

A client iterating over NUMA cells obtained via virConnectGetCapabilities
and invoking virNodeGetMemoryStats on them will see an internal failure
"NUMA isn't available on this host". An example for such a client is
VDSM.

Since the intention seems to be that libvirt always reports at least
a single cell it is necessary to return "fake" node memory statistics
matching the previously reported fake cell in case NUMA isn't supported
on the system.

Signed-off-by: Viktor Mihajlovski 
---
  src/util/virhostmem.c | 8 
  1 file changed, 8 insertions(+)

diff --git a/src/util/virhostmem.c b/src/util/virhostmem.c
index a9ba278..fa04a37 100644
--- a/src/util/virhostmem.c
+++ b/src/util/virhostmem.c
@@ -267,6 +267,14 @@ virHostMemGetStats(int cellNum ATTRIBUTE_UNUSED,
  FILE *meminfo;
  int max_node;

+/*
+ * Even if built without numactl, libvirt claims
+ * to have a one-cells NUMA topology. In such a
+ * case return the statistics for the entire host.
+ */
+if (!virNumaIsAvailable() && cellNum == 0)
+cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
+
  if (cellNum == VIR_NODE_MEMORY_STATS_ALL_CELLS) {
  if (VIR_STRDUP(meminfo_path, MEMINFO_PATH) < 0)
  return -1;




--
Mit freundlichen Grüßen/Kind regards
   Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Köderitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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

Re: [libvirt] [libvit-jenkins-ci PATCH v2 00/16] Ansible all the things!

2017-10-09 Thread Daniel P. Berrange
On Mon, Oct 09, 2017 at 01:58:45PM +0200, Andrea Bolognani wrote:
> On Mon, 2017-10-09 at 11:39 +0100, Daniel P. Berrange wrote:
> > On Fri, Oct 06, 2017 at 02:48:36PM +0200, Andrea Bolognani wrote:
> > > Changes from [v1]:
> > > 
> > >   * drop support for building projects;
> > >   * reduce redundancy by using mappings;
> > >   * add FreeBSD 10 support.
> > > 
> > > [v1] 
> > > https://www.redhat.com/archives/libvir-list/2017-October/msg00035.html
> > > 
> > > Andrea Bolognani (16):
> > >   ansible: Initial support
> > >   ansible: Add libosinfo project
> > >   ansible: Add libvirt project
> > >   ansible: Add libvirt-cim project
> > >   ansible: Add libvirt-glib project
> > >   ansible: Add libvirt-go project
> > >   ansible: Add libvirt-go-xml project
> > >   ansible: Add libvirt-perl project
> > >   ansible: Add libvirt-python project
> > >   ansible: Add libvirt-sandbox project
> > >   ansible: Add libvirt-tck project
> > >   ansible: Add osinfo-db project
> > >   ansible: Add osinfo-db-tools project
> > >   ansible: Add virt-manager project
> > >   ansible: Add virt-viewer project
> > >   ansible: Install and configure Jenkins agent
> > 
> > ACK to all patches on the basis that I don't know ansible but nothing
> > looks bad from a naive POV.
> 
> That's good enough for me. Pushed :)
> 
> > One thing the current builders have setup is a cron job to do a nightly
> > yum update (or equiv). I'm not sure whether this belongs in Ansible or
> > in prior kickstart file ?
> 
> Oh, I was not aware of that.
> 
> There are two ways we can approach this:
> 
>   a) have Ansible set up the necessary cron jobs;
>   b) run the Ansible playbook from the host instead.
> 
> I'd rather go with b) since the playbook already upgrades all
> installed packages as part of setting up the base system.

I dont mind as long as the packages get updated daily.

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


[libvirt] [PATCH v2] qemu: argv: parse qemu commandline memory arguments

2017-10-09 Thread Kothapally Madhu Pavan
Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
format along with existing format. And adds a testcase to validate the changes.

Signed-off-by: Kothapally Madhu Pavan 
---
 src/qemu/qemu_parse_command.c  | 89 +++---
 .../qemuargv2xml-mem-scale-maxmemory.args  | 22 ++
 .../qemuargv2xml-mem-scale-maxmemory.xml   | 38 +
 tests/qemuargv2xmltest.c   |  1 +
 4 files changed, 138 insertions(+), 12 deletions(-)
 create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
 create mode 100644 tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.xml

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 37e1149..f8b6f8b 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1629,26 +1629,91 @@ static int
 qemuParseCommandLineMem(virDomainDefPtr dom,
 const char *val)
 {
-unsigned long long mem;
+unsigned long long mem = 0;
+unsigned long long size = 0;
+unsigned long long maxmem = 0;
+unsigned int slots = 0;
 char *end;
+size_t i;
+int nkws;
+char **kws;
+char **vals;
+int n;
+int ret = -1;
 
-if (virStrToLong_ull(val, , 10, ) < 0) {
+if (qemuParseKeywords(val, , , , 1) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot parse memory level '%s'"), val);
-return -1;
+   _("cannot parse memory '%s'"), val);
+goto cleanup;
 }
 
-if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot scale memory: %s"),
-   virGetLastErrorMessage());
-return -1;
+for (i = 0; i < nkws; i++) {
+if (vals[i] == NULL) {
+if (i > 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory '%s'"), val);
+goto cleanup;
+}
+if (virStrToLong_ull(kws[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory level '%s'"), kws[i]);
+goto cleanup;
+}
+if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot scale memory: %s"),
+   virGetLastErrorMessage());
+goto cleanup;
+}
+
+size = mem;
+
+} else {
+if (STREQ(kws[i], "size") || STREQ(kws[i], "maxmem")) {
+if (virStrToLong_ull(vals[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory level '%s'"), 
vals[i]);
+goto cleanup;
+}
+if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot scale memory: %s"),
+   virGetLastErrorMessage());
+goto cleanup;
+}
+
+STREQ(kws[i], "size") ? (size = mem) : (maxmem = mem);
+
+}
+if (STREQ(kws[i], "slots")) {
+if (virStrToLong_i(vals[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse slots value '%s'"), 
vals[i]);
+goto cleanup;
+}
+
+   slots = n;
+
+}
+}
 }
 
-virDomainDefSetMemoryTotal(dom, mem / 1024);
-dom->mem.cur_balloon = mem / 1024;
+virDomainDefSetMemoryTotal(dom, size / 1024);
+dom->mem.cur_balloon = size / 1024;
+dom->mem.memory_slots = slots;
+dom->mem.max_memory = maxmem;
 
-return 0;
+ret = 0;
+
+ cleanup:
+for (i = 0; i < nkws; i++) {
+VIR_FREE(kws[i]);
+VIR_FREE(vals[i]);
+}
+VIR_FREE(kws);
+VIR_FREE(vals);
+
+return ret;
 }
 
 
diff --git a/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args 
b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
new file mode 100644
index 000..7bce841
--- /dev/null
+++ b/tests/qemuargv2xmldata/qemuargv2xml-mem-scale-maxmemory.args
@@ -0,0 +1,22 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-i686 \
+-name QEMUGuest1 \
+-S \
+-M pc \
+-m 8G,slots=16,maxmem=16G \
+-smp 1,maxcpus=2,sockets=2,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-monitor unix:/tmp/test-monitor,server,nowait \
+-no-acpi \
+-boot c \
+-usb \
+-drive 

Re: [libvirt] [libvit-jenkins-ci PATCH v2 00/16] Ansible all the things!

2017-10-09 Thread Andrea Bolognani
On Mon, 2017-10-09 at 11:39 +0100, Daniel P. Berrange wrote:
> On Fri, Oct 06, 2017 at 02:48:36PM +0200, Andrea Bolognani wrote:
> > Changes from [v1]:
> > 
> >   * drop support for building projects;
> >   * reduce redundancy by using mappings;
> >   * add FreeBSD 10 support.
> > 
> > [v1] https://www.redhat.com/archives/libvir-list/2017-October/msg00035.html
> > 
> > Andrea Bolognani (16):
> >   ansible: Initial support
> >   ansible: Add libosinfo project
> >   ansible: Add libvirt project
> >   ansible: Add libvirt-cim project
> >   ansible: Add libvirt-glib project
> >   ansible: Add libvirt-go project
> >   ansible: Add libvirt-go-xml project
> >   ansible: Add libvirt-perl project
> >   ansible: Add libvirt-python project
> >   ansible: Add libvirt-sandbox project
> >   ansible: Add libvirt-tck project
> >   ansible: Add osinfo-db project
> >   ansible: Add osinfo-db-tools project
> >   ansible: Add virt-manager project
> >   ansible: Add virt-viewer project
> >   ansible: Install and configure Jenkins agent
> 
> ACK to all patches on the basis that I don't know ansible but nothing
> looks bad from a naive POV.

That's good enough for me. Pushed :)

> One thing the current builders have setup is a cron job to do a nightly
> yum update (or equiv). I'm not sure whether this belongs in Ansible or
> in prior kickstart file ?

Oh, I was not aware of that.

There are two ways we can approach this:

  a) have Ansible set up the necessary cron jobs;
  b) run the Ansible playbook from the host instead.

I'd rather go with b) since the playbook already upgrades all
installed packages as part of setting up the base system.

-- 
Andrea Bolognani / Red Hat / Virtualization

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


Re: [libvirt] [libvirt-jenkins-ci PATCH v2 16/16] ansible: Install and configure Jenkins agent

2017-10-09 Thread Andrea Bolognani
On Mon, 2017-10-09 at 11:38 +0100, Daniel P. Berrange wrote:
> On Fri, Oct 06, 2017 at 02:48:52PM +0200, Andrea Bolognani wrote:
> > The agent is downloaded and configured to start at boot. The
> > secrets needed to prove the workers' identity to the Jenkins server
> > are stored inside Ansible vaults.
> > 
> > Signed-off-by: Andrea Bolognani 
> 
> > diff --git a/ansible/host_vars/libvirt-centos-6/vault.yml 
> > b/ansible/host_vars/libvirt-centos-6/vault.yml
> > new file mode 100644
> > index 000..2522a28
> > --- /dev/null
> > +++ b/ansible/host_vars/libvirt-centos-6/vault.yml
> > @@ -0,0 +1,10 @@
> > +$ANSIBLE_VAULT;1.1;AES256
> > +33376164643732313335383930346630343432643939303864313631353063636663663634616638
> > +3062306563323630653033656231373634363932336331620a383065336664343663346562353862
> > +64616131656633653338316232303562363632643530313961316130303335626235653430326530
> > +3566363365323830660a363063623035333231396337393537626161363634313637323563643161
> > +36613030333563363630363730656238646138306236643937623266646639616130343734313566
> > +61356165383464323434333836333030336464326436373731313439626161653931626431343665
> > +3030623633313334656430636363366132323132323039356264636465333630653335396662
> > +38356334386337386135343463323233666432326361656438333961303237353562656339623264
> > +3765
> 
> What is this data & how was it generated ? How is it decrypted ? Presumably
> there's some local key we're not publishing ?

It just contains the secret used by the Jenkins agent to authenticate
with the Jenkins server. Each of the files look like

  ---
  vault_jenkins_secret: "IT'S A SECRET TO EVERYBODY"

once decrypted; the main variables file for the host references the
encrypted variable with

  jenkins_secret: '{{ vault_jenkins_secret }}'

so there is a visible trail to the vaulted variable, and only the
jenkins_secret variable is used anywhere else as per best practices.

The file was created and can be edited using ansible-vault; the vault
password is retrieved automatically from the user's home directory
thanks to the line

  vault_password_file = ~/.ansible/libvirt-jenkins-ci.vault-password

being present in the ansible.cfg file. I have already transmitted
the vault password using an encrypted side-channel :)

-- 
Andrea Bolognani / Red Hat / Virtualization

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


Re: [libvirt] [PATCH] qemu: Changes in parsing qemu commandline memory section

2017-10-09 Thread Madhu Pavan



On 10/09/2017 04:34 PM, Daniel P. Berrange wrote:

On Mon, Oct 09, 2017 at 04:32:38PM +0530, Kothapally Madhu Pavan wrote:

Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
format along with existing format.

Signed-off-by: Kothapally Madhu Pavan 
---
  src/qemu/qemu_parse_command.c | 89 +--
  1 file changed, 77 insertions(+), 12 deletions(-)

This needs to have a corresponding  addition to tests/qemuargv2xmltest.c to
validate the code is operating correctly.

Sure. I will add it and post a v2.

Thanks,
Madhu.

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


Re: [libvirt] [PATCH] qemu: Changes in parsing qemu commandline memory section

2017-10-09 Thread Daniel P. Berrange
On Mon, Oct 09, 2017 at 04:32:38PM +0530, Kothapally Madhu Pavan wrote:
> Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
> This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
> format along with existing format.
> 
> Signed-off-by: Kothapally Madhu Pavan 
> ---
>  src/qemu/qemu_parse_command.c | 89 
> +--
>  1 file changed, 77 insertions(+), 12 deletions(-)

This needs to have a corresponding  addition to tests/qemuargv2xmltest.c to
validate the code is operating correctly.


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


[libvirt] [PATCH] qemu: Changes in parsing qemu commandline memory section

2017-10-09 Thread Kothapally Madhu Pavan
Existing qemuParseCommandLineMem() will parse "-m 4G" format string.
This patch allows it to parse "-m size=8126464k,slots=32,maxmem=33554432k"
format along with existing format.

Signed-off-by: Kothapally Madhu Pavan 
---
 src/qemu/qemu_parse_command.c | 89 +--
 1 file changed, 77 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c
index 37e1149..c30e8ed 100644
--- a/src/qemu/qemu_parse_command.c
+++ b/src/qemu/qemu_parse_command.c
@@ -1629,26 +1629,91 @@ static int
 qemuParseCommandLineMem(virDomainDefPtr dom,
 const char *val)
 {
-unsigned long long mem;
+unsigned long long mem = 0;
+unsigned long long size = 0;
+unsigned long long maxmem = 0;
+unsigned int slots = 0;
 char *end;
+size_t i;
+int nkws;
+char **kws;
+char **vals;
+int n;
+int ret = -1;
 
-if (virStrToLong_ull(val, , 10, ) < 0) {
+if (qemuParseKeywords(val, , , , 1) < 0) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot parse memory level '%s'"), val);
-return -1;
+   _("cannot parse memory '%s'"), val);
+goto cleanup;
 }
 
-if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _("cannot scale memory: %s"),
-   virGetLastErrorMessage());
-return -1;
+for (i = 0; i < nkws; i++) {
+if (vals[i] == NULL) {
+if (i > 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory '%s'"), val);
+goto cleanup;
+}
+if (virStrToLong_ull(kws[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory level '%s'"), kws[i]);
+goto cleanup;
+}
+if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot scale memory: %s"),
+   virGetLastErrorMessage());
+goto cleanup;
+}
+
+size = mem;
+
+} else {
+if (STREQ(kws[i], "size") || STREQ(kws[i], "maxmem")) {
+if (virStrToLong_ull(vals[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse memory level '%s'"), 
vals[i]);
+goto cleanup;
+}
+if (virScaleInteger(, end, 1024*1024, ULLONG_MAX) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot scale memory: %s"),
+   virGetLastErrorMessage());
+goto cleanup;
+}
+
+STREQ(kws[i], "size") ? (size = mem) : (maxmem = mem);
+
+}
+if (STREQ(kws[i], "slots")) {
+if (virStrToLong_i(vals[i], , 10, ) < 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("cannot parse slots value '%s'"), 
vals[i]);
+goto cleanup;
+}
+ 
+   slots = n;
+
+}
+}
 }
 
-virDomainDefSetMemoryTotal(dom, mem / 1024);
-dom->mem.cur_balloon = mem / 1024;
+virDomainDefSetMemoryTotal(dom, size / 1024);
+dom->mem.cur_balloon = size / 1024;
+dom->mem.memory_slots = slots;
+dom->mem.max_memory = maxmem;
 
-return 0;
+ret = 0;
+
+ cleanup:
+for (i = 0; i < nkws; i++) {
+VIR_FREE(kws[i]);
+VIR_FREE(vals[i]);
+}
+VIR_FREE(kws);
+VIR_FREE(vals);
+
+return ret;
 }
 
 
-- 
1.8.3.1

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


Re: [libvirt] [libvirt-jenkins-ci PATCH v2 16/16] ansible: Install and configure Jenkins agent

2017-10-09 Thread Daniel P. Berrange
On Fri, Oct 06, 2017 at 02:48:52PM +0200, Andrea Bolognani wrote:
> The agent is downloaded and configured to start at boot. The
> secrets needed to prove the workers' identity to the Jenkins server
> are stored inside Ansible vaults.
> 
> Signed-off-by: Andrea Bolognani 


> diff --git a/ansible/host_vars/libvirt-centos-6/vault.yml 
> b/ansible/host_vars/libvirt-centos-6/vault.yml
> new file mode 100644
> index 000..2522a28
> --- /dev/null
> +++ b/ansible/host_vars/libvirt-centos-6/vault.yml
> @@ -0,0 +1,10 @@
> +$ANSIBLE_VAULT;1.1;AES256
> +33376164643732313335383930346630343432643939303864313631353063636663663634616638
> +3062306563323630653033656231373634363932336331620a383065336664343663346562353862
> +64616131656633653338316232303562363632643530313961316130303335626235653430326530
> +3566363365323830660a363063623035333231396337393537626161363634313637323563643161
> +36613030333563363630363730656238646138306236643937623266646639616130343734313566
> +61356165383464323434333836333030336464326436373731313439626161653931626431343665
> +3030623633313334656430636363366132323132323039356264636465333630653335396662
> +38356334386337386135343463323233666432326361656438333961303237353562656339623264
> +3765

What is this data & how was it generated ? How is it decrypted ? Presumably
there's some local key we're not publishing ?


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] [libvit-jenkins-ci PATCH v2 00/16] Ansible all the things!

2017-10-09 Thread Daniel P. Berrange
On Fri, Oct 06, 2017 at 02:48:36PM +0200, Andrea Bolognani wrote:
> Changes from [v1]:
> 
>   * drop support for building projects;
>   * reduce redundancy by using mappings;
>   * add FreeBSD 10 support.
> 
> [v1] https://www.redhat.com/archives/libvir-list/2017-October/msg00035.html
> 
> Andrea Bolognani (16):
>   ansible: Initial support
>   ansible: Add libosinfo project
>   ansible: Add libvirt project
>   ansible: Add libvirt-cim project
>   ansible: Add libvirt-glib project
>   ansible: Add libvirt-go project
>   ansible: Add libvirt-go-xml project
>   ansible: Add libvirt-perl project
>   ansible: Add libvirt-python project
>   ansible: Add libvirt-sandbox project
>   ansible: Add libvirt-tck project
>   ansible: Add osinfo-db project
>   ansible: Add osinfo-db-tools project
>   ansible: Add virt-manager project
>   ansible: Add virt-viewer project
>   ansible: Install and configure Jenkins agent

ACK to all patches on the basis that I don't know ansible but nothing
looks bad from a naive POV.

One thing the current builders have setup is a cron job to do a nightly
yum update (or equiv). I'm not sure whether this belongs in Ansible or
in prior kickstart file ?

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] gnulib tests in libvirt broken by newer glibc 2.26

2017-10-09 Thread Daniel P. Berrange
On Fri, Oct 06, 2017 at 07:59:13PM +0200, Bruno Haible wrote:
> Daniel P. Berrange wrote:
> > From my own F28 rawhide install with glibc-2.26.90-16.fc28.x86_64
> > 
> > > 
> > >   1) The output of
> > >  $ nm test-getopt-posix | grep getopt
> > 
> > $ nm test-getopt-posix | grep getopt
> >  U getopt@@GLIBC_2.2.5
> > 00400ab0 t getopt_loop.constprop.0
> > 00400c50 t test_getopt
> > 
> > 
> > >   2) The output of
> > >  $ gcc -DHAVE_CONFIG_H -DGNULIB_STRICT_CHECKING=1 -I. -I.. -I../gllib 
> > > -g -O2 -E test-getopt-posix.c
> > 
> > Attached in the file 'question-2.txt'
> > 
> > > 
> > >   3) The output of
> > >  $ gcc -DHAVE_CONFIG_H -DGNULIB_STRICT_CHECKING=1 -I. -I.. -I../gllib 
> > > -g -O2 -E -dM test-getopt-posix.c
> > 
> > Attached in the file 'question-3.txt'
> 
> Thanks. From this, I can see that getopt-pfx-core.h does not get included
> at all. Please try this patch (or, if you don't want to re-run configure,
> just remove the "&& !defined __GLIBC__" from the generated unistd.h).
> 
> 
> diff --git a/lib/unistd.in.h b/lib/unistd.in.h
> index 748112f..b5b6e0e 100644
> --- a/lib/unistd.in.h
> +++ b/lib/unistd.in.h
> @@ -134,9 +134,8 @@
>  /* The definition of _GL_WARN_ON_USE is copied here.  */
>  
>  
> -/* Get getopt(), optarg, optind, opterr, optopt.
> -   But avoid namespace pollution on glibc systems.  */
> -#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined 
> _GL_SYSTEM_GETOPT
> +/* Get getopt(), optarg, optind, opterr, optopt.  */
> +#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
>  # include 
>  # include 
>  #endif

Tested-by: Daniel P. Berrange 


Confirmed it fixes the failure on Fedora 28, and does not cause a regression
on Fedora 26 with older glibc.

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


[libvirt] [question]Why libvirt bind all devices with same vendor id and device id to vfio-pci driver, and only unbind devices used by VMs to original driver?

2017-10-09 Thread Wuzongyong (Euler Dept)
Hi,

As the title says, I thought that it's a bit unreasonable and inconsistent  to 
unbind devices assigned to VMs to original driver
and leave other devices binding to vfio-pci driver.
Why not to bind devices we need to vfio-pci driver instead of bind all devices 
with same type to vfio-pci driver?
Or, we may can rebind devices unused with same type to original driver.

Thanks,
Zongyong Wu

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

Re: [libvirt] Question about the host-model CPU mode

2017-10-09 Thread Marc Hartmayer
On Thu, Oct 05, 2017 at 02:11 PM +0200, Jiri Denemark  
wrote:
> On Thu, Oct 05, 2017 at 10:46:24 +0200, Marc Hartmayer wrote:
>> Let's assume we've a z13 system with a QEMU 2.9 and we define a domain
>> using the default s390-virtio-ccw machine together with the host-model
>> CPU mode. The definition will have the machine expanded to
>> s390-virtio-ccw-2.9 but retain the host-model CPU mode. In a next step
>> we upgrade to QEMU 2.10 (first version to recognize z14). Everything is
>> still fine, even though the machine runs in 2.9 compatibility
>> mode. Finally we upgrade to a z14. As a consequence it is not possible
>> to start the domain anymore as the machine type doesn't support our CPU
>> host model (which is expanded at start time of the domain).
>
> If I understand it correctly, when QEMU 2.10 is installed, we expand
> the host-model CPU into a different model than with QEMU 2.9. And the
> CPU model we got with QEMU 2.10 does not work with s390-virtio-ccw-2.9
> machine type even on QEMU 2.10. Is that correct?

Right.

>
>> Is this behavior expected?
>
> Partially.
>
>> There are some ways to avoid this problem:
>> - CPU model expansion is performed at domain definition time
>
> No, host-model is designed to be expanded when a domain starts so that
> the same definition always results in the best CPU model to be used no
> matter on which host the domain gest started.
>
>> - host-model is related to the machine type of a domain
>
> So if usability of a specific CPU model depends on the selected machine
> types, we probably need to count with this restriction.

Yep.

> But it's going to be a bit complicated because we ask QEMU what the
> host CPU is and the interface we used would need to be enhanced to
> give us different results for all supported machine types so that we
> can select the right one when a domain is started.

So how do we deal with this?

>
> Jirka
>
--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


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

Re: [libvirt] [libvirt-jenkins-ci PATCH v2 01/16] ansible: Initial support

2017-10-09 Thread Andrea Bolognani
On Fri, 2017-10-06 at 14:48 +0200, Andrea Bolognani wrote:
> diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg
> new file mode 100644
> index 000..ca02677
> --- /dev/null
> +++ b/ansible/ansible.cfg
> @@ -0,0 +1,8 @@
> +[defaults]
> +display_skipped_hosts = False
> +forks = 16
> +inventory = ./inventory
> +log_path = ./log
> +nocows = 1
> +pipelining = True
> +squash_actions = package

This won't work. Assume

  diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg
  index ca02677..6b18c57 100644
  --- a/ansible/ansible.cfg
  +++ b/ansible/ansible.cfg
  @@ -4,5 +4,7 @@ forks = 16
   inventory = ./inventory
   log_path = ./log
   nocows = 1
  -pipelining = True
   squash_actions = package
  +
  +[ssh_connection]
  +pipelining = True

has been squashed in.

-- 
Andrea Bolognani / Red Hat / Virtualization

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