Re: [libvirt] [PATCH 1/3] CPU: Implement guestData for PPC CPU driver

2013-09-02 Thread Li Zhang

On 2013年09月02日 12:08, Doug Goldstein wrote:
On Thu, Aug 29, 2013 at 3:46 AM, Li Zhang zhlci...@gmail.com 
mailto:zhlci...@gmail.com wrote:


From: Li Zhang zhlci...@linux.vnet.ibm.com
mailto:zhlci...@linux.vnet.ibm.com

On Power platform, Power7+ can support Power7 guest.
It needs to define XML configuration to specify guest's CPU model.

For exmaple:
  cpu match='exact'
modelPOWER7+_v2.1/model
vendorIBM/vendor
  /cpu

Signed-off-by: Li Zhang zhlci...@linux.vnet.ibm.com
mailto:zhlci...@linux.vnet.ibm.com
---
 src/cpu/cpu_powerpc.c | 166
+-
 1 file changed, 164 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index 647a8a1..84fa3f7 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -99,6 +99,23 @@ ppcModelFindPVR(const struct ppc_map *map,
 return NULL;
 }

+static struct ppc_model *
+ppcModelCopy(const struct ppc_model *model)
+{
+struct ppc_model *copy;
+
+if (VIR_ALLOC(copy)  0 ||
+VIR_STRDUP(copy-name, model-name)  0) {
+ppcModelFree(copy);
+return NULL;
+}
+
+copy-data.pvr = model-data.pvr;
+copy-vendor = model-vendor;
+
+return copy;
+}
+
 static struct ppc_vendor *
 ppcVendorFind(const struct ppc_map *map,
   const char *name)
@@ -126,6 +143,29 @@ ppcVendorFree(struct ppc_vendor *vendor)
 VIR_FREE(vendor);
 }

+static struct ppc_model *
+ppcModelFromCPU(const virCPUDefPtr cpu,
+const struct ppc_map *map)
+{
+struct ppc_model *model = NULL;
+
+if ((model = ppcModelFind(map, cpu-model)) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Unknown CPU model %s), cpu-model);
+goto error;
+}
+
+if ((model = ppcModelCopy(model)) == NULL)
+goto error;
+
+return model;
+
+error:
+ppcModelFree(model);
+return NULL;
+}
+
+
 static int
 ppcVendorLoad(xmlXPathContextPtr ctxt,
   struct ppc_map *map)
@@ -288,6 +328,112 @@ error:
 return NULL;
 }

+static virCPUDataPtr
+ppcMakeCPUData(virArch arch, struct cpuPPCData *data)
+{
+virCPUDataPtr cpuData;
+
+if (VIR_ALLOC(cpuData)  0)
+return NULL;
+
+cpuData-arch = arch;
+cpuData-data.ppc = *data;
+data = NULL;
+
+return cpuData;
+}
+
+static virCPUCompareResult
+ppcCompute(virCPUDefPtr host,
+ const virCPUDefPtr cpu,
+ virCPUDataPtr *guestData,
+ char **message)
+
+{
+struct ppc_map *map = NULL;
+struct ppc_model *host_model = NULL;
+struct ppc_model *guest_model = NULL;
+
+int ret = 0;
+virArch arch;
+size_t i;
+
+if (cpu-arch != VIR_ARCH_NONE) {
+bool found = false;
+
+for (i = 0; i  ARRAY_CARDINALITY(archs); i++) {
+if (archs[i] == cpu-arch) {
+found = true;
+break;
+}
+}
+
+if (!found) {
+VIR_DEBUG(CPU arch %s does not match host arch,
+  virArchToString(cpu-arch));
+if (message 
+virAsprintf(message,
+_(CPU arch %s does not match host
arch),
+  virArchToString(cpu-arch))  0)
+goto error;
+return VIR_CPU_COMPARE_INCOMPATIBLE;
+}
+arch = cpu-arch;
+} else {
+arch = host-arch;
+}
+
+   if (cpu-vendor 
+(!host-vendor || STRNEQ(cpu-vendor, host-vendor))) {
+VIR_DEBUG(host CPU vendor does not match required CPU
vendor %s,
+  cpu-vendor);
+if (message 
+virAsprintf(message,
+_(host CPU vendor does not match required 
+  CPU vendor %s),
+cpu-vendor)  0)
+goto error;
+return VIR_CPU_COMPARE_INCOMPATIBLE;
+}


Could this beginning part of ppcCompute() not go into some common 
function in cpu_generic.c? It just looks entirely copied and pasted 
from cpu_x86.c from x86Compute()


CPU driver's functions can be called separately for different 
architectures.
Doesn't it break the structure to let PPC driver go into some functions 
in cpu_generic.c?


PPC's CPU logic is the same as X86.
The difference is that CPUID is not supported on PPC and it is removed.


+
+if (!(map = ppcLoadMap()) ||
+!(host_model = ppcModelFromCPU(host, map)) ||
   

[libvirt] Is it a problem that after virEventRegisterDefaultImpl we have handlers leaked

2013-09-02 Thread Wangyufei (A)
Hello,
When I ran programme event-test compiled from event-test.c, I found a problem 
that, after virEventRegisterDefaultImpl I do virConnectOpenAuth and 
virConnectClose, there will be handlers of socket and pipe opened by 
virConnectOpenAuth leaked after virConnectClose. So I did some analysis, and I 
found the fact following:

In the condition that we only have one connection here

int virNetSocketAddIOCallback(virNetSocketPtr sock,
  int events,
  virNetSocketIOFunc func,
  void *opaque,
  virFreeCallback ff)
{
int ret = -1;

virObjectRef(sock); //Here we add sock refers once, then we will get refers 
equal 2 after
virObjectLock(sock);
if (sock-watch  0) {
VIR_DEBUG(Watch already registered on socket %p, sock);
goto cleanup;
}

if ((sock-watch = virEventAddHandle(sock-fd, //If we have called 
virEventRegisterDefaultImpl, then here we'll get a sock watch non negative and 
will not go to cleanup.
 events,
 virNetSocketEventHandle,
 sock,
 virNetSocketEventFree))  0) {
VIR_DEBUG(Failed to register watch on socket %p, sock);
goto cleanup;
}
sock-func = func;
sock-opaque = opaque;
sock-ff = ff;

ret = 0;

cleanup:
virObjectUnlock(sock);
if (ret != 0)
virObjectUnref(sock); //If we haven't called 
virEventRegisterDefaultImpl, we'll be here after virEventAddHandle, and sock 
refers will decrease to 1
return ret;
}

Condition with virEventRegisterDefaultImpl, we'll do unrefer action in two 
places:

1.   virEventRunDefaultImpl  -virEventPollRunOnce  
-virEventRunDefaultImpl  -virEventPollRunOnce  -virEventPollCleanupHandles 
- virNetSocketEventFree - virObjectUnref

2.   virConnectClose -virObjectUnref -virConnectDispose 
-remoteConnectClose  -doRemoteClose  -virNetClientClose  
-virNetClientCloseInternal - virNetClientIOEventLoopPassTheBuck - 
virNetClientCloseLocked - virObjectUnref

When event dealing loop is alive, everything work fine, we'll get sock refers 2 
after virConnectOpenAuth and unrefer twice in two places above after 
virConnectClose. But If some accidents happened like we quit event dealing loop 
or virEventRunDefaultImpl suspended, then sock refers will never be zero, and 
handlers will never be freed.
In a particular condition we have two threads, thread one doing event dealing 
loop, thread two doing something like virConnectOpenAuth and virConnectClose 
ceaselessly, then we'll get a big trouble that handlers available will be ate 
up soon.

I consider to add something like virEventDeregisterDefaultImpl to set 
addHandleImpl and his buddy NULL. Apparently it is far away from fixing it 
completely.

At last I have two questions here:


1.   Is it a problem that after virEventRegisterDefaultImpl we have 
handlers leaked?

2.   If it is a problem, is there anybody any good idea to help me out?


Best Regards,
-WangYufei

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

[libvirt] [PATCH 4/5] qemu: refactor out function to build scsi device qemu commandline

2013-09-02 Thread Guannan Ren
---
 src/qemu/qemu_command.c | 124 +++-
 1 file changed, 48 insertions(+), 76 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f38e98f..e46baaf 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4094,6 +4094,40 @@ error:
 return NULL;
 }
 
+static int
+qemuBuildSCSIDriveDevStr(int controllerModel,
+ virDomainDiskDefPtr disk,
+ virQEMUCapsPtr qemuCaps,
+ virBufferPtr opt)
+{
+if (disk-device != VIR_DOMAIN_DISK_DEVICE_LUN) {
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
+if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+virBufferAddLit(opt, scsi-cd);
+else
+virBufferAddLit(opt, scsi-hd);
+} else {
+virBufferAddLit(opt, scsi-disk);
+}
+} else {
+virBufferAddLit(opt, scsi-block);
+}
+
+
+if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC)
+virBufferAsprintf(opt, ,bus=scsi%d.%d,scsi-id=%d,
+  disk-info.addr.drive.controller,
+  disk-info.addr.drive.bus,
+  disk-info.addr.drive.unit);
+else
+virBufferAsprintf(opt, ,bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d,
+  disk-info.addr.drive.controller,
+  disk-info.addr.drive.bus,
+  disk-info.addr.drive.target,
+  disk-info.addr.drive.unit);
+return 0;
+}
+
 char *
 qemuBuildDriveDevStr(virDomainDefPtr def,
  virDomainDiskDefPtr disk,
@@ -4232,94 +4266,32 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
 if ((qemuSetScsiControllerModel(def, qemuCaps, controllerModel))  0)
 goto error;
 
-if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC) {
+if (controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSILOGIC ||
+controllerModel == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
 if (disk-info.addr.drive.target != 0) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
_(target must be 0 for controller 
  model 'lsilogic'));
 goto error;
 }
-
-if (disk-device == VIR_DOMAIN_DISK_DEVICE_LUN) {
-virBufferAddLit(opt, scsi-block);
-} else {
-if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
-if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM)
-virBufferAddLit(opt, scsi-cd);
-else
-virBufferAddLit(opt, scsi-hd);
-} else {
-virBufferAddLit(opt, scsi-disk);
-}
-}
-
-virBufferAsprintf(opt, ,bus=scsi%d.%d,scsi-id=%d,
-  disk-info.addr.drive.controller,
-  disk-info.addr.drive.bus,
-  disk-info.addr.drive.unit);
-} else if (controllerModel == 
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
-if (disk-info.addr.drive.target != 0) {
+} else if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) {
+if (disk-info.addr.drive.target  7) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(target must be 0 for controller 
- model 'usb-bot'));
+   _(This QEMU doesn't support target 
+ greater than 7));
 goto error;
 }
 
-if (disk-device != VIR_DOMAIN_DISK_DEVICE_LUN) {
-if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
-if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM)
-virBufferAddLit(opt, scsi-cd);
-else
-virBufferAddLit(opt, scsi-hd);
-} else {
-virBufferAddLit(opt, scsi-disk);
-}
-} else {
-virBufferAddLit(opt, scsi-block);
-}
-
-virBufferAsprintf(opt, 
,bus=scsi%d.0,channel=%d,scsi-id=%d,lun=%d,
-  disk-info.addr.drive.controller,
-  disk-info.addr.drive.bus,
-  disk-info.addr.drive.target,
-  disk-info.addr.drive.unit);
-} else {
-if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_DISK_CHANNEL)) {
-if (disk-info.addr.drive.target  7) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(This QEMU doesn't support target 
- greater than 7));
-

[libvirt] [PATCH 0/5]qemu: add usb-bot scsi controller support

2013-09-02 Thread Guannan Ren

BZ:https://bugzilla.redhat.com/show_bug.cgi?id=917702
qemu patch:http://lists.gnu.org/archive/html/qemu-devel/2013-01/msg02200.html

These patch aims to add usb-bot SCSI controller support for libvirt.
As usb-storage libvirt already supported, usb-bot only supports one
SCSI target with SCSI ID 0.
The difference is that usb-storage creates SCSI HBA and additionaly
either a scsi-disk or a scsi-generic device, usb-bot only creates the
SCSI HBA. we can attach a SCSI device to it with another -device.

usb-bot supports a single target and a number of luns. The limit is
15 luns (0~15 LUN ID) and they must be contiguous(using lun 0 and 2
without 1 doesn't work).

Athought usb-bot is a SCSI controller it needs to be attached to a
exsiting USB controller for work. So it has to use address of usb type.

Libvirt XML:

devices
   ...
   disk type='file' device='disk'
 driver name='qemu' type='raw'/
 source file='/var/lib/libvirt/images/disk.qcow2'/
 target dev='sdc' bus='scsi'/
 address type='drive' controller='0' bus='0' target='0' unit='0'/
   /disk
   controller type='usb' index='0'/
   controller type='scsi' index='0' model='usb-bot'
 address type='usb' bus='0' port='1'/
   /controller
...
/devices

The QEMU commandline:

qemu ${other_vm_args}  \
 -device piix3-usb-uhci,id=usb \
 -device usb-bot,id=scsi0,bus=usb.0,port=1 \
 -drive 
file=/var/lib/libvirt/images/disk.qcow2,if=none,id=drive-scsi0-0-0-0,format=raw 
\
 -device 
scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=0,drive=drive-scsi0-0-0-0,id=scsi0-0-0-0

As the usb-storage creates scsi disk automatically which doesn't let
you set scsi-disk properties such as vendor, product, wwn, channel,
scsi-id and lun. So QEMU guys prefer usb-bot to usb-storage.
So this is the first part of the whole work. Next step will replace
usb-storage with usb-bot when disk in xml uses usb bus like
disk ...
  ...
  target bus='usb'
/disk

Guannan Ren(5)
  qemu: add usb-bot qemu cap flag
  qemu: add usb-bot model scsi controller support
  qemu: add usb-bot support from disks points of view
  qemu: refactor out function to build scsi device qemu commandline
  tests: add xml2argv test for usb-bot scsi controller

 docs/formatdomain.html.in |   4 +--
 docs/schemas/domaincommon.rng |   1 +
 src/conf/domain_conf.c| 111 
+++--
 src/conf/domain_conf.h|   5 +++
 src/libvirt_private.syms  |   1 +
 src/qemu/qemu_capabilities.c  |   3 ++
 src/qemu/qemu_capabilities.h  |   1 +
 src/qemu/qemu_command.c   | 124 
++---
 src/vmx/vmx.c |   3 +-
 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.args |  10 ++
 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.xml  |  33 

 tests/qemuxml2argvtest.c  |   3 ++
 12 files changed, 242 insertions(+), 57 deletions(-)

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


[libvirt] [PATCH 1/5] qemu: add usb-bot qemu cap flag

2013-09-02 Thread Guannan Ren
QEMU_CAPS_DEVICE_USB_BOT  /* -device usb-bot */
---
 src/qemu/qemu_capabilities.c | 3 +++
 src/qemu/qemu_capabilities.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 7888e2d..6a775ee 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -237,6 +237,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
   dmi-to-pci-bridge,
   i440fx-pci-hole64-size,
   q35-pci-hole64-size,
+
+  usb-bot, /* 155 */
 );
 
 struct _virQEMUCaps {
@@ -1375,6 +1377,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
 { vmware-svga, QEMU_CAPS_DEVICE_VMWARE_SVGA },
 { usb-serial, QEMU_CAPS_DEVICE_USB_SERIAL },
 { usb-net, QEMU_CAPS_DEVICE_USB_NET },
+{ usb-bot, QEMU_CAPS_DEVICE_USB_BOT },
 { virtio-rng-pci, QEMU_CAPS_DEVICE_VIRTIO_RNG },
 { virtio-rng-s390, QEMU_CAPS_DEVICE_VIRTIO_RNG },
 { virtio-rng-ccw, QEMU_CAPS_DEVICE_VIRTIO_RNG },
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 69f3395..67746a4 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -193,6 +193,7 @@ enum virQEMUCapsFlags {
 QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE  = 152, /* -device i82801b11-bridge */
 QEMU_CAPS_I440FX_PCI_HOLE64_SIZE = 153, /* i440FX-pcihost.pci-hole64-size 
*/
 QEMU_CAPS_Q35_PCI_HOLE64_SIZE = 154, /* q35-pcihost.pci-hole64-size */
+QEMU_CAPS_DEVICE_USB_BOT = 155, /* -device usb-bot */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 };
-- 
1.8.3.1

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


[libvirt] [PATCH 5/5] tests: add xml2argv test for usb-bot scsi controller

2013-09-02 Thread Guannan Ren
---
 .../qemuxml2argv-disk-scsi-usbbot.args | 10 +++
 .../qemuxml2argv-disk-scsi-usbbot.xml  | 33 ++
 tests/qemuxml2argvtest.c   |  3 ++
 3 files changed, 46 insertions(+)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.args 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.args
new file mode 100644
index 000..09e6d57
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.args
@@ -0,0 +1,10 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \
+pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \
+unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device usb-bot,id=scsi0 
\
+-usb -drive file=/dev/HostVG/QEMUGuest1,if=none,id=drive-scsi0-0-0-0 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
+drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \
+-drive file=/tmp/scsidisk.img,if=none,id=drive-scsi0-0-0-1 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=1,\
+drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.xml
new file mode 100644
index 000..4be405f
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-usbbot.xml
@@ -0,0 +1,33 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory unit='KiB'219136/memory
+  currentMemory unit='KiB'219136/currentMemory
+  vcpu placement='static'1/vcpu
+  os
+type arch='i686' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/qemu/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='sda' bus='scsi'/
+  address type='drive' controller='0' bus='0' target='0' unit='0'/
+/disk
+disk type='file' device='disk'
+  source file='/tmp/scsidisk.img'/
+  target dev='sdb' bus='scsi'/
+  address type='drive' controller='0' bus='0' target='0' unit='1'/
+/disk
+controller type='usb' index='0'/
+controller type='ide' index='0'/
+controller type='scsi' index='0' model='usb-bot'/
+controller type='pci' index='0' model='pci-root'/
+memballoon model='virtio'/
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 4e3508b..29de992 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -548,6 +548,9 @@ mymain(void)
 DO_TEST(disk-scsi-device,
 QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
 QEMU_CAPS_SCSI_LSI);
+DO_TEST(disk-scsi-usbbot,
+QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
+QEMU_CAPS_DEVICE_USB_BOT);
 DO_TEST(disk-scsi-device-auto,
 QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
 QEMU_CAPS_SCSI_LSI);
-- 
1.8.3.1

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


[libvirt] [PATCH 2/5] qemu: add usb-bot model scsi controller support

2013-09-02 Thread Guannan Ren
usb-bot is SCSI HBA which support only one SCSI target with ID 0.
we can create one or more SCSI devices connected to it with -device
as its luns. For usb-bot the limit is 15 luns.
The difference from other SCSI controllers is that usb-bot needs
usb-bus support. That means usb-bot is required to be attached to a
existing USB controller.

libvirt xml example:
devices
 ...
 controller type='usb' index='0'
 /controller
 controller type='scsi' index='0' model='usb-bot'
   address type='usb' bus='0' port='1'/
 /controller
 ...
/devices

QEMU commandline should be:
-device piix3-usb-uhci,id=usb \
-device usb-bot,id=scsi0,bus=usb.0,port=1
---
 docs/formatdomain.html.in |  4 ++--
 docs/schemas/domaincommon.rng |  1 +
 src/conf/domain_conf.c| 52 +--
 src/conf/domain_conf.h|  1 +
 src/qemu/qemu_command.c   | 16 +
 src/vmx/vmx.c |  3 ++-
 6 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cce179d..274acf4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2413,8 +2413,8 @@
   control how many devices can be connected through the
   controller.  A scsi controller has an optional
   attribute codemodel/code, which is one of auto, buslogic,
-  ibmvscsi, lsilogic, lsisas1068, lsisas1078, virtio-scsi or
-  vmpvscsi.  A usb controller has an optional attribute
+  ibmvscsi, lsilogic, lsisas1068, lsisas1078, virtio-scsi,
+  vmpvscsi or usb-bot.  A usb controller has an optional attribute
   codemodel/code, which is one of piix3-uhci, piix4-uhci, ehci,
   ich9-ehci1, ich9-uhci1, ich9-uhci2, ich9-uhci3, vt82c686b-uhci,
   pci-ohci or nec-xhci.  Additionally,
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 6978dc7..d748d68 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1509,6 +1509,7 @@
   valueibmvscsi/value
   valuevirtio-scsi/value
   valuelsisas1078/value
+  valueusb-bot/value
 /choice
   /attribute
 /optional
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f8fbf79..545c157 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -324,7 +324,8 @@ VIR_ENUM_IMPL(virDomainControllerModelSCSI, 
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAS
   vmpvscsi,
   ibmvscsi,
   virtio-scsi,
-  lsisas1078);
+  lsisas1078,
+  usb-bot);
 
 VIR_ENUM_IMPL(virDomainControllerModelUSB, 
VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST,
   piix3-uhci,
@@ -5736,6 +5737,17 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 goto error;
 
 switch (def-type) {
+case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+if (def-model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
+if (def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
+def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(usb-bot mode of scsi controller requires 
+ address of type 'usb'));
+goto error;
+}
+}
+break;
 case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: {
 char *ports = virXMLPropString(node, ports);
 if (ports) {
@@ -5826,7 +5838,8 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO 
 def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW 
 def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390 
-def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
+def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI 
+def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
_(Controllers must use the 'pci' address type));
 goto error;
@@ -13778,6 +13791,38 @@ 
virDomainDefMaybeAddSmartcardController(virDomainDefPtr def)
 return 0;
 }
 
+static int
+virDomainDefMaybeAddUSBcontroller(virDomainDefPtr def)
+{
+size_t i;
+int maxController = -1;
+
+for (i = 0; i  def-ncontrollers; i++) {
+virDomainControllerDefPtr cont = def-controllers[i];
+
+if (cont-type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+continue;
+
+if (cont-model != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT)
+continue;
+
+if ((int)cont-info.addr.usb.bus  maxController)
+maxController = cont-info.addr.usb.bus;
+}
+
+if (maxController == -1)
+return 0;
+
+for (i = 0; i = maxController; i++) {
+if (virDomainDefMaybeAddController(def,
+   VIR_DOMAIN_CONTROLLER_TYPE_USB,
+   

[libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view

2013-09-02 Thread Guannan Ren
usb-bot only supports 16 luns(0~15) and they must be contiguous,
(using lun 0 and 2 without 1 doesn't work). In this case qemu
doesn't throw an error, we can not find the lun 2 in guests. So
Adding a checking function in libvirt to prevent from this case.
---
 src/conf/domain_conf.c   | 59 
 src/conf/domain_conf.h   |  4 
 src/libvirt_private.syms |  1 +
 src/qemu/qemu_command.c  | 32 ++
 4 files changed, 96 insertions(+)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 545c157..84dfe25 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4287,6 +4287,65 @@ virDomainDiskDefAssignAddress(virDomainXMLOptionPtr 
xmlopt,
 return 0;
 }
 
+bool
+virDomainDiskAttachedToUsbbotLunIsContiguous(virDomainDefPtr def)
+{
+size_t i;
+int controllerModel;
+virBitmapPtr units = NULL;
+bool is_set = false;
+bool ret = false;
+
+if (!(units = virBitmapNew(SCSI_CONTROLLER_USB_BOT_MODEL_MAX_LUNS)))
+goto cleanup;
+
+for (i = 0; i  def-ndisks; i++) {
+virDomainDiskDefPtr disk = def-disks[i];
+int unitValue = disk-info.addr.drive.unit;
+
+if (disk-bus != VIR_DOMAIN_DISK_BUS_SCSI)
+continue;
+
+controllerModel =
+virDomainDeviceFindControllerModel(def, disk-info,
+   
VIR_DOMAIN_CONTROLLER_TYPE_SCSI);
+if (controllerModel != VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT)
+continue;
+
+/* usb-bot only supports 16 luns */
+if (unitValue  ~0xf) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(The address unit value of disk '%s' is too big),
+   disk-src);
+goto cleanup;
+}
+
+if (virBitmapGetBit(units, unitValue, is_set) == 0  is_set) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(The address unit value of disk '%s' is already 
used),
+   disk-src);
+goto cleanup;
+}
+
+if (unitValue  0) {
+if (virBitmapGetBit(units, unitValue - 1, is_set) == 0  
!is_set) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(The address unit value of disk 
+ attached to usb-bot controller is not 
contiguous));
+goto cleanup;
+}
+}
+
+ignore_value(virBitmapSetBit(units, unitValue));
+}
+
+ret = true;
+
+cleanup:
+virBitmapFree(units);
+return ret;
+}
+
 static virSecurityLabelDefPtr
 virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt,
 unsigned int flags)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 3e69f84..9e2f477 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -778,6 +778,8 @@ typedef enum {
 VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST
 } virDomainControllerModelPCI;
 
+# define SCSI_CONTROLLER_USB_BOT_MODEL_MAX_LUNS 16
+
 enum virDomainControllerModelSCSI {
 VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AUTO,
 VIR_DOMAIN_CONTROLLER_MODEL_SCSI_BUSLOGIC,
@@ -2362,6 +2364,8 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def,
 int virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt,
   virDomainDiskDefPtr def);
 
+bool virDomainDiskAttachedToUsbbotLunIsContiguous(virDomainDefPtr def);
+
 virDomainDiskDefPtr
 virDomainDiskRemove(virDomainDefPtr def, size_t i);
 virDomainDiskDefPtr
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 35f0f1b..c1f7da5 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -179,6 +179,7 @@ virDomainDeviceFindControllerModel;
 virDomainDeviceInfoCopy;
 virDomainDeviceInfoIterate;
 virDomainDeviceTypeToString;
+virDomainDiskAttachedToUsbbotLunIsContiguous;
 virDomainDiskBusTypeToString;
 virDomainDiskCacheTypeFromString;
 virDomainDiskCacheTypeToString;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5f08a72..f38e98f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4257,6 +4257,32 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
   disk-info.addr.drive.controller,
   disk-info.addr.drive.bus,
   disk-info.addr.drive.unit);
+} else if (controllerModel == 
VIR_DOMAIN_CONTROLLER_MODEL_SCSI_USB_BOT) {
+if (disk-info.addr.drive.target != 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(target must be 0 for controller 
+ model 'usb-bot'));
+goto error;
+}
+
+if (disk-device != VIR_DOMAIN_DISK_DEVICE_LUN) {
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SCSI_CD)) {
+if (disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM)
+   

Re: [libvirt] [PATCHv5 1/5] domifaddr: Implement the public APIs

2013-09-02 Thread Nehal J Wani
On Sun, Sep 1, 2013 at 7:13 PM, Nehal J Wani nehaljw.k...@gmail.com wrote:
 Define a new API virDomainInterfaceAddresses, which returns
 the address information of a running domain's interfaces(s).
 If no interface name is specified, it returns the information
 of all interfaces, otherwise it only returns the information
 of the specificed interface. The address information includes
 the MAC and IP addresses.

 Define helper function virDomainInterfaceFree, which allows
 the upper layer application to free the domain interface object
 conveniently.

 The API is going to provide multiple methods by flags, e.g.

   * Query guest agent
   * Parse lease file of dnsmasq
   * DHCP snooping

 But at this stage, it will only work with guest agent, and flags
 won't be supported.

 include/libvirt/libvirt.h.in:
   * Define virDomainInterfaceAddresses, virDomainInterfaceFree
   * Define structs virDomainInterface, virDomainIPAddress

 python/generator.py:
   * Skip the auto-generation for virDomainInterfaceAddresses
 and virDomainInterfaceFree

 src/driver.h:
   * Define domainInterfaceAddresses

 src/libvirt.c:
   * Implement virDomainInterfaceAddresses
   * Implement virDomainInterfaceFree

 src/libvirt_public.syms:
   * Export the new symbols

 ---
  include/libvirt/libvirt.h.in |  32 
  python/generator.py  |   3 ++
  src/driver.h |   6 +++
  src/libvirt.c| 115 
 +++
  src/libvirt_public.syms  |   6 +++
  5 files changed, 162 insertions(+)

 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index a47e33c..1a34d02 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -2044,6 +2044,38 @@ int 
 virDomainGetInterfaceParameters (virDomainPtr dom,
   
 virTypedParameterPtr params,
   int *nparams, 
 unsigned int flags);

 +typedef enum {
 +VIR_IP_ADDR_TYPE_IPV4,
 +VIR_IP_ADDR_TYPE_IPV6,
 +
 +#ifdef VIR_ENUM_SENTINELS
 +VIR_IP_ADDR_TYPE_LAST
 +#endif
 +} virIPAddrType;
 +
 +typedef struct _virDomainInterfaceIPAddress virDomainIPAddress;
 +typedef virDomainIPAddress *virDomainIPAddressPtr;
 +struct _virDomainInterfaceIPAddress {
 +int type;/* virIPAddrType */
 +char *addr;  /* IP address */
 +unsigned int prefix; /* IP address prefix */
 +};
 +
 +typedef struct _virDomainInterface virDomainInterface;
 +typedef virDomainInterface *virDomainInterfacePtr;
 +struct _virDomainInterface {
 +char *name; /* interface name */
 +char *hwaddr;   /* hardware address */
 +unsigned int naddrs;/* number of items in @addrs */
 +virDomainIPAddressPtr addrs;/* array of IP addresses */
 +};
 +
 +int virDomainInterfaceAddresses(virDomainPtr dom,
 +virDomainInterfacePtr **ifaces,
 +unsigned int flags);
 +
 +void virDomainInterfaceFree(virDomainInterfacePtr iface);
 +
  /* Management of domain block devices */

  int virDomainBlockPeek (virDomainPtr dom,
 diff --git a/python/generator.py b/python/generator.py
 index fb321c6..50f779b 100755
 --- a/python/generator.py
 +++ b/python/generator.py
 @@ -458,6 +458,7 @@ skip_impl = (
  'virNodeGetMemoryParameters',
  'virNodeSetMemoryParameters',
  'virNodeGetCPUMap',
 +'virDomainInterfaceAddresses',
  'virDomainMigrate3',
  'virDomainMigrateToURI3',
  )
 @@ -560,6 +561,8 @@ skip_function = (
  virTypedParamsGetString,
  virTypedParamsGetUInt,
  virTypedParamsGetULLong,
 +
 +virDomainInterfaceFree, # Only useful in C
  )

  lxc_skip_function = (
 diff --git a/src/driver.h b/src/driver.h
 index be64333..eb4927b 100644
 --- a/src/driver.h
 +++ b/src/driver.h
 @@ -518,6 +518,11 @@ typedef int
unsigned int flags);

  typedef int
 +(*virDrvDomainInterfaceAddresses)(virDomainPtr dom,
 +  virDomainInterfacePtr **ifaces,
 +  unsigned int flags);
 +
 +typedef int
  (*virDrvDomainMemoryStats)(virDomainPtr domain,
 struct _virDomainMemoryStat *stats,
 unsigned int nr_stats,
 @@ -1238,6 +1243,7 @@ struct _virDriver {
  virDrvDomainInterfaceStats domainInterfaceStats;
  virDrvDomainSetInterfaceParameters domainSetInterfaceParameters;
  virDrvDomainGetInterfaceParameters domainGetInterfaceParameters;
 +virDrvDomainInterfaceAddressesdomainInterfaceAddresses;
  virDrvDomainMemoryStats domainMemoryStats;
  virDrvDomainBlockPeek domainBlockPeek;
  virDrvDomainMemoryPeek domainMemoryPeek;
 diff --git a/src/libvirt.c b/src/libvirt.c
 index 07a3fd5..82c117f 100644
 --- a/src/libvirt.c
 +++ b/src/libvirt.c
 

Re: [libvirt] [PATCHv5 5/5] domifaddr: Expose python binding

2013-09-02 Thread Nehal J Wani
On Sun, Sep 1, 2013 at 7:13 PM, Nehal J Wani nehaljw.k...@gmail.com wrote:
 Expose virDomainInterfaceAddresses to python binding

 examples/python/Makefile.am:
   * Add new file domipaddrs.py

 examples/python/README:
   * Add documentation for the python example

 python/libvirt-override-api.xml:
   * Add new symbol for virDomainInterfaceAddresses

 python/libvirt-override.c:
   * Hand written python api

 Example:
   $ ./run python ./examples/python/domipaddrs.py f18
   Interface  MAC address  Protocol Address
   lo 00:00:00:00:00:00ipv4 127.0.0.1/8
   lo 00:00:00:00:00:00ipv6 ::1/128
   eth2   52:54:00:36:2a:e5
   eth1   52:54:00:b1:70:19ipv4 192.168.105.201/16
   eth1   52:54:00:b1:70:19ipv4 192.168.201.195/16
   eth1   52:54:00:b1:70:19ipv6 fe80::5054:ff:feb1:7019/64
   eth0   52:54:00:2e:45:ceipv4 10.1.33.188/24
   eth0   52:54:00:2e:45:ceipv6 2001:db8:0:f101::2/64
   eth0   52:54:00:2e:45:ceipv6 fe80::5054:ff:fe2e:45ce/64

 ---
  examples/python/Makefile.am |   2 +-
  examples/python/README  |   1 +
  examples/python/domipaddrs.py   |  50 ++
  python/libvirt-override-api.xml |   8 ++-
  python/libvirt-override.c   | 111 
 
  5 files changed, 170 insertions(+), 2 deletions(-)
  create mode 100755 examples/python/domipaddrs.py

 diff --git a/examples/python/Makefile.am b/examples/python/Makefile.am
 index 2cacfa1..d33ee17 100644
 --- a/examples/python/Makefile.am
 +++ b/examples/python/Makefile.am
 @@ -17,4 +17,4 @@
  EXTRA_DIST=\
 README  \
 consolecallback.py  \
 -   dominfo.py domrestore.py domsave.py domstart.py esxlist.py
 +   dominfo.py domrestore.py domsave.py domstart.py esxlist.py 
 domipaddrs.py
 diff --git a/examples/python/README b/examples/python/README
 index f4db76c..1285d52 100644
 --- a/examples/python/README
 +++ b/examples/python/README
 @@ -10,6 +10,7 @@ domsave.py  - save all running domU's into a directory
  domrestore.py - restore domU's from their saved files in a directory
  esxlist.py  - list active domains of an VMware ESX host and print some info.
also demonstrates how to use the libvirt.openAuth() method
 +domipaddrs.py - print domain interfaces along with their MAC and IP addresses

  The XML files in this directory are examples of the XML format that libvirt
  expects, and will have to be adapted for your setup. They are only needed
 diff --git a/examples/python/domipaddrs.py b/examples/python/domipaddrs.py
 new file mode 100755
 index 000..679e0bf
 --- /dev/null
 +++ b/examples/python/domipaddrs.py
 @@ -0,0 +1,50 @@
 +#!/usr/bin/env python
 +# domipaddrds - print domain interfaces along with their MAC and IP addresses
 +
 +import libvirt
 +import sys
 +
 +def usage():
 +print Usage: %s [URI] DOMAIN % sys.argv[0]
 +print Print domain interfaces along with their MAC and IP 
 addresses
 +
 +uri = None
 +name = None
 +args = len(sys.argv)
 +
 +if args == 2:
 +name = sys.argv[1]
 +elif args == 3:
 +uri = sys.argv[1]
 +name = sys.argv[2]
 +else:
 +usage()
 +sys.exit(2)
 +
 +conn = libvirt.openReadOnly(uri)
 +if conn == None:
 +print Unable to open connection to libvirt
 +sys.exit(1)
 +
 +try:
 +dom = conn.lookupByName(name)
 +except libvirt.libvirtError:
 +print Domain %s not found % name
 +sys.exit(0)
 +
 +ifaces = dom.interfaceAddresses(0)
 +if (ifaces == None):
 +print Failed to get domain interfaces
 +sys.exit(0)
 +
 +print  {0:10} {1:20} {2:12} {3}.format(Interface, MAC address, 
 Protocol, Address)
 +
 +for (name, val) in ifaces.iteritems():
 +if val['ip_addrs']:
 +for addr in val['ip_addrs']:
 +   print  {0:10} {1:19}.format(name, val['hwaddr']),
 +   print  {0:12} {1}/{2} .format(addr['type'], addr['addr'], 
 addr['prefix']),
 +   print
 +else:
 +print  {0:10} {1:19}.format(name, val['hwaddr']),
 +print
 diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml
 index 9a88215..60491de 100644
 --- a/python/libvirt-override-api.xml
 +++ b/python/libvirt-override-api.xml
 @@ -602,5 +602,11 @@
arg name='conn' type='virConnectPtr' info='pointer to the hypervisor 
 connection'/
arg name='flags' type='int' info='unused, pass 0'/
  /function
 -  /symbols
 +function name='virDomainInterfaceAddresses' file='python'
 +  inforeturns a dictionary of domain interfaces along with their MAC 
 and IP addresses/info
 +  arg name='dom' type='virDomainPtr' info='pointer to the domain'/
 +  arg name='flags' type='unsigned int' info='extra flags; not used yet, 
 so callers should always pass 0'/
 +  return type='virDomainInterfacePtr' 

Re: [libvirt] [PATCH 08/12] libxl: Use atomic ops for driver-nactive

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.h   |  2 +-
  src/libxl/libxl_driver.c | 10 --
  2 files changed, 5 insertions(+), 7 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
 index e3875ba..83bb6b9 100644
 --- a/src/libxl/libxl_conf.h
 +++ b/src/libxl/libxl_conf.h
 @@ -90,7 +90,7 @@ struct _libxlDriverPrivate {
   * then lockless thereafter */
  libxlDriverConfigPtr config;
  
 -size_t nactive;
 +unsigned int nactive;
  
  virStateInhibitCallback inhibitCallback;
  void *inhibitOpaque;
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index e604899..7615cdd 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -50,6 +50,7 @@
  #include virstring.h
  #include virsysinfo.h
  #include viraccessapicheck.h
 +#include viratomic.h
  
  #define VIR_FROM_THIS VIR_FROM_LIBXL
  
 @@ -265,8 +266,7 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
  virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
  }
  
 -driver-nactive--;
 -if (!driver-nactive  driver-inhibitCallback)
 +if (virAtomicIntDecAndTest(driver-nactive)  driver-inhibitCallback)
  driver-inhibitCallback(false, driver-inhibitOpaque);
  
  if ((vm-def-ngraphics == 1) 
 @@ -655,9 +655,8 @@ libxlVmStart(libxlDriverPrivatePtr driver, 
 virDomainObjPtr vm,
  if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
  goto error;
  
 -if (!driver-nactive  driver-inhibitCallback)
 +if (virAtomicIntInc(driver-nactive)  driver-inhibitCallback)
  driver-inhibitCallback(true, driver-inhibitOpaque);

Not exactly the same as previous code. Previously, the callback was
called iff nactive == 0; However, with your change the callback is
invoked each time the control gets to the 'if' (as virAtomicIntInc()
returns the *new* value after the increment). I think we want this to be:

if (virAtomicIntInc(driver-nactive) == 1  driver-inhibitCallback)

 -driver-nactive++;
  
  event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED,
   restore_fd  0 ?
 @@ -727,9 +726,8 @@ libxlReconnectDomain(virDomainObjPtr vm,
  vm-def-id = d_info.domid;
  virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNKNOWN);
  
 -if (!driver-nactive  driver-inhibitCallback)
 +if (virAtomicIntInc(driver-nactive)  driver-inhibitCallback)

Same applies here.

  driver-inhibitCallback(true, driver-inhibitOpaque);
 -driver-nactive++;
  
  /* Recreate domain death et. al. events */
  libxlCreateDomEvents(vm);
 

ACK if you fix the issue.

Michal

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


Re: [libvirt] [PATCH 06/12] libxl: User per-domain ctx in libxlDomainGetInfo

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 libxlDomainGetInfo() uses the driver-wide libxl ctx when
 it would be more appropriate to use the per-domain ctx
 associated with the domain.  Switch to using the per-domain
 libxl ctx.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_driver.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
 
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index 6fd9178..a26fbf6 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -1818,6 +1818,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr 
 info)
  libxlDriverPrivatePtr driver = dom-conn-privateData;
  virDomainObjPtr vm;
  libxl_dominfo d_info;
 +libxlDomainObjPrivatePtr priv;
  int ret = -1;
  
  libxlDriverLock(driver);
 @@ -1833,12 +1834,13 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr 
 info)
  if (virDomainGetInfoEnsureACL(dom-conn, vm-def)  0)
  goto cleanup;
  
 +priv = vm-privateData;
  if (!virDomainObjIsActive(vm)) {
  info-cpuTime = 0;
  info-memory = vm-def-mem.cur_balloon;
  info-maxMem = vm-def-mem.max_balloon;
  } else {
 -if (libxl_domain_info(driver-ctx, d_info, dom-id) != 0) {
 +if (libxl_domain_info(priv-ctx, d_info, dom-id) != 0) {
  virReportError(VIR_ERR_INTERNAL_ERROR,
 _(libxl_domain_info failed for domain '%d'), 
 dom-id);
  goto cleanup;
 

ACK

Michal

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


Re: [libvirt] [PATCH 07/12] libxl: Introduce libxlDriverConfig object

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 The libxlDriverPrivate struct contains an variety of data with
 varying access needs. Similar to the QEMU and LXC drivers,
 move all the static config data into a dedicated libxlDriverConfig
 object. The only locking requirement is to hold the driver lock
 while obtaining an instance of libxlDriverConfig. Once a reference
 is held on the config object, it can be used completely lockless
 since it is immutable.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   | 124 ++-
  src/libxl/libxl_conf.h   |  52 +---
  src/libxl/libxl_driver.c | 313 
 +++
  3 files changed, 309 insertions(+), 180 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
 index 231a53d..19fd8a6 100644
 --- a/src/libxl/libxl_conf.c
 +++ b/src/libxl/libxl_conf.c
 @@ -64,6 +64,41 @@ static const char *xen_cap_re = 
 (xen|hvm)-[[:digit:]]+\\.[[:digit:]]+-(x86_32|x
  static regex_t xen_cap_rec;
  
  
 +static virClassPtr libxlDriverConfigClass;
 +static void libxlDriverConfigDispose(void *obj);
 +
 +static int libxlConfigOnceInit(void)
 +{
 +if (!(libxlDriverConfigClass = virClassNew(virClassForObject(),
 +   libxlDriverConfig,
 +   sizeof(libxlDriverConfig),
 +   libxlDriverConfigDispose)))
 +return -1;
 +
 +return 0;
 +}
 +
 +VIR_ONCE_GLOBAL_INIT(libxlConfig)
 +
 +static void
 +libxlDriverConfigDispose(void *obj)
 +{
 +libxlDriverConfigPtr cfg = obj;
 +
 +virObjectUnref(cfg-caps);
 +libxl_ctx_free(cfg-ctx);
 +xtl_logger_destroy(cfg-logger);
 +if (cfg-logger_file)
 +VIR_FORCE_FCLOSE(cfg-logger_file);
 +
 +VIR_FREE(cfg-configDir);
 +VIR_FREE(cfg-autostartDir);
 +VIR_FREE(cfg-logDir);
 +VIR_FREE(cfg-stateDir);
 +VIR_FREE(cfg-libDir);
 +VIR_FREE(cfg-saveDir);
 +}
 +
  static int
  libxlCapsInitHost(libxl_ctx *ctx, virCapsPtr caps)
  {
 @@ -978,8 +1013,8 @@ error:
  return -1;
  }
  
 -bool
 -libxlGetAutoballoonConf(libxlDriverPrivatePtr driver)
 +static bool
 +libxlGetAutoballoonConf(libxlDriverConfigPtr cfg)
  {
  regex_t regex;
  int ret;
 @@ -990,11 +1025,94 @@ libxlGetAutoballoonConf(libxlDriverPrivatePtr driver)
  if (ret)
  return true;
  
 -ret = regexec(regex, driver-verInfo-commandline, 0, NULL, 0);
 +ret = regexec(regex, cfg-verInfo-commandline, 0, NULL, 0);
  regfree(regex);
  return ret == REG_NOMATCH;
  }
  
 +libxlDriverConfigPtr
 +libxlDriverConfigNew(void)
 +{
 +libxlDriverConfigPtr cfg;
 +char *log_file = NULL;
 +char ebuf[1024];
 +unsigned int free_mem;
 +
 +if (libxlConfigInitialize()  0)
 +return NULL;
 +
 +if (!(cfg = virObjectNew(libxlDriverConfigClass)))
 +return NULL;
 +
 +if (VIR_STRDUP(cfg-configDir, LIBXL_CONFIG_DIR)  0)
 +goto error;
 +if (VIR_STRDUP(cfg-autostartDir, LIBXL_AUTOSTART_DIR)  0)
 +goto error;
 +if (VIR_STRDUP(cfg-logDir, LIBXL_LOG_DIR)  0)
 +goto error;
 +if (VIR_STRDUP(cfg-stateDir, LIBXL_STATE_DIR)  0)
 +goto error;
 +if (VIR_STRDUP(cfg-libDir, LIBXL_LIB_DIR)  0)
 +goto error;
 +if (VIR_STRDUP(cfg-saveDir, LIBXL_SAVE_DIR)  0)
 +goto error;
 +
 +if (virAsprintf(log_file, %s/libxl-driver.log, cfg-logDir)  0)
 +goto error;
 +
 +if ((cfg-logger_file = fopen(log_file, a)) == NULL)  {
 +VIR_ERROR(_(Failed to create log file '%s': %s),
 +  log_file, virStrerror(errno, ebuf, sizeof(ebuf)));
 +goto error;
 +}
 +VIR_FREE(log_file);
 +
 +cfg-logger =
 +(xentoollog_logger *)xtl_createlogger_stdiostream(cfg-logger_file,
 +  XTL_DEBUG, 0);
 +if (!cfg-logger) {
 +VIR_ERROR(_(cannot create logger for libxenlight, disabling 
 driver));
 +goto error;
 +}
 +
 +if (libxl_ctx_alloc(cfg-ctx, LIBXL_VERSION, 0, cfg-logger)) {
 +VIR_ERROR(_(cannot initialize libxenlight context, probably not 
 +running in a Xen Dom0, disabling driver));
 +goto error;
 +}
 +
 +if ((cfg-verInfo = libxl_get_version_info(cfg-ctx)) == NULL) {
 +VIR_ERROR(_(cannot version information from libxenlight, 
 +disabling driver));
 +goto error;
 +}
 +cfg-version = (cfg-verInfo-xen_version_major * 100) +
 +(cfg-verInfo-xen_version_minor * 1000);
 +
 +/* This will fill xenstore info about free and dom0 memory if missing,
 + * should be called before starting first domain */
 +if (libxl_get_free_memory(cfg-ctx, free_mem)) {
 +VIR_ERROR(_(Unable to configure libxl's memory management 
 parameters));
 +goto error;
 +}
 +
 +/* setup autoballoon */
 +cfg-autoballoon = 

Re: [libvirt] [PATCH 11/12] libxl: Remove unnecessary driver locking

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Now that most fields of libxlDriverPrivate struct are immutable
 or self-locking, there is no need to acquire the driver lock in
 much of the libxl driver.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   |   7 +-
  src/libxl/libxl_driver.c | 217 
 +--
  2 files changed, 46 insertions(+), 178 deletions(-)

ACK

Michal

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


Re: [libvirt] [PATCH 05/12] libxl: libxl: Use per-domain ctx in libxlMakeDomCreateInfo

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 libxlMakeDomCreateInfo() uses the driver-wide libxl ctx when
 it would be more appropriate to use the per-domain ctx
 associated with the domain.  Switch to using the per-domain
 libxl ctx.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
 index 81b4af4..231a53d 100644
 --- a/src/libxl/libxl_conf.c
 +++ b/src/libxl/libxl_conf.c
 @@ -395,7 +395,7 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
  }
  
  static int
 -libxlMakeDomCreateInfo(libxlDriverPrivatePtr driver,
 +libxlMakeDomCreateInfo(libxl_ctx *ctx,
 virDomainDefPtr def,
 libxl_domain_create_info *c_info)
  {
 @@ -413,7 +413,7 @@ libxlMakeDomCreateInfo(libxlDriverPrivatePtr driver,
  
  if (def-nseclabels 
  def-seclabels[0]-type == VIR_DOMAIN_SECLABEL_STATIC) {
 -if (libxl_flask_context_to_sid(driver-ctx,
 +if (libxl_flask_context_to_sid(ctx,
 def-seclabels[0]-label,
 strlen(def-seclabels[0]-label),
 c_info-ssidref)) {
 @@ -1024,10 +1024,11 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
 virDomainObjPtr vm, libxl_domain_config *d_config)
  {
  virDomainDefPtr def = vm-def;
 +libxlDomainObjPrivatePtr priv = vm-privateData;
  
  libxl_domain_config_init(d_config);
  
 -if (libxlMakeDomCreateInfo(driver, def, d_config-c_info)  0)
 +if (libxlMakeDomCreateInfo(priv-ctx, def, d_config-c_info)  0)
  return -1;
  
  if (libxlMakeDomBuildInfo(vm, d_config)  0)
 

ACK

Michal

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


Re: [libvirt] [PATCH 10/12] libxl: Move driver lock/unlock to libxl_conf

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Move the libxl driver lock/unlock functions from libxl_driver.c
 to libxl_conf.h so they can be used by other source files.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.h   | 12 
  src/libxl/libxl_driver.c | 12 
  2 files changed, 12 insertions(+), 12 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
 index 95e0983..174a759 100644
 --- a/src/libxl/libxl_conf.h
 +++ b/src/libxl/libxl_conf.h
 @@ -150,4 +150,16 @@ int
  libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
 virDomainObjPtr vm, libxl_domain_config *d_config);
  
 +static inline void
 +libxlDriverLock(libxlDriverPrivatePtr driver)
 +{
 +virMutexLock(driver-lock);
 +}
 +
 +static inline void
 +libxlDriverUnlock(libxlDriverPrivatePtr driver)
 +{
 +virMutexUnlock(driver-lock);
 +}
 +
  #endif /* LIBXL_CONF_H */
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index 7615cdd..8ece4c9 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -77,18 +77,6 @@ static int
  libxlVmStart(libxlDriverPrivatePtr driver, virDomainObjPtr vm,
   bool start_paused, int restore_fd);
  
 -static void
 -libxlDriverLock(libxlDriverPrivatePtr driver)
 -{
 -virMutexLock(driver-lock);
 -}
 -
 -static void
 -libxlDriverUnlock(libxlDriverPrivatePtr driver)
 -{
 -virMutexUnlock(driver-lock);
 -}
 -
  /* driver must be locked before calling */
  static void
  libxlDomainEventQueue(libxlDriverPrivatePtr driver, virDomainEventPtr event)
 

ACK

Michal

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


Re: [libvirt] [PATCH 02/12] libxl: Introduce libxl_domain.[ch]

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Create libxl_domain.[ch] and move all functions operating on
 libxlDomainObjPrivate to these files.  This will be useful for
 future patches that e.g. add job support for libxlDomainObjPrivate.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  po/POTFILES.in   |   1 +
  src/Makefile.am  |   1 +
  src/libxl/libxl_conf.c   |   2 +-
  src/libxl/libxl_conf.h   |  18 --
  src/libxl/libxl_domain.c | 469 
 +++
  src/libxl/libxl_domain.h |  61 ++
  src/libxl/libxl_driver.c | 436 +--
  7 files changed, 535 insertions(+), 453 deletions(-)

Did a compile test and it passes. The diff stat looks reasonably, so I
am comfortable giving my ACK, or do you really want me to check if you
haven't changed any function? :)

Michal

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


Re: [libvirt] [PATCH 12/12] libxl: Add libxlDomObjFromDomain

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Similar to the QEMU and LXC drivers, add a helper function to
 lookup a domain, and use it instead of much copy and paste.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_driver.c | 269 
 ++-
  1 file changed, 56 insertions(+), 213 deletions(-)

ACK

Michal

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


Re: [libvirt] [PATCH 04/12] libxl: Add libxl_version_info to libxlDriverPrivate

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 libxl version info is static data as far as the libxl driver
 is concerned, so retrieve this info when the driver is initialized
 and stash it in the libxlDriverPrivate object.  Subsequently use
 the stashed info instead of repeatedly calling libxl_get_version_info().
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   |  7 +--
  src/libxl/libxl_conf.h   |  1 +
  src/libxl/libxl_driver.c | 39 ---
  3 files changed, 10 insertions(+), 37 deletions(-)

ACK

Michal

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


Re: [libvirt] [PATCH 01/12] libxl: Move detection of autoballoon to libxl_conf

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Detecting whether or not to autoballoon is configuration related,
 so move the code to libxl_conf.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   | 22 ++
  src/libxl/libxl_conf.h   |  3 +++
  src/libxl/libxl_driver.c | 25 +
  3 files changed, 26 insertions(+), 24 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
 index 8129c7f..f8937a4 100644
 --- a/src/libxl/libxl_conf.c
 +++ b/src/libxl/libxl_conf.c
 @@ -978,6 +978,28 @@ error:
  return -1;
  }
  
 +bool
 +libxlGetAutoballoonConf(libxlDriverPrivatePtr driver)
 +{
 +const libxl_version_info *info;
 +regex_t regex;
 +int ret;
 +
 +info = libxl_get_version_info(driver-ctx);
 +if (!info)
 +return true; /* default to on */
 +
 +ret = regcomp(regex,
 +(^| )dom0_mem=((|min:|max:)[0-9]+[bBkKmMgG]?,?)+($| ),
 +REG_NOSUB | REG_EXTENDED);
 +if (ret)
 +return true;

Pre-existing, but if we fail to compile the regex, shouldn't we error out?

 +
 +ret = regexec(regex, info-commandline, 0, NULL, 0);
 +regfree(regex);
 +return ret == REG_NOMATCH;
 +}
 +

ACK

Michal

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


Re: [libvirt] [PATCH 03/12] libxl: Earlier detection of not running on Xen

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Detect early on in libxl driver initialization if the driver
 should be loaded at all, avoiding needless initialization steps
 that only have to be undone later.  While at it, move th

s/th/the/

 detection to a helper function to improve readability.
 
 After detecting that the driver should be loaded, subsequent
 failures such as initializing the log stream, allocating libxl
 ctx, etc. should be treated as failure to initialize the driver.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_driver.c | 62 
 +++-
  1 file changed, 40 insertions(+), 22 deletions(-)
 
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index ff4f6be..759fed5 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -775,34 +775,54 @@ libxlStateCleanup(void)
  return 0;
  }
  
 -static int
 -libxlStateInitialize(bool privileged,
 - virStateInhibitCallback callback ATTRIBUTE_UNUSED,
 - void *opaque ATTRIBUTE_UNUSED)
 +static bool
 +libxlDriverShouldLoad(bool privileged)
  {
 -const libxl_version_info *ver_info;
 -char *log_file = NULL;
 +bool ret = false;
  virCommandPtr cmd;
 -int status, ret = 0;
 -unsigned int free_mem;
 -char ebuf[1024];
 +int status;
  
 -/* Disable libxl driver if non-root */
 +/* Don't load if non-root */
  if (!privileged) {
  VIR_INFO(Not running privileged, disabling libxenlight driver);
 -return 0;
 +return ret;
 +}
 +
 +/* Don't load if not running on a Xen control domain (dom0) */
 +if (!virFileExists(/proc/xen/capabilities)) {
 +VIR_INFO(No Xen capabilities detected, probably not running 
 + in a Xen Dom0.  Disabling libxenlight driver);
 +
 +return ret;
  }
  
 -/* Disable driver if legacy xen toolstack (xend) is in use */
 +   /* Don't load if legacy xen toolstack (xend) is in use */

Indentation off.

  cmd = virCommandNewArgList(/usr/sbin/xend, status, NULL);
  if (virCommandRun(cmd, status) == 0  status == 0) {
  VIR_INFO(Legacy xen tool stack seems to be in use, disabling 
libxenlight driver.);
 -virCommandFree(cmd);
 -return 0;
 +} else {
 +ret = true;
  }
  virCommandFree(cmd);
  
 +return ret;
 +}
 +
 +static int
 +libxlStateInitialize(bool privileged,
 + virStateInhibitCallback callback ATTRIBUTE_UNUSED,
 + void *opaque ATTRIBUTE_UNUSED)
 +{
 +const libxl_version_info *ver_info;
 +char *log_file = NULL;
 +int ret = 0;
 +unsigned int free_mem;
 +char ebuf[1024];
 +
 +if (!libxlDriverShouldLoad(privileged))
 +return 0;
 +
  if (VIR_ALLOC(libxl_driver)  0)
  return -1;
  
 @@ -883,21 +903,20 @@ libxlStateInitialize(bool privileged,
  libxl_driver-logger =
  (xentoollog_logger 
 *)xtl_createlogger_stdiostream(libxl_driver-logger_file, XTL_DEBUG, 0);
  if (!libxl_driver-logger) {
 -VIR_INFO(cannot create logger for libxenlight, disabling driver);
 -goto fail;
 +VIR_ERROR(_(Failed to create logger for libxenlight));
 +goto error;
  }
  
  if (libxl_ctx_alloc(libxl_driver-ctx,
 LIBXL_VERSION, 0,
 libxl_driver-logger)) {
 -VIR_INFO(cannot initialize libxenlight context, probably not 
 running 
 - in a Xen Dom0, disabling driver);
 -goto fail;
 +VIR_ERROR(_(Failed to initialize libxenlight context));
 +goto error;
  }
  
  if ((ver_info = libxl_get_version_info(libxl_driver-ctx)) == NULL) {
 -VIR_INFO(cannot version information from libxenlight, disabling 
 driver);
 -goto fail;
 +VIR_ERROR(_(Failed to get version information from libxenlight));
 +goto error;
  }
  libxl_driver-version = (ver_info-xen_version_major * 100) +
  (ver_info-xen_version_minor * 1000);
 @@ -956,7 +975,6 @@ libxlStateInitialize(bool privileged,
  
  error:
  ret = -1;
 -fail:
  VIR_FREE(log_file);
  if (libxl_driver)
  libxlDriverUnlock(libxl_driver);
 

ACK with those two nits fixed.

Michal

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


Re: [libvirt] [PATCH 09/12] libxl: Add comments to libxlDriverPrivate fields

2013-09-02 Thread Michal Privoznik
On 30.08.2013 23:46, Jim Fehlig wrote:
 Similar to the QEMU and LXC drivers, annotate the fields of
 libxlDriverPrivate struct to indicate the locking rules for
 their use.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.h | 7 +++
  1 file changed, 7 insertions(+)
 
 diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
 index 83bb6b9..95e0983 100644
 --- a/src/libxl/libxl_conf.h
 +++ b/src/libxl/libxl_conf.h
 @@ -90,19 +90,26 @@ struct _libxlDriverPrivate {
   * then lockless thereafter */
  libxlDriverConfigPtr config;
  
 +/* Atomic inc/dec only */
  unsigned int nactive;
  
 +/* Immutable pointers. Caller must provide locking */
  virStateInhibitCallback inhibitCallback;
  void *inhibitOpaque;
  
 +/* Immutable pointer, self-locking APIs */
  virDomainObjListPtr domains;
  
 +/* Immutable pointer, immutable object */
  virDomainXMLOptionPtr xmlopt;
  
 +/* Immutable pointer, self-locking APIs */
  virDomainEventStatePtr domainEventState;
  
 +/* Immutable pointer, self-locking APIs */
  virPortAllocatorPtr reservedVNCPorts;
  
 +/* Immutable pointer, lockless APIs*/
  virSysinfoDefPtr hostsysinfo;
  };
  
 

ACK

Michal

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


Re: [libvirt] [PATCH 01/12] libxl: Move detection of autoballoon to libxl_conf

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:47PM -0600, Jim Fehlig wrote:
 Detecting whether or not to autoballoon is configuration related,
 so move the code to libxl_conf.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   | 22 ++
  src/libxl/libxl_conf.h   |  3 +++
  src/libxl/libxl_driver.c | 25 +
  3 files changed, 26 insertions(+), 24 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH 02/12] libxl: Introduce libxl_domain.[ch]

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:48PM -0600, Jim Fehlig wrote:
 Create libxl_domain.[ch] and move all functions operating on
 libxlDomainObjPrivate to these files.  This will be useful for
 future patches that e.g. add job support for libxlDomainObjPrivate.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  po/POTFILES.in   |   1 +
  src/Makefile.am  |   1 +
  src/libxl/libxl_conf.c   |   2 +-
  src/libxl/libxl_conf.h   |  18 --
  src/libxl/libxl_domain.c | 469 
 +++
  src/libxl/libxl_domain.h |  61 ++
  src/libxl/libxl_driver.c | 436 +--
  7 files changed, 535 insertions(+), 453 deletions(-)
 
 diff --git a/po/POTFILES.in b/po/POTFILES.in
 index 9a83069..281274e 100644
 --- a/po/POTFILES.in
 +++ b/po/POTFILES.in
 @@ -67,6 +67,7 @@ src/lxc/lxc_conf.c
  src/lxc/lxc_controller.c
  src/lxc/lxc_driver.c
  src/lxc/lxc_process.c
 +src/libxl/libxl_domain.c
  src/libxl/libxl_driver.c
  src/libxl/libxl_conf.c
  src/network/bridge_driver.c
 diff --git a/src/Makefile.am b/src/Makefile.am
 index d8b943d..82aefe3 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -657,6 +657,7 @@ XENAPI_DRIVER_SOURCES =   
 \
  
  LIBXL_DRIVER_SOURCES =   \
   libxl/libxl_conf.c libxl/libxl_conf.h   \
 + libxl/libxl_domain.c libxl/libxl_domain.h   \
   libxl/libxl_driver.c libxl/libxl_driver.h
  
  UML_DRIVER_SOURCES = \
 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
 index f8937a4..f9ffe5d 100644
 --- a/src/libxl/libxl_conf.c
 +++ b/src/libxl/libxl_conf.c
 @@ -39,7 +39,7 @@
  #include viralloc.h
  #include viruuid.h
  #include capabilities.h
 -#include libxl_driver.h
 +#include libxl_domain.h
  #include libxl_conf.h
  #include libxl_utils.h
  #include virstoragefile.h
 diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
 index 0498012..68e770c 100644
 --- a/src/libxl/libxl_conf.h
 +++ b/src/libxl/libxl_conf.h
 @@ -89,24 +89,6 @@ struct _libxlDriverPrivate {
  typedef struct _libxlEventHookInfo libxlEventHookInfo;
  typedef libxlEventHookInfo *libxlEventHookInfoPtr;
  
 -typedef struct _libxlDomainObjPrivate libxlDomainObjPrivate;
 -typedef libxlDomainObjPrivate *libxlDomainObjPrivatePtr;
 -struct _libxlDomainObjPrivate {
 -virObjectLockable parent;
 -
 -/* per domain log stream for libxl messages */
 -FILE *logger_file;
 -xentoollog_logger *logger;
 -/* per domain libxl ctx */
 -libxl_ctx *ctx;
 -/* console */
 -virChrdevsPtr devs;
 -libxl_evgen_domain_death *deathW;
 -
 -/* list of libxl timeout registrations */
 -libxlEventHookInfoPtr timerRegistrations;
 -};
 -
  # define LIBXL_SAVE_MAGIC libvirt-xml\n \0 \r
  # define LIBXL_SAVE_VERSION 1
  
 diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
 new file mode 100644
 index 000..1d03797
 --- /dev/null
 +++ b/src/libxl/libxl_domain.c
 @@ -0,0 +1,469 @@
 +/*---*/
 +/*  Copyright (C) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.

It is a pretty minor nitpick, but the normal style 

/*
 * filename.h: blah description blah
 *
 * Copyright (C) 2013 


without any '/*---'


 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library.  If not, see
 + * http://www.gnu.org/licenses/.
 + *
 + * Authors:
 + * Jim Fehlig jfeh...@suse.com
 + */
 +/*---*/

Can remove the '--' here too


 diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
 new file mode 100644
 index 000..2797d38
 --- /dev/null
 +++ b/src/libxl/libxl_domain.h
 @@ -0,0 +1,61 @@
 +/*---*/
 +/*  Copyright (C) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * 

Re: [libvirt] [PATCH 03/12] libxl: Earlier detection of not running on Xen

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:49PM -0600, Jim Fehlig wrote:
 Detect early on in libxl driver initialization if the driver
 should be loaded at all, avoiding needless initialization steps
 that only have to be undone later.  While at it, move th
 detection to a helper function to improve readability.
 
 After detecting that the driver should be loaded, subsequent
 failures such as initializing the log stream, allocating libxl
 ctx, etc. should be treated as failure to initialize the driver.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_driver.c | 62 
 +++-
  1 file changed, 40 insertions(+), 22 deletions(-)
 
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index ff4f6be..759fed5 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -775,34 +775,54 @@ libxlStateCleanup(void)
  return 0;
  }
  
 -static int
 -libxlStateInitialize(bool privileged,
 - virStateInhibitCallback callback ATTRIBUTE_UNUSED,
 - void *opaque ATTRIBUTE_UNUSED)
 +static bool
 +libxlDriverShouldLoad(bool privileged)
  {
 -const libxl_version_info *ver_info;
 -char *log_file = NULL;
 +bool ret = false;
  virCommandPtr cmd;
 -int status, ret = 0;
 -unsigned int free_mem;
 -char ebuf[1024];
 +int status;
  
 -/* Disable libxl driver if non-root */
 +/* Don't load if non-root */
  if (!privileged) {
  VIR_INFO(Not running privileged, disabling libxenlight driver);
 -return 0;
 +return ret;
 +}
 +
 +/* Don't load if not running on a Xen control domain (dom0) */
 +if (!virFileExists(/proc/xen/capabilities)) {
 +VIR_INFO(No Xen capabilities detected, probably not running 
 + in a Xen Dom0.  Disabling libxenlight driver);
 +
 +return ret;
  }
  
 -/* Disable driver if legacy xen toolstack (xend) is in use */
 +   /* Don't load if legacy xen toolstack (xend) is in use */

Indentation typo

  cmd = virCommandNewArgList(/usr/sbin/xend, status, NULL);
  if (virCommandRun(cmd, status) == 0  status == 0) {
  VIR_INFO(Legacy xen tool stack seems to be in use, disabling 
libxenlight driver.);
 -virCommandFree(cmd);
 -return 0;
 +} else {
 +ret = true;
  }
  virCommandFree(cmd);
  
 +return ret;
 +}
 +
 +static int
 +libxlStateInitialize(bool privileged,
 + virStateInhibitCallback callback ATTRIBUTE_UNUSED,
 + void *opaque ATTRIBUTE_UNUSED)
 +{
 +const libxl_version_info *ver_info;
 +char *log_file = NULL;
 +int ret = 0;
 +unsigned int free_mem;
 +char ebuf[1024];
 +
 +if (!libxlDriverShouldLoad(privileged))
 +return 0;
 +
  if (VIR_ALLOC(libxl_driver)  0)
  return -1;
  
 @@ -883,21 +903,20 @@ libxlStateInitialize(bool privileged,
  libxl_driver-logger =
  (xentoollog_logger 
 *)xtl_createlogger_stdiostream(libxl_driver-logger_file, XTL_DEBUG, 0);
  if (!libxl_driver-logger) {
 -VIR_INFO(cannot create logger for libxenlight, disabling driver);
 -goto fail;
 +VIR_ERROR(_(Failed to create logger for libxenlight));
 +goto error;
  }
  
  if (libxl_ctx_alloc(libxl_driver-ctx,
 LIBXL_VERSION, 0,
 libxl_driver-logger)) {
 -VIR_INFO(cannot initialize libxenlight context, probably not 
 running 
 - in a Xen Dom0, disabling driver);
 -goto fail;
 +VIR_ERROR(_(Failed to initialize libxenlight context));
 +goto error;
  }
  
  if ((ver_info = libxl_get_version_info(libxl_driver-ctx)) == NULL) {
 -VIR_INFO(cannot version information from libxenlight, disabling 
 driver);
 -goto fail;
 +VIR_ERROR(_(Failed to get version information from libxenlight));


For the errors here, it is preferrable to use  virReportError() which will
in turn call VIR_ERROR anywway.

 +goto error;
  }
  libxl_driver-version = (ver_info-xen_version_major * 100) +
  (ver_info-xen_version_minor * 1000);
 @@ -956,7 +975,6 @@ libxlStateInitialize(bool privileged,
  
  error:
  ret = -1;
 -fail:
  VIR_FREE(log_file);
  if (libxl_driver)
  libxlDriverUnlock(libxl_driver);


ACK

if the error reporting is changed


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

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


Re: [libvirt] [PATCH 02/12] libxl: Introduce libxl_domain.[ch]

2013-09-02 Thread Daniel P. Berrange
On Mon, Sep 02, 2013 at 12:22:40PM +0100, Daniel P. Berrange wrote:
 On Fri, Aug 30, 2013 at 03:46:48PM -0600, Jim Fehlig wrote:
  Create libxl_domain.[ch] and move all functions operating on
  libxlDomainObjPrivate to these files.  This will be useful for
  future patches that e.g. add job support for libxlDomainObjPrivate.
  
  Signed-off-by: Jim Fehlig jfeh...@suse.com
  ---
   po/POTFILES.in   |   1 +
   src/Makefile.am  |   1 +
   src/libxl/libxl_conf.c   |   2 +-
   src/libxl/libxl_conf.h   |  18 --
   src/libxl/libxl_domain.c | 469 
  +++
   src/libxl/libxl_domain.h |  61 ++
   src/libxl/libxl_driver.c | 436 +--
   7 files changed, 535 insertions(+), 453 deletions(-)
  
  diff --git a/po/POTFILES.in b/po/POTFILES.in
  index 9a83069..281274e 100644
  --- a/po/POTFILES.in
  +++ b/po/POTFILES.in
  @@ -67,6 +67,7 @@ src/lxc/lxc_conf.c
   src/lxc/lxc_controller.c
   src/lxc/lxc_driver.c
   src/lxc/lxc_process.c
  +src/libxl/libxl_domain.c
   src/libxl/libxl_driver.c
   src/libxl/libxl_conf.c
   src/network/bridge_driver.c
  diff --git a/src/Makefile.am b/src/Makefile.am
  index d8b943d..82aefe3 100644
  --- a/src/Makefile.am
  +++ b/src/Makefile.am
  @@ -657,6 +657,7 @@ XENAPI_DRIVER_SOURCES = 
  \
   
   LIBXL_DRIVER_SOURCES = \
  libxl/libxl_conf.c libxl/libxl_conf.h   \
  +   libxl/libxl_domain.c libxl/libxl_domain.h   \
  libxl/libxl_driver.c libxl/libxl_driver.h
   
   UML_DRIVER_SOURCES =   \
  diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
  index f8937a4..f9ffe5d 100644
  --- a/src/libxl/libxl_conf.c
  +++ b/src/libxl/libxl_conf.c
  @@ -39,7 +39,7 @@
   #include viralloc.h
   #include viruuid.h
   #include capabilities.h
  -#include libxl_driver.h
  +#include libxl_domain.h
   #include libxl_conf.h
   #include libxl_utils.h
   #include virstoragefile.h
  diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
  index 0498012..68e770c 100644
  --- a/src/libxl/libxl_conf.h
  +++ b/src/libxl/libxl_conf.h
  @@ -89,24 +89,6 @@ struct _libxlDriverPrivate {
   typedef struct _libxlEventHookInfo libxlEventHookInfo;
   typedef libxlEventHookInfo *libxlEventHookInfoPtr;
   
  -typedef struct _libxlDomainObjPrivate libxlDomainObjPrivate;
  -typedef libxlDomainObjPrivate *libxlDomainObjPrivatePtr;
  -struct _libxlDomainObjPrivate {
  -virObjectLockable parent;
  -
  -/* per domain log stream for libxl messages */
  -FILE *logger_file;
  -xentoollog_logger *logger;
  -/* per domain libxl ctx */
  -libxl_ctx *ctx;
  -/* console */
  -virChrdevsPtr devs;
  -libxl_evgen_domain_death *deathW;
  -
  -/* list of libxl timeout registrations */
  -libxlEventHookInfoPtr timerRegistrations;
  -};
  -
   # define LIBXL_SAVE_MAGIC libvirt-xml\n \0 \r
   # define LIBXL_SAVE_VERSION 1
   
  diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
  new file mode 100644
  index 000..1d03797
  --- /dev/null
  +++ b/src/libxl/libxl_domain.c
  @@ -0,0 +1,469 @@
  +/*---*/
  +/*  Copyright (C) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
 
 It is a pretty minor nitpick, but the normal style 
 
 /*
  * filename.h: blah description blah
  *
  * Copyright (C) 2013 
 
 
 without any '/*---'
 
 
  + *
  + * This library is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU Lesser General Public
  + * License as published by the Free Software Foundation; either
  + * version 2.1 of the License, or (at your option) any later version.
  + *
  + * This library is distributed in the hope that it will be useful,
  + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  + * Lesser General Public License for more details.
  + *
  + * You should have received a copy of the GNU Lesser General Public
  + * License along with this library.  If not, see
  + * http://www.gnu.org/licenses/.
  + *
  + * Authors:
  + * Jim Fehlig jfeh...@suse.com
  + */
  +/*---*/
 
 Can remove the '--' here too
 
 
  diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
  new file mode 100644
  index 000..2797d38
  --- /dev/null
  +++ b/src/libxl/libxl_domain.h
  @@ -0,0 +1,61 @@
  +/*---*/
  +/*  Copyright (C) 2011-2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
  + *
  + * This library is free software; you can redistribute it and/or
  + * modify it under the terms of the GNU Lesser General Public
  + * License as 

Re: [libvirt] [PATCH 04/12] libxl: Add libxl_version_info to libxlDriverPrivate

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:50PM -0600, Jim Fehlig wrote:
 libxl version info is static data as far as the libxl driver
 is concerned, so retrieve this info when the driver is initialized
 and stash it in the libxlDriverPrivate object.  Subsequently use
 the stashed info instead of repeatedly calling libxl_get_version_info().
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   |  7 +--
  src/libxl/libxl_conf.h   |  1 +
  src/libxl/libxl_driver.c | 39 ---
  3 files changed, 10 insertions(+), 37 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH 06/12] libxl: User per-domain ctx in libxlDomainGetInfo

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:52PM -0600, Jim Fehlig wrote:
 libxlDomainGetInfo() uses the driver-wide libxl ctx when
 it would be more appropriate to use the per-domain ctx
 associated with the domain.  Switch to using the per-domain
 libxl ctx.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_driver.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

ACK

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

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


Re: [libvirt] [PATCH 05/12] libxl: libxl: Use per-domain ctx in libxlMakeDomCreateInfo

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:51PM -0600, Jim Fehlig wrote:
 libxlMakeDomCreateInfo() uses the driver-wide libxl ctx when
 it would be more appropriate to use the per-domain ctx
 associated with the domain.  Switch to using the per-domain
 libxl ctx.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c | 7 ---
  1 file changed, 4 insertions(+), 3 deletions(-)

ACK

This would help any future work to make locking more fine grained.

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

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


Re: [libvirt] [PATCH 07/12] libxl: Introduce libxlDriverConfig object

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:53PM -0600, Jim Fehlig wrote:
 The libxlDriverPrivate struct contains an variety of data with
 varying access needs. Similar to the QEMU and LXC drivers,
 move all the static config data into a dedicated libxlDriverConfig
 object. The only locking requirement is to hold the driver lock
 while obtaining an instance of libxlDriverConfig. Once a reference
 is held on the config object, it can be used completely lockless
 since it is immutable.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   | 124 ++-
  src/libxl/libxl_conf.h   |  52 +---
  src/libxl/libxl_driver.c | 313 
 +++
  3 files changed, 309 insertions(+), 180 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH 09/12] libxl: Add comments to libxlDriverPrivate fields

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:55PM -0600, Jim Fehlig wrote:
 Similar to the QEMU and LXC drivers, annotate the fields of
 libxlDriverPrivate struct to indicate the locking rules for
 their use.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.h | 7 +++
  1 file changed, 7 insertions(+)

ACK


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

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


Re: [libvirt] [PATCH 08/12] libxl: Use atomic ops for driver-nactive

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:54PM -0600, Jim Fehlig wrote:
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.h   |  2 +-
  src/libxl/libxl_driver.c | 10 --
  2 files changed, 5 insertions(+), 7 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
 index e3875ba..83bb6b9 100644
 --- a/src/libxl/libxl_conf.h
 +++ b/src/libxl/libxl_conf.h
 @@ -90,7 +90,7 @@ struct _libxlDriverPrivate {
   * then lockless thereafter */
  libxlDriverConfigPtr config;
  
 -size_t nactive;
 +unsigned int nactive;
  
  virStateInhibitCallback inhibitCallback;
  void *inhibitOpaque;
 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index e604899..7615cdd 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -50,6 +50,7 @@
  #include virstring.h
  #include virsysinfo.h
  #include viraccessapicheck.h
 +#include viratomic.h
  
  #define VIR_FROM_THIS VIR_FROM_LIBXL
  
 @@ -265,8 +266,7 @@ libxlVmCleanup(libxlDriverPrivatePtr driver,
  virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
  }
  
 -driver-nactive--;
 -if (!driver-nactive  driver-inhibitCallback)
 +if (virAtomicIntDecAndTest(driver-nactive)  driver-inhibitCallback)
  driver-inhibitCallback(false, driver-inhibitOpaque);
  
  if ((vm-def-ngraphics == 1) 
 @@ -655,9 +655,8 @@ libxlVmStart(libxlDriverPrivatePtr driver, 
 virDomainObjPtr vm,
  if (virDomainSaveStatus(driver-xmlopt, cfg-stateDir, vm)  0)
  goto error;
  
 -if (!driver-nactive  driver-inhibitCallback)
 +if (virAtomicIntInc(driver-nactive)  driver-inhibitCallback)
  driver-inhibitCallback(true, driver-inhibitOpaque);
 -driver-nactive++;
  
  event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED,
   restore_fd  0 ?
 @@ -727,9 +726,8 @@ libxlReconnectDomain(virDomainObjPtr vm,
  vm-def-id = d_info.domid;
  virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNKNOWN);
  
 -if (!driver-nactive  driver-inhibitCallback)
 +if (virAtomicIntInc(driver-nactive)  driver-inhibitCallback)
  driver-inhibitCallback(true, driver-inhibitOpaque);
 -driver-nactive++;
  
  /* Recreate domain death et. al. events */
  libxlCreateDomEvents(vm);

ACK if you fix Michael's comments


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

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


Re: [libvirt] [PATCH 10/12] libxl: Move driver lock/unlock to libxl_conf

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:56PM -0600, Jim Fehlig wrote:
 Move the libxl driver lock/unlock functions from libxl_driver.c
 to libxl_conf.h so they can be used by other source files.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.h   | 12 
  src/libxl/libxl_driver.c | 12 
  2 files changed, 12 insertions(+), 12 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH 11/12] libxl: Remove unnecessary driver locking

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:57PM -0600, Jim Fehlig wrote:
 Now that most fields of libxlDriverPrivate struct are immutable
 or self-locking, there is no need to acquire the driver lock in
 much of the libxl driver.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_conf.c   |   7 +-
  src/libxl/libxl_driver.c | 217 
 +--
  2 files changed, 46 insertions(+), 178 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH 12/12] libxl: Add libxlDomObjFromDomain

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 03:46:58PM -0600, Jim Fehlig wrote:
 Similar to the QEMU and LXC drivers, add a helper function to
 lookup a domain, and use it instead of much copy and paste.
 
 Signed-off-by: Jim Fehlig jfeh...@suse.com
 ---
  src/libxl/libxl_driver.c | 269 
 ++-
  1 file changed, 56 insertions(+), 213 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH] build: only create virt-login-shell for lxc builds

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 02:37:20PM -0600, Eric Blake wrote:
 I noticed from an ./autobuild.sh run that we were installing a
 virt-login-shell.exe binary when cross-building for mingw,
 even though such a binary is necessarily worthless since the
 code depends on lxc which is a Linux-only concept.
 
 * tools/Makefile.am (conf_DATA, bin_PROGRAMS, dist_man1_MANS):
 Make virt-login-shell installation conditional.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
 
 I'm debating about pushing this under the build-breaker rule.
 
  tools/Makefile.am | 14 +++---
  1 file changed, 11 insertions(+), 3 deletions(-)

Unfortunately this will now break the libvirt.spec.in if
%{with_lxc} is set to 0. Fortunately we don't do that by
default for any platforms we support but still nice to
fix it

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

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


Re: [libvirt] [PATCH 2/2] Pass AM_LDFLAGS to driver modules too

2013-09-02 Thread Daniel P. Berrange
On Sun, Sep 01, 2013 at 11:31:01AM +0200, Guido Günther wrote:
 This gives us a RO got, otherwise Debian's lintian complains:
 
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_qemu.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_storage.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_uml.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_vbox.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_nwfilter.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_storage.so
 W: libvirt-bin: hardening-no-relro 
 usr/lib/libvirt/connection-driver/libvirt_driver_uml.so
 W: libvirt-sanlock: hardening-no-relro usr/lib/libvirt/lock-driver/sanlock.so
 ---
  src/Makefile.am | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)


Ahhh, good catch by Debian!

ACK

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

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

Re: [libvirt] [PATCHv5 1/5] domifaddr: Implement the public APIs

2013-09-02 Thread Daniel P. Berrange
On Sun, Sep 01, 2013 at 07:13:31PM +0530, Nehal J Wani wrote:
 Define a new API virDomainInterfaceAddresses, which returns
 the address information of a running domain's interfaces(s).
 If no interface name is specified, it returns the information
 of all interfaces, otherwise it only returns the information
 of the specificed interface. The address information includes
 the MAC and IP addresses.
 
 Define helper function virDomainInterfaceFree, which allows
 the upper layer application to free the domain interface object
 conveniently.
 
 The API is going to provide multiple methods by flags, e.g.
 
   * Query guest agent
   * Parse lease file of dnsmasq
   * DHCP snooping
 
 But at this stage, it will only work with guest agent, and flags
 won't be supported.
 
 include/libvirt/libvirt.h.in:
   * Define virDomainInterfaceAddresses, virDomainInterfaceFree
   * Define structs virDomainInterface, virDomainIPAddress
 
 python/generator.py:
   * Skip the auto-generation for virDomainInterfaceAddresses
 and virDomainInterfaceFree
 
 src/driver.h:
   * Define domainInterfaceAddresses
 
 src/libvirt.c:
   * Implement virDomainInterfaceAddresses
   * Implement virDomainInterfaceFree
 
 src/libvirt_public.syms:
   * Export the new symbols
 
 ---
  include/libvirt/libvirt.h.in |  32 
  python/generator.py  |   3 ++
  src/driver.h |   6 +++
  src/libvirt.c| 115 
 +++
  src/libvirt_public.syms  |   6 +++
  5 files changed, 162 insertions(+)

ACK

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

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


Re: [libvirt] [PATCH 1/2] Fix AM_LDFLAGS typo

2013-09-02 Thread Daniel P. Berrange
On Sun, Sep 01, 2013 at 11:30:46AM +0200, Guido Günther wrote:
 ---
 This should probably go into 1.1.2
 
  src/Makefile.am | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/Makefile.am b/src/Makefile.am
 index 636bcbc..19dfb81 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -1455,7 +1455,7 @@ libvirt_driver_nwfilter_la_CFLAGS = \
   -I$(top_srcdir)/src/access \
   -I$(top_srcdir)/src/conf \
   $(AM_CFLAGS)
 -libvirt_driver_nwfilter_la_LDFLAGS = $(LD_AMFLAGS)
 +libvirt_driver_nwfilter_la_LDFLAGS = $(AM_LDFLAGS)
  libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS) $(LIBNL_LIBS) 
 $(DBUS_LIBS)
  if WITH_DRIVER_MODULES
  libvirt_driver_nwfilter_la_LIBADD += ../gnulib/lib/libgnu.la

ACK


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

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

Re: [libvirt] [PATCHv5 2/5] domifaddr: Implement the remote protocol

2013-09-02 Thread Daniel P. Berrange
On Sun, Sep 01, 2013 at 07:13:32PM +0530, Nehal J Wani wrote:
 daemon/remote.c
* Define remoteSerializeDomainInterface, 
 remoteDispatchDomainInterfaceAddresses
 
 src/remote/remote_driver.c
* Define remoteDomainInterfaceAddresses
 
 src/remote/remote_protocol.x
* New RPC procedure: REMOTE_PROC_DOMAIN_INTERFACE_ADDRESSES
* Define structs remote_domain_ip_addr, remote_domain_interface,
  remote_domain_interfaces_addresse_args, 
 remote_domain_interface_addresses_ret
* Introduce upper bounds (to handle DDoS attacks):
  REMOTE_DOMAIN_INTERFACE_MAX = 2048
  REMOTE_DOMAIN_IP_ADDR_MAX = 2048
  Restrictions on the maximum number of aliases per interface were
  removed after kernel v2.0, and theoretically, at present, there
  are no upper limits on number of interfaces per virtual machine
  and on the number of IP addresses per interface.
 
 src/remote_protocol-structs
* New structs added
 
 ---
  daemon/remote.c  | 131 
 +++
  src/remote/remote_driver.c   |  99 
  src/remote/remote_protocol.x |  40 -
  src/remote_protocol-structs  |  24 
  4 files changed, 293 insertions(+), 1 deletion(-)
 
 diff --git a/daemon/remote.c b/daemon/remote.c
 index 6ace7af..7091cab 100644
 --- a/daemon/remote.c
 +++ b/daemon/remote.c
 @@ -5144,7 +5144,138 @@ cleanup:

 +
 +static int
 +remoteDispatchDomainInterfaceAddresses(
 +virNetServerPtr server ATTRIBUTE_UNUSED,
 +virNetServerClientPtr client,
 +virNetMessagePtr msg ATTRIBUTE_UNUSED,
 +virNetMessageErrorPtr rerr,
 +remote_domain_interface_addresses_args *args,
 +remote_domain_interface_addresses_ret *ret)

Normal practice for this file is to layout args thus:

 static int
 remoteDispatchDomainInterfaceAddresses(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
remote_domain_interface_addresses_args 
*args,
remote_domain_interface_addresses_ret 
*ret)



ACK if the style issue is fixed


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

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


[libvirt] [PATCH] storage: new backend: btrfs subvolumes

2013-09-02 Thread Oskari Saarenmaa
This commit adds a new storage pool driver, btrfs, which can be used to
manage btrfs subvolumes on an existing btrfs filesystem.  The driver can
create new blank subvolumes and snapshots of existing subvolumes as well
as delete existing subvolumes.

The subvolumes created are automatically made visible on the host side
and can be attached to domains using the filesystem tags as defined in
'format domain' documentation.

Libvirt volumes do not implement quotas at the moment because the current
(btrfs-progs-0.20.rc1.20130501git7854c8b-4.fc20.x86_64) support for quota
management in btrfs-progs is lacking the necessary features, for example
it's not possible to see the quota assigned to a certain subvolume and
usage information is only updated on syncfs(2).  Quota support will be
implemented once the tools gain the necessary features.

Signed-off-by: Oskari Saarenmaa o...@ohmu.fi
---
 configure.ac  |  23 +-
 docs/drivers.html.in  |   1 +
 docs/schemas/storagepool.rng  |  11 +
 docs/storage.html.in  |  60 +
 include/libvirt/libvirt.h.in  |   1 +
 libvirt.spec.in   |   2 +
 src/Makefile.am   |   8 +
 src/conf/storage_conf.c   |  12 +-
 src/conf/storage_conf.h   |   1 +
 src/storage/storage_backend.c |   6 +
 src/storage/storage_backend_btrfs.c   | 284 ++
 src/storage/storage_backend_btrfs.h   |  30 +++
 tests/storagepoolxml2xmlin/pool-btrfs.xml |   7 +
 tests/storagepoolxml2xmlout/pool-btrfs.xml|  17 ++
 tests/storagepoolxml2xmltest.c|   1 +
 tests/storagevolxml2xmlin/vol-btrfs-snapshot.xml  |  11 +
 tests/storagevolxml2xmlin/vol-btrfs.xml   |   8 +
 tests/storagevolxml2xmlout/vol-btrfs-snapshot.xml |  26 ++
 tests/storagevolxml2xmlout/vol-btrfs.xml  |  17 ++
 tests/storagevolxml2xmltest.c |   2 +
 20 files changed, 525 insertions(+), 3 deletions(-)
 create mode 100644 src/storage/storage_backend_btrfs.c
 create mode 100644 src/storage/storage_backend_btrfs.h
 create mode 100644 tests/storagepoolxml2xmlin/pool-btrfs.xml
 create mode 100644 tests/storagepoolxml2xmlout/pool-btrfs.xml
 create mode 100644 tests/storagevolxml2xmlin/vol-btrfs-snapshot.xml
 create mode 100644 tests/storagevolxml2xmlin/vol-btrfs.xml
 create mode 100644 tests/storagevolxml2xmlout/vol-btrfs-snapshot.xml
 create mode 100644 tests/storagevolxml2xmlout/vol-btrfs.xml

diff --git a/configure.ac b/configure.ac
index f853e03..100c87d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1562,6 +1562,8 @@ AC_ARG_WITH([storage-rbd],
   AC_HELP_STRING([--with-storage-rbd], [with RADOS Block Device backend for 
the storage driver @:@default=check@:@]),[],[with_storage_rbd=check])
 AC_ARG_WITH([storage-sheepdog],
   AC_HELP_STRING([--with-storage-sheepdog], [with Sheepdog backend for the 
storage driver @:@default=check@:@]),[],[with_storage_sheepdog=check])
+AC_ARG_WITH([storage-btrfs],
+  AC_HELP_STRING([--with-storage-btrfs], [with Btrfs backend for the storage 
driver @:@default=check@:@]),[],[with_storage_btrfs=check])
 
 if test $with_libvirtd = no; then
   with_storage_dir=no
@@ -1774,6 +1776,24 @@ fi
 AM_CONDITIONAL([WITH_STORAGE_SHEEPDOG],
   [test $with_storage_sheepdog = yes])
 
+if test $with_storage_btrfs = yes || test $with_storage_btrfs = check; 
then
+  AC_PATH_PROG([BTRFS], [btrfs], [], [$PATH:/sbin:/usr/sbin])
+
+  if test $with_storage_btrfs = yes ; then
+if test -z $BTRFS ; then AC_MSG_ERROR([We need btrfs -command for btrfs 
storage driver]) ; fi
+  else
+if test -z $BTRFS ; then with_storage_btrfs=no ; fi
+if test $with_storage_btrfs = check ; then with_storage_btrfs=yes ; fi
+  fi
+
+  if test $with_storage_btrfs = yes ; then
+AC_DEFINE_UNQUOTED([WITH_STORAGE_BTRFS], 1, [whether Btrfs backend for 
storage driver is enabled])
+AC_DEFINE_UNQUOTED([BTRFS],[$BTRFS],[Location of btrfs program])
+  fi
+fi
+AM_CONDITIONAL([WITH_STORAGE_BTRFS], [test $with_storage_btrfs = yes])
+
+
 
 LIBPARTED_CFLAGS=
 LIBPARTED_LIBS=
@@ -1861,7 +1881,7 @@ AC_SUBST([DEVMAPPER_CFLAGS])
 AC_SUBST([DEVMAPPER_LIBS])
 
 with_storage=no
-for backend in dir fs lvm iscsi scsi mpath rbd disk; do
+for backend in dir fs lvm iscsi scsi mpath rbd disk btrfs; do
 if eval test \$with_storage_$backend = yes; then
 with_storage=yes
 break
@@ -2573,6 +2593,7 @@ AC_MSG_NOTICE([   mpath: $with_storage_mpath])
 AC_MSG_NOTICE([Disk: $with_storage_disk])
 AC_MSG_NOTICE([ RBD: $with_storage_rbd])
 AC_MSG_NOTICE([Sheepdog: $with_storage_sheepdog])
+AC_MSG_NOTICE([   Btrfs: $with_storage_btrfs])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Security Drivers])
 AC_MSG_NOTICE([])
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
index 7aa44f3..d9eb6d7 100644
--- 

Re: [libvirt] [PATCHv5 3/5] domifaddr: Implement the API for qemu

2013-09-02 Thread Daniel P. Berrange
On Sun, Sep 01, 2013 at 07:13:33PM +0530, Nehal J Wani wrote:
 +int
 +qemuAgentGetInterfaces(qemuAgentPtr mon,
 +   virDomainInterfacePtr **ifaces)
 +{
 +
 +/* interface name is required to be presented */
 +name = virJSONValueObjectGetString(tmp_iface, name);
 +if (!name) {
 +virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 +   _(qemu agent didn't provide 'name' field));
 +goto error;
 +}
 +
 +/* Handle aliases of type ifname:alias-name */
 +ifname = virStringSplit(name, :, 2);
 +ifname_s = ifname[0];
 +
 +iface = virHashLookup(ifaces_store, ifname_s);
 +
 +/* If the storage bag doesn't contain this iface, add it */
 +if (!iface) {
 +if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1)  0)
 +goto cleanup;
 +
 +if (VIR_ALLOC(ifaces_ret[ifaces_count - 1])  0)
 +goto cleanup;
 +
 +if (virHashAddEntry(ifaces_store, ifname_s,
 +ifaces_ret[ifaces_count - 1])  0)
 +goto cleanup;
 +
 +iface = ifaces_ret[ifaces_count - 1];
 +iface-naddrs = 0;
 +
 +if (VIR_STRDUP(iface-name, ifname_s)  0)
 +goto error;
 +
 +/* hwaddr might be omitted */

Really ? Can qemu guest agent report interfacs with 'hardware-address'
field not being present ?  I'd expect that field to be mandatory and
so report an error in libvirt if missing.

 +hwaddr = virJSONValueObjectGetString(tmp_iface, 
 hardware-address);
 +if (hwaddr  VIR_STRDUP(iface-hwaddr, hwaddr)  0)
 +goto error;
 +}
 +
 +/* Has to be freed for each interface. */
 +virStringFreeList(ifname);

You're leaking 'ifname' if any of the 'goto ' branches are
taken above.


 +
 +/* as well as IP address which - moreover -
 + * can be presented multiple times */
 +ip_addr_arr = virJSONValueObjectGet(tmp_iface, ip-addresses);
 +if (!ip_addr_arr)
 +continue;
 +
 +if ((ip_addr_arr_size = virJSONValueArraySize(ip_addr_arr))  0)
 +/* Mmm, empty 'ip-address'? */
 +continue;

The ' 0' condition indicates an error scenario, so shouldn't be
silently ignored.  '== 0' is the empty list scenario that is ok
to ignore, but already handled by the for() loop conditions.

 +
 +/* If current iface already exists, continue with the count */
 +addrs_count = iface-naddrs;
 +
 +for (j = 0; j  ip_addr_arr_size; j++) {
 +



 diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
 index 4e27981..4014a09 100644
 --- a/tests/qemuagenttest.c
 +++ b/tests/qemuagenttest.c
 @@ -576,6 +576,154 @@ cleanup:
  return ret;
  }
  
 +static const char testQemuAgentGetInterfacesResponse[] =
 +{\return\: 
 +[
 +   {\name\:\lo\,
 +\ip-addresses\:
 +  [
 + {\ip-address-type\:\ipv4\,
 +  \ip-address\:\127.0.0.1\,
 +  \prefix\:8
 + },
 + {\ip-address-type\:\ipv6\,
 +  \ip-address\:\::1\,
 +  \prefix\:128
 + }
 +  ],
 +\hardware-address\:\00:00:00:00:00:00\
 +   },
 +   {\name\:\eth0\,
 +\ip-addresses\:
 +  [
 + {\ip-address-type\:\ipv4\,
 +  \ip-address\:\192.168.102.142\,
 +  \prefix\:24
 + },
 + {\ip-address-type\:\ipv6\,
 +  \ip-address\:\fe80::5054:ff:fe89:ad35\,
 +  \prefix\:64
 + },
 + {\ip-address-type\:\ipv4\,
 +  \ip-address\:\192.168.234.152\,
 +  \prefix\:16
 + },
 + {\ip-address-type\:\ipv6\,
 +  \ip-address\:\fe80::5054:ff:fec3:68bb\,
 +  \prefix\:64
 + }
 +  ],
 +\hardware-address\:\52:54:00:89:ad:35\
 +   },
 +   {\name\:\eth1\,
 +\ip-addresses\:
 +  [
 + {\ip-address-type\:\ipv4\,
 +  \ip-address\:\192.168.103.83\,
 +  \prefix\:24
 + },
 + {\ip-address-type\:\ipv6\,
 +  \ip-address\:\fe80::5054:ff:fed3:39ee\,
 +  \prefix\:64
 + }
 +  ],
 +\hardware-address\:\52:54:00:d3:39:ee\
 +   },
 +   {\name\:\eth1:0\,
 +\ip-addresses\:
 +  [
 + {\ip-address-type\:\ipv4\,
 +  \ip-address\:\192.168.10.91\,
 +  \prefix\:24
 + },
 + {\ip-address-type\:\ipv6\,
 +  \ip-address\:\fe80::fc54:ff:fefe:4c4f\,
 +  

[libvirt] [PATCH] Add forwarders attribute to dns / element.

2013-09-02 Thread Diego Woitasen
Useful to set custom forwarders instead of using the contents of
/etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to resolv VM
domain names from domain 0, when domain option is used.

Signed-off-by: Diego Woitasen diego.woita...@vhgroup.net
---
 src/conf/network_conf.c| 34 +-
 src/conf/network_conf.h|  1 +
 src/network/bridge_driver.c|  8 +
 .../nat-network-dns-forwarders.conf| 15 ++
 .../nat-network-dns-forwarders.xml |  9 ++
 tests/networkxml2conftest.c|  1 +
 6 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.conf
 create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.xml

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index d54f2aa..99f12d2 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -175,6 +175,12 @@ virNetworkDNSSrvDefClear(virNetworkDNSSrvDefPtr def)
 static void
 virNetworkDNSDefClear(virNetworkDNSDefPtr def)
 {
+if (def-forwarders) {
+size_t i;
+for (i = 0; def-forwarders[i] != NULL; i++)
+VIR_FREE(def-forwarders[i]);
+VIR_FREE(def-forwarders);
+}
 if (def-txts) {
 while (def-ntxts)
 virNetworkDNSTxtDefClear(def-txts[--def-ntxts]);
@@ -1038,6 +1044,7 @@ virNetworkDNSDefParseXML(const char *networkName,
 xmlNodePtr *srvNodes = NULL;
 xmlNodePtr *txtNodes = NULL;
 char *forwardPlainNames = NULL;
+char *forwarders = NULL;
 int nhosts, nsrvs, ntxts;
 size_t i;
 int ret = -1;
@@ -1058,6 +1065,20 @@ virNetworkDNSDefParseXML(const char *networkName,
 }
 }
 
+forwarders = virXPathString(string(./@forwarders), ctxt);
+if (forwarders) {
+def-forwarders = virStringSplit(forwarders, ,, 0);
+for (i = 0; def-forwarders[i] != NULL; i++) {
+if (virSocketAddrParse(NULL, def-forwarders[i], AF_UNSPEC)  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(Invalid forwarder IP address '%s' 
+ in network '%s'),
+   def-forwarders[i], networkName);
+goto cleanup;
+}
+}
+}
+
 nhosts = virXPathNodeSet(./host, ctxt, hostNodes);
 if (nhosts  0) {
 virReportError(VIR_ERR_XML_ERROR,
@@ -1120,6 +1141,7 @@ virNetworkDNSDefParseXML(const char *networkName,
 
 ret = 0;
 cleanup:
+VIR_FREE(forwarders);
 VIR_FREE(forwardPlainNames);
 VIR_FREE(hostNodes);
 VIR_FREE(srvNodes);
@@ -2267,12 +2289,22 @@ virNetworkDNSDefFormat(virBufferPtr buf,
 int result = 0;
 size_t i, j;
 
-if (!(def-forwardPlainNames || def-nhosts || def-nsrvs || def-ntxts))
+if (!(def-forwardPlainNames || def-forwarders || def-nhosts || 
+  def-nsrvs || def-ntxts))
 goto out;
 
 virBufferAddLit(buf, dns);
 if (def-forwardPlainNames) {
 virBufferAddLit(buf,  forwardPlainNames='yes');
+if (!(def-forwarders || def-nhosts || def-nsrvs || def-ntxts)) {
+virBufferAddLit(buf, /\n);
+goto out;
+}
+}
+
+if (def-forwarders) {
+char *forwarders = virStringJoin((const char **)def-forwarders, ,);
+virBufferAsprintf(buf,  forwarders='%s', forwarders);
 if (!(def-nhosts || def-nsrvs || def-ntxts)) {
 virBufferAddLit(buf, /\n);
 goto out;
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index c28bfae..3bedc2f 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -122,6 +122,7 @@ struct _virNetworkDNSDef {
 virNetworkDNSHostDefPtr hosts;
 size_t nsrvs;
 virNetworkDNSSrvDefPtr srvs;
+char **forwarders;
 };
 
 typedef struct _virNetworkIpDef virNetworkIpDef;
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3a8be90..c167254 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -708,6 +708,14 @@ networkDnsmasqConfContents(virNetworkObjPtr network,
 if (!network-def-dns.forwardPlainNames)
 virBufferAddLit(configbuf, domain-needed\n);
 
+if (network-def-dns.forwarders) {
+virBufferAddLit(configbuf, no-resolv\n);
+for (i=0; network-def-dns.forwarders[i] != NULL; i++) {
+virBufferAsprintf(configbuf, server=%s\n,
+   network-def-dns.forwarders[i]);
+}
+}
+
 if (network-def-domain) {
 virBufferAsprintf(configbuf,
   domain=%s\n
diff --git a/tests/networkxml2confdata/nat-network-dns-forwarders.conf 
b/tests/networkxml2confdata/nat-network-dns-forwarders.conf
new file mode 100644
index 000..ea6a54a
--- /dev/null
+++ b/tests/networkxml2confdata/nat-network-dns-forwarders.conf
@@ -0,0 +1,15 @@
+##WARNING:  THIS IS AN 

Re: [libvirt] [PATCHv5 4/5] domifaddr: Add virsh support

2013-09-02 Thread Daniel P. Berrange
On Sun, Sep 01, 2013 at 07:13:34PM +0530, Nehal J Wani wrote:
 Use virDomainInterfaceAddresses in virsh
 
 tools/virsh-domain-monitor.c
* Introduce new command : domifaddr
  Usage: domifaddr domain [interface] [full]

'full' shouldn't be a positional arg - it should just be a flag eg

   virsh domifaddr --full f18

  
 +
 +=item Bdomifaddr Idomain [Iinterface] [I--full]
 +
 +Get a list of interfaces of a running domain along with their IP and MAC
 +addresses, or limited output just for one interface if Iinterface is
 +specified. Note, that Iinterface can be driver dependent, it can be
 +the name within guest OS or the name you would see in domain XML.
 +Moreover, the whole command may require a guest agent to be configured
 +for the queried domain under some drivers, notably qemu. All fields can
 +be fully displayed by passing the option: I--full.
 +
  =item Bdomifstat Idomain Iinterface-device
  
  Get network interface stats for a running domain.


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

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


Re: [libvirt] [PATCH] Add forwarders attribute to dns / element.

2013-09-02 Thread Daniel P. Berrange
On Mon, Sep 02, 2013 at 08:50:30AM -0300, Diego Woitasen wrote:
 Useful to set custom forwarders instead of using the contents of
 /etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to resolv 
 VM
 domain names from domain 0, when domain option is used.
 
 Signed-off-by: Diego Woitasen diego.woita...@vhgroup.net
 ---
  src/conf/network_conf.c| 34 
 +-
  src/conf/network_conf.h|  1 +
  src/network/bridge_driver.c|  8 +
  .../nat-network-dns-forwarders.conf| 15 ++
  .../nat-network-dns-forwarders.xml |  9 ++
  tests/networkxml2conftest.c|  1 +
  6 files changed, 67 insertions(+), 1 deletion(-)
  create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.conf
  create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.xml
 


 @@ -1058,6 +1065,20 @@ virNetworkDNSDefParseXML(const char *networkName,
  }
  }
  
 +forwarders = virXPathString(string(./@forwarders), ctxt);
 +if (forwarders) {
 +def-forwarders = virStringSplit(forwarders, ,, 0);

It is frowned upon to create XML where one attribute encodes multiple
separate values. For example, makes it impossible for apps to extract
a single value using xpath queies.

If we need to support multiple addresses for forwarders, then this
suggests we need a child element underneath dns eg perhaps

  dns
forwarder addr='8.8.8.8'/
forwarder addr='1.2.3.4'/
forwarder addr='234:223::4242'/
  /dns


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

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


Re: [libvirt] [PATCH] Add forwarders attribute to dns / element.

2013-09-02 Thread Diego Woitasen
On Mon, Sep 2, 2013 at 8:54 AM, Daniel P. Berrange berra...@redhat.com wrote:
 On Mon, Sep 02, 2013 at 08:50:30AM -0300, Diego Woitasen wrote:
 Useful to set custom forwarders instead of using the contents of
 /etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to resolv 
 VM
 domain names from domain 0, when domain option is used.

 Signed-off-by: Diego Woitasen diego.woita...@vhgroup.net
 ---
  src/conf/network_conf.c| 34 
 +-
  src/conf/network_conf.h|  1 +
  src/network/bridge_driver.c|  8 +
  .../nat-network-dns-forwarders.conf| 15 ++
  .../nat-network-dns-forwarders.xml |  9 ++
  tests/networkxml2conftest.c|  1 +
  6 files changed, 67 insertions(+), 1 deletion(-)
  create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.conf
  create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.xml



 @@ -1058,6 +1065,20 @@ virNetworkDNSDefParseXML(const char *networkName,
  }
  }

 +forwarders = virXPathString(string(./@forwarders), ctxt);
 +if (forwarders) {
 +def-forwarders = virStringSplit(forwarders, ,, 0);

 It is frowned upon to create XML where one attribute encodes multiple
 separate values. For example, makes it impossible for apps to extract
 a single value using xpath queies.

 If we need to support multiple addresses for forwarders, then this
 suggests we need a child element underneath dns eg perhaps

   dns
 forwarder addr='8.8.8.8'/
 forwarder addr='1.2.3.4'/
 forwarder addr='234:223::4242'/
   /dns


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

Ok, I'll fix it.

What do you think about the feature?

-- 
Diego Woitasen
VHGroup - Lead Linux and open source solutions architect
www.vhgroup.net

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


Re: [libvirt] [PATCH] Add forwarders attribute to dns / element.

2013-09-02 Thread Daniel P. Berrange
On Mon, Sep 02, 2013 at 09:27:59AM -0300, Diego Woitasen wrote:
 On Mon, Sep 2, 2013 at 8:54 AM, Daniel P. Berrange berra...@redhat.com 
 wrote:
  On Mon, Sep 02, 2013 at 08:50:30AM -0300, Diego Woitasen wrote:
  Useful to set custom forwarders instead of using the contents of
  /etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to 
  resolv VM
  domain names from domain 0, when domain option is used.
 
  Signed-off-by: Diego Woitasen diego.woita...@vhgroup.net
  ---
   src/conf/network_conf.c| 34 
  +-
   src/conf/network_conf.h|  1 +
   src/network/bridge_driver.c|  8 +
   .../nat-network-dns-forwarders.conf| 15 ++
   .../nat-network-dns-forwarders.xml |  9 ++
   tests/networkxml2conftest.c|  1 +
   6 files changed, 67 insertions(+), 1 deletion(-)
   create mode 100644 
  tests/networkxml2confdata/nat-network-dns-forwarders.conf
   create mode 100644 
  tests/networkxml2confdata/nat-network-dns-forwarders.xml
 
 
 
  @@ -1058,6 +1065,20 @@ virNetworkDNSDefParseXML(const char *networkName,
   }
   }
 
  +forwarders = virXPathString(string(./@forwarders), ctxt);
  +if (forwarders) {
  +def-forwarders = virStringSplit(forwarders, ,, 0);
 
  It is frowned upon to create XML where one attribute encodes multiple
  separate values. For example, makes it impossible for apps to extract
  a single value using xpath queies.
 
  If we need to support multiple addresses for forwarders, then this
  suggests we need a child element underneath dns eg perhaps
 
dns
  forwarder addr='8.8.8.8'/
  forwarder addr='1.2.3.4'/
  forwarder addr='234:223::4242'/
/dns
 
 
  Daniel
  --
  |: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ 
  :|
  |: http://libvirt.org  -o- http://virt-manager.org 
  :|
  |: http://autobuild.org   -o- http://search.cpan.org/~danberr/ 
  :|
  |: http://entangle-photo.org   -o-   http://live.gnome.org/gtk-vnc 
  :|
 
 Ok, I'll fix it.
 
 What do you think about the feature?

The feature proposal sounds fine to me.


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

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


Re: [libvirt] [PATCH v3 3/8] qemu: Don't add default memballoon device on ARM

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:31PM -0400, Cole Robinson wrote:
 And add test cases for a basic working ARM guest.
 ---
  docs/schemas/domaincommon.rng  | 19 +
  src/qemu/qemu_domain.c |  4 ++-
  .../qemuxml2argv-arm-vexpressa9-nodevs.args|  5 
  .../qemuxml2argv-arm-vexpressa9-nodevs.xml | 26 +
  tests/qemuxml2argvtest.c   |  3 ++
  tests/testutilsqemu.c  | 33 
 ++
  6 files changed, 89 insertions(+), 1 deletion(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-nodevs.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-nodevs.xml

ACK


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

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


Re: [libvirt] [PATCH v3 4/8] qemu: Fix specifying char devs for ARM

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:32PM -0400, Cole Robinson wrote:
 QEMU ARM boards don't give us any way to explicitly wire in
 a -chardev, so use the old style -serial options.
 
 Unfortunately this isn't as simple as just turning off the CHARDEV flag
 for qemu-system-arm, as upcoming virtio support _will_ use device/chardev.
 ---
  src/qemu/qemu_capabilities.c | 18 ++
  src/qemu/qemu_capabilities.h |  4 
  src/qemu/qemu_command.c  |  3 +--
  src/qemu/qemu_process.c  | 37 ++---
  4 files changed, 45 insertions(+), 17 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH v3 2/8] domain_conf: Add default memballoon in PostParse callbacks

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:30PM -0400, Cole Robinson wrote:
 This should be a no-op change for now.
 ---
  src/conf/domain_conf.c | 13 -
  src/qemu/qemu_domain.c | 10 ++
  src/xen/xen_driver.c   |  9 +
  3 files changed, 19 insertions(+), 13 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH v3 6/8] domain_conf: Add disk bus=sd, wire it up for qemu

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:34PM -0400, Cole Robinson wrote:
 This corresponds to '-sd' and '-drive if=sd' on the qemu command line.
 Needed for many ARM boards which don't provide any other way to
 pass in storage.
 ---
  docs/formatdomain.html.in |  3 ++-
  docs/schemas/domaincommon.rng |  1 +
  src/conf/domain_conf.c|  4 +++-
  src/conf/domain_conf.h|  1 +
  src/qemu/qemu_command.c   | 20 +++-
  5 files changed, 22 insertions(+), 7 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH v3 5/8] qemu: Don't try to allocate PCI addresses for ARM

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:33PM -0400, Cole Robinson wrote:
 ---
  src/qemu/qemu_command.c | 16 ++--
  1 file changed, 14 insertions(+), 2 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH v3 7/8] qemu: Fix networking for ARM guests

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:35PM -0400, Cole Robinson wrote:
 Similar to the chardev bit, ARM boards depend on the old style '-net nic'
 for actually instantiating net devices. But we can't block out
 -netdev altogether since it's needed for upcoming virtio support.
 
 And add tests for working ARM XML with console, disk, and networking.
 ---
  src/qemu/qemu_command.c| 34 
 --
  src/qemu/qemu_domain.c | 20 +++--
  .../qemuxml2argv-arm-vexpressa9-basic.args |  8 +
  .../qemuxml2argv-arm-vexpressa9-basic.xml  | 34 
 ++
  tests/qemuxml2argvtest.c   |  3 ++
  5 files changed, 88 insertions(+), 11 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-basic.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-basic.xml

ACK

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

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


Re: [libvirt] [PATCH v3 8/8] qemu: Support virtio-mmio transport for virtio on ARM

2013-09-02 Thread Daniel P. Berrange
On Fri, Aug 30, 2013 at 12:41:36PM -0400, Cole Robinson wrote:
 Starting with qemu 1.6, the qemu-system-arm vexpress-a9 model has a
 hardcoded virtio-mmio transport which enables attaching all virtio
 devices.
 
 On the command line, we have to use virtio-XXX-device rather than
 virtio-XXX-pci, thankfully s390 already set the precedent here so
 it's fairly straight forward.
 
 At the XML level, this adds a new device address type virtio-mmio.
 The controller and addressing don't have any subelements at the
 moment because we they aren't needed for this usecase, but could
 be added later if needed.
 
 Add a test case for an ARM guest with one of every virtio device
 enabled.
 ---
  src/conf/domain_conf.c | 12 +++-
  src/conf/domain_conf.h |  1 +
  src/qemu/qemu_capabilities.c   | 17 --
  src/qemu/qemu_capabilities.h   |  2 +
  src/qemu/qemu_command.c| 65 
 +-
  .../qemuxml2argv-arm-vexpressa9-virtio.args| 14 +
  .../qemuxml2argv-arm-vexpressa9-virtio.xml | 45 +++
  tests/qemuxml2argvtest.c   |  4 ++
  8 files changed, 139 insertions(+), 21 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.xml

ACK


 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index 380e2bb..1d70eba 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -207,6 +207,7 @@ enum virDomainDeviceAddressType {
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
 +VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO,
  
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
  };

So there's no kind of address properties needed for the MMIO
address type ?


ACK

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

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


Re: [libvirt] [PATCH 3/5] qemu: add usb-bot support from disks points of view

2013-09-02 Thread Daniel P. Berrange
On Mon, Sep 02, 2013 at 05:38:42PM +0800, Guannan Ren wrote:
 usb-bot only supports 16 luns(0~15) and they must be contiguous,
 (using lun 0 and 2 without 1 doesn't work). In this case qemu
 doesn't throw an error, we can not find the lun 2 in guests. So
 Adding a checking function in libvirt to prevent from this case.

Hmm, this seems like a problematic restriction.

How does this work if we start off a guest with 3 disks
attached to the usb-bot SCSI controller. Then hot-unplug
the 2nd disk.

Next time we need will need to start with with LUNs 0
and 2 populated only, otherwise we have ABI change upon
migrate or save/restore.

I think this restriction about contiguous luns must be
removed if this device is to be usable with multiple luns.

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

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


Re: [libvirt] [PATCHv2 0/2] Support setting the 'removable' flag for USB disks

2013-09-02 Thread Peter Krempa
On 08/28/13 15:41, Peter Krempa wrote:
 On 08/28/13 15:34, anonym wrote:
 27/08/13 14:40, Peter Krempa wrote:
 On 08/23/13 12:38, Fred A. Kemp wrote:
 From: Fred A. Kemp ano...@riseup.net


...


 I'm very time constrained at the moment so I didn't have time to read
 the sources in detail, so the above fix is based on pattern matching
 only. If the fix looks good any way, it should be fixup'ed into my patch #1.

 I'm a bit confused with the process now, as my previous patches were
 ACKed but not pushed. Should send a new patchset?
 
 Ususaly the reviewer is responsible for checking and pushing patches
 from non-maintainers. If the fix is indeed to enable the one capability
 bit I'll amend those patches and push them later today.

I rebased and pushed the patches now that the release is done.

 

 Cheers!


Peter





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

[libvirt] [PATCH] qemu: Handle huge number of queues correctly

2013-09-02 Thread Michal Privoznik
Currently, kernel supports up to 8 queues for a multiqueue tap device.
However, if user tries to enter a huge number (e.g. one million) the tap
allocation fails, as expected. But what is not expected is the log full
of warnings:

warning : virFileClose:83 : Tried to close invalid fd 0

The problem is, upon error we iterate over an array of FDs (handlers to
queues) and VIR_FORCE_CLOSE() over each item. However, the array is
pre-filled with zeros. Hence, we repeatedly close stdin. Ouch.
But there's more. The queues allocation is done in virNetDevTapCreate()
which cleans up the FDs in case of error. Then, its caller, the
virNetDevTapCreateInBridgePort() iterates over the FD array and tries to
close them too. And so does qemuNetworkIfaceConnect() and
qemuBuildInterfaceCommandLine().

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/qemu/qemu_command.c | 10 +++---
 src/util/virnetdevtap.c |  4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index f8fccea..73a13b3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -405,7 +405,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
 cleanup:
 if (ret  0) {
 size_t i;
-for (i = 0; i  *tapfdSize; i++)
+for (i = 0; i  *tapfdSize  tapfd[i] = 0; i++)
 VIR_FORCE_CLOSE(tapfd[i]);
 if (template_ifname)
 VIR_FREE(net-ifname);
@@ -7241,6 +7241,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
 VIR_ALLOC_N(tapfdName, tapfdSize)  0)
 goto cleanup;
 
+memset(tapfd, -1, tapfdSize * sizeof(tapfd[0]));
+
 if (qemuNetworkIfaceConnect(def, conn, driver, net,
 qemuCaps, tapfd, tapfdSize)  0)
 goto cleanup;
@@ -7268,6 +7270,8 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
 VIR_ALLOC_N(vhostfdName, vhostfdSize))
 goto cleanup;
 
+memset(vhostfd, -1, vhostfdSize * sizeof(vhostfd[0]));
+
 if (qemuOpenVhostNet(def, net, qemuCaps, vhostfd, vhostfdSize)  0)
 goto cleanup;
 }
@@ -7329,13 +7333,13 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
 cleanup:
 if (ret  0)
 virDomainConfNWFilterTeardown(net);
-for (i = 0; tapfd  i  tapfdSize; i++) {
+for (i = 0; tapfd  i  tapfdSize  tapfd[i] = 0; i++) {
 if (ret  0)
 VIR_FORCE_CLOSE(tapfd[i]);
 if (tapfdName)
 VIR_FREE(tapfdName[i]);
 }
-for (i = 0; vhostfd  i  vhostfdSize; i++) {
+for (i = 0; vhostfd  i  vhostfdSize  vhostfd[i] = 0; i++) {
 if (ret  0)
 VIR_FORCE_CLOSE(vhostfd[i]);
 if (vhostfdName)
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 42e8dfe..dc2c224 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -498,8 +498,8 @@ int virNetDevTapCreateInBridgePort(const char *brname,
 return 0;
 
 error:
-while (tapfdSize)
-VIR_FORCE_CLOSE(tapfd[--tapfdSize]);
+while (tapfdSize  tapfd[--tapfdSize] = 0)
+VIR_FORCE_CLOSE(tapfd[tapfdSize]);
 
 return -1;
 }
-- 
1.8.1.5

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


[libvirt] [PATCH] examples: Add script to parse topology from capabilities output

2013-09-02 Thread Peter Krempa
Add a demo script originally written by Amador Pahim to parse topology
of the host from data provided in the capabilities XML.
---
 examples/python/topology.py | 45 +
 1 file changed, 45 insertions(+)
 create mode 100755 examples/python/topology.py

diff --git a/examples/python/topology.py b/examples/python/topology.py
new file mode 100755
index 000..1b678bc
--- /dev/null
+++ b/examples/python/topology.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# Parse topology information from the capabilities XML and use
+# them to calculate host topology
+#
+# Authors:
+#   Amador Pahim apa...@redhat.com
+#   Peter Krempa pkre...@redhat.com
+
+import libvirt
+import sys
+from xml.dom import minidom
+
+try:
+conn = libvirt.openReadOnly(None)
+except libvirt.libvirtError:
+print 'Failed to connect to the hypervisor'
+sys.exit(1)
+
+try:
+capsXML = conn.getCapabilities()
+except libvirt.libvirtError:
+print 'Failed to request capabilities'
+sys.exit(1)
+
+caps = minidom.parseString(capsXML)
+host = caps.getElementsByTagName('host')[0]
+cells = host.getElementsByTagName('cells')[0]
+total_cpus = cells.getElementsByTagName('cpu').length
+
+socketIds = []
+siblingsIds = []
+
+socketIds = [ proc.getAttribute('socket_id')
+  for proc in cells.getElementsByTagName('cpu')
+  if proc.getAttribute('socket_id') not in socketIds ]
+
+siblingsIds = [ proc.getAttribute('siblings')
+for proc in cells.getElementsByTagName('cpu')
+if proc.getAttribute('siblings') not in siblingsIds ]
+
+print Host topology
+print NUMA nodes:, cells.getAttribute('num')
+printSockets:,len(set(socketIds))
+print  Cores:,len(set(siblingsIds))
+printThreads:,total_cpus
-- 
1.8.3.2

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


[libvirt] [PATCH] Add forwarders attribute to dns / element.

2013-09-02 Thread Diego Woitasen
Useful to set custom forwarders instead of using the contents of
/etc/resolv.conf. It helps me to setup dnsmasq as local nameserver to resolv VM
domain names from domain 0, when domain option is used.

Signed-off-by: Diego Woitasen diego.woita...@vhgroup.net
---
 docs/formatnetwork.html.in |  8 
 docs/schemas/network.rng   |  5 +++
 src/conf/network_conf.c| 43 --
 src/conf/network_conf.h|  2 +
 src/network/bridge_driver.c|  8 
 .../nat-network-dns-forwarders.conf| 16 
 .../nat-network-dns-forwarders.xml | 12 ++
 tests/networkxml2conftest.c|  1 +
 8 files changed, 92 insertions(+), 3 deletions(-)
 create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.conf
 create mode 100644 tests/networkxml2confdata/nat-network-dns-forwarders.xml

diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in
index e1482db..4dd809a 100644
--- a/docs/formatnetwork.html.in
+++ b/docs/formatnetwork.html.in
@@ -631,6 +631,8 @@
 lt;domain name=example.com/gt;
 lt;dnsgt;
   lt;txt name=example value=example value /gt;
+  lt;forwarders addr=8.8.8.8 /gt;
+  lt;forwarders addr=8.8.4.4 /gt;
   lt;srv service='name' protocol='tcp' domain='test-domain-name' 
target='.' port='1024' priority='10' weight='10'/gt;
   lt;host ip='192.168.122.2'gt;
 lt;hostnamegt;myhostlt;/hostnamegt;
@@ -685,6 +687,12 @@
 
 Currently supported sub-elements of codelt;dnsgt;/code are:
 dl
+  dtcodeforwarders/code/dt
+  ddA codedns/code element can have 0 or more 
codeforwarders/code elements.
+Each forwarders element defines an IP address to be used as 
forwarder
+in DNS server configuration. The addr attribute is required and 
defines the
+IP address of every forwarder. span class=sinceSince N/A/span
+  /dd
   dtcodetxt/code/dt
   ddA codedns/code element can have 0 or more codetxt/code 
elements.
 Each txt element defines a DNS TXT record and has two attributes, 
both
diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng
index ab183f1..e0c2b51 100644
--- a/docs/schemas/network.rng
+++ b/docs/schemas/network.rng
@@ -217,6 +217,11 @@
 /attribute
   /optional
   zeroOrMore
+element name=forwarders
+  attribute name=addrref name=ipAddr//attribute
+/element
+  /zeroOrMore
+  zeroOrMore
 element name=txt
   attribute name=nameref name=dnsName//attribute
   attribute name=valuetext//attribute
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index d54f2aa..1c1aa64 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -175,6 +175,11 @@ virNetworkDNSSrvDefClear(virNetworkDNSSrvDefPtr def)
 static void
 virNetworkDNSDefClear(virNetworkDNSDefPtr def)
 {
+if (def-forwarders) {
+while (def-nfwds)
+VIR_FREE(def-forwarders[--def-nfwds]);
+VIR_FREE(def-forwarders);
+}
 if (def-txts) {
 while (def-ntxts)
 virNetworkDNSTxtDefClear(def-txts[--def-ntxts]);
@@ -1037,8 +1042,9 @@ virNetworkDNSDefParseXML(const char *networkName,
 xmlNodePtr *hostNodes = NULL;
 xmlNodePtr *srvNodes = NULL;
 xmlNodePtr *txtNodes = NULL;
+xmlNodePtr *fwdNodes = NULL;
 char *forwardPlainNames = NULL;
-int nhosts, nsrvs, ntxts;
+int nfwds, nhosts, nsrvs, ntxts;
 size_t i;
 int ret = -1;
 xmlNodePtr save = ctxt-node;
@@ -1058,6 +1064,30 @@ virNetworkDNSDefParseXML(const char *networkName,
 }
 }
 
+nfwds = virXPathNodeSet(./forwarders, ctxt, fwdNodes);
+if (nfwds  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(invalid forwarders element found in dns of 
network %s),
+   networkName);
+goto cleanup;
+}
+if (nfwds  0) {
+if (VIR_ALLOC_N(def-forwarders, nfwds)  0)
+goto cleanup;
+
+for (i = 0; i  nfwds; i++) {
+def-forwarders[i] = virXMLPropString(fwdNodes[i], addr);
+if (virSocketAddrParse(NULL, def-forwarders[i], AF_UNSPEC)  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(Invalid forwarder IP address '%s' 
+ in network '%s'),
+   def-forwarders[i], networkName);
+goto cleanup;
+}
+def-nfwds++;
+}
+}
+
 nhosts = virXPathNodeSet(./host, ctxt, hostNodes);
 if (nhosts  0) {
 virReportError(VIR_ERR_XML_ERROR,
@@ -1121,6 +1151,7 @@ virNetworkDNSDefParseXML(const char *networkName,
 ret = 0;
 cleanup:
 

Re: [libvirt] [PATCH 2/3] virsh: Remember terminal state when starting and add helpers

2013-09-02 Thread Michal Privoznik
On 29.08.2013 17:52, Peter Krempa wrote:
 This patch adds instrumentation to allow modification of config of the
 terminal in virsh and successful reset of the state afterwards.
 
 The added helpers allow to disable receiving of SIGINT when pressing the
 key sequence (Ctrl+C usualy). This normally sends SIGINT to the
 foreground process group which kills ssh processes used for transport of
 the data.
 ---
 The termios code may need protecting with #ifndef WIN32.
 
 
  tools/virsh.c | 54 ++
  tools/virsh.h |  9 +
  2 files changed, 63 insertions(+)

ACK

Michal

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


[libvirt] [PATCHv2 RESEND 2/5] virstring.h/c: Util method for making some find and replace in strings

2013-09-02 Thread Manuel VIVES
---
 src/libvirt_private.syms |1 +
 src/util/virstring.c |   48 ++
 src/util/virstring.h |2 ++
 3 files changed, 51 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a6af540..b5f83c3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1920,6 +1920,7 @@ virStringListLength;
 virStringSplit;
 virStrncpy;
 virStrndup;
+virStrReplace;
 virStrToDouble;
 virStrToLong_i;
 virStrToLong_l;
diff --git a/src/util/virstring.c b/src/util/virstring.c
index d11db5c..a30a4ef 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -616,3 +616,51 @@ size_t virStringListLength(char **strings)
 
 return i;
 }
+
+/*
+ virStrReplace(haystack, oldneedle, newneedle) --
+  Search haystack and replace all occurences of oldneedle with newneedle.
+  Return a string with all the replacements in case of success, NULL in case
+  of failure
+*/
+char *
+virStrReplace(char *haystack,
+  const char *oldneedle, const char *newneedle)
+{
+char *ret;
+size_t i, count = 0;
+size_t newneedle_len = strlen(newneedle);
+size_t oldneedle_len = strlen(oldneedle);
+size_t totalLength = 0;
+if (strlen(oldneedle) == 0) {
+ignore_value(VIR_STRDUP(ret, haystack));
+goto cleanup;
+}
+
+for (i = 0; haystack[i] != '\0'; i++) {
+if (strstr(haystack[i], oldneedle) == haystack[i]) {
+count++;
+i += oldneedle_len - 1;
+}
+}
+if (VIR_ALLOC_N(ret, (i + count * (newneedle_len - oldneedle_len)))  0) {
+ret = NULL;
+goto cleanup;
+}
+totalLength = sizeof(char *)*(i + count * (newneedle_len - oldneedle_len));
+i = 0;
+while (*haystack) {
+if (strstr(haystack, oldneedle) == haystack) {
+if (virStrcpy(ret[i], newneedle, totalLength) == NULL) {
+ret = NULL;
+goto cleanup;
+}
+i += newneedle_len;
+haystack += oldneedle_len;
+} else
+ret[i++] = *haystack++;
+}
+ret[i] = '\0';
+cleanup:
+return ret;
+}
diff --git a/src/util/virstring.h b/src/util/virstring.h
index b390150..90522bd 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -223,4 +223,6 @@ size_t virStringListLength(char **strings);
 virAsprintfInternal(false, 0, NULL, NULL, 0, \
 strp, __VA_ARGS__)
 
+char * virStrReplace(char *haystack, const char *oldneedle, const char 
*newneedle);
+
 #endif /* __VIR_STRING_H__ */
-- 
1.7.10.4

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


[libvirt] [PATCHv2 RESEND 4/5] vbox_tmpl.c: Patch for redefining snapshots

2013-09-02 Thread Manuel VIVES
The snapshots are saved in xml files, and then can be redefined
---
 src/vbox/vbox_tmpl.c |  848 +-
 1 file changed, 840 insertions(+), 8 deletions(-)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index ded179f..2b07dec 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -61,6 +61,7 @@
 #include virstring.h
 #include virtime.h
 #include virutil.h
+#include dirname.h
 
 /* This one changes from version to version. */
 #if VBOX_API_VERSION == 2002
@@ -274,6 +275,12 @@ static vboxGlobalData *g_pVBoxGlobalData = NULL;
 
 #endif /* VBOX_API_VERSION = 4000 */
 
+/*This error is a bit specific
+ *In the VBOX API it is named E_ACCESSDENIED
+ *It is returned when the called object is not ready. In
+ *particular when we do any call on a disk which has been closed
+*/
+#define VBOX_E_ACCESSDENIED 0x80070005
 #define reportInternalErrorIfNS_FAILED(message) \
 if (NS_FAILED(rc)) { \
 virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(message)); \
@@ -284,6 +291,8 @@ static vboxGlobalData *g_pVBoxGlobalData = NULL;
 static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml);
 static int vboxDomainCreate(virDomainPtr dom);
 static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags);
+static virStorageVolPtr vboxStorageVolLookupByPath(virConnectPtr conn, const 
char *path);
+static int vboxStorageDeleteOrClose(virStorageVolPtr vol, unsigned int flags, 
unsigned int flagDeleteOrClose);
 static void vboxDriverLock(vboxGlobalData *data) {
 virMutexLock(data-lock);
 }
@@ -5896,6 +5905,823 @@ cleanup:
 return snapshot;
 }
 
+#if VBOX_API_VERSION =4002
+static void
+vboxSnapshotXmlRetrieveSnapshotNodeByName(xmlNodePtr a_node,
+   const char *name,
+   xmlNodePtr *snap_node)
+{
+xmlNodePtr cur_node = NULL;
+
+for (cur_node = a_node; cur_node; cur_node = cur_node-next) {
+if (cur_node-type == XML_ELEMENT_NODE) {
+if (!xmlStrcmp(cur_node-name, (const xmlChar *) Snapshot) 
+STREQ(virXMLPropString(cur_node, name), name)) {
+*snap_node = cur_node;
+return;
+}
+}
+if (cur_node-children)
+vboxSnapshotXmlRetrieveSnapshotNodeByName(cur_node-children, 
name, snap_node);
+}
+}
+
+
+
+
+static int
+vboxDetachAndCloseDisks(virDomainPtr dom,
+IMedium *disk)
+{
+VBOX_OBJECT_CHECK(dom-conn, int, -1);
+nsresult rc;
+PRUnichar *location = NULL;
+vboxArray childrenDiskArray = VBOX_ARRAY_INITIALIZER;
+virStorageVolPtr volPtr = NULL;
+char *location_utf8 = NULL;
+PRUint32 dummyState = 0;
+size_t i = 0;
+if (disk == NULL) {
+VIR_DEBUG(Null pointer to disk);
+return -1;
+}
+rc = disk-vtbl-GetLocation(disk, location);
+if (rc == VBOX_E_ACCESSDENIED) {
+VIR_DEBUG(Disk already closed);
+goto cleanup;
+}
+reportInternalErrorIfNS_FAILED(cannot get disk location);
+rc = vboxArrayGet(childrenDiskArray, disk, disk-vtbl-GetChildren);
+reportInternalErrorIfNS_FAILED(cannot get children disks);
+for (i = 0; i  childrenDiskArray.count; ++i) {
+IMedium *childDisk = childrenDiskArray.items[i];
+if (childDisk) {
+vboxDetachAndCloseDisks(dom, childDisk);
+}
+}
+rc = disk-vtbl-RefreshState(disk, dummyState);
+reportInternalErrorIfNS_FAILED(cannot refresh state);
+VBOX_UTF16_TO_UTF8(location, location_utf8);
+volPtr = vboxStorageVolLookupByPath(dom-conn, location_utf8);
+
+if (volPtr) {
+VIR_DEBUG(Closing %s, location_utf8);
+if (vboxStorageDeleteOrClose(volPtr, 0, VBOX_STORAGE_CLOSE_FLAG) != 0) 
{
+VIR_DEBUG(Error while closing disk);
+}
+}
+VBOX_UTF8_FREE(location_utf8);
+cleanup:
+VBOX_UTF16_FREE(location);
+vboxArrayRelease(childrenDiskArray);
+return ret;
+}
+
+static void
+vboxSnapshotXmlAddChild(xmlNodePtr parent,
+xmlNodePtr child)
+{
+/*Used in order to add child without writing the stuff concerning xml 
namespaces*/
+xmlBufferPtr tmpBuf = xmlBufferCreate();
+char *tmpString = NULL;
+xmlNodePtr tmpNode = NULL;
+xmlNodeDump(tmpBuf, parent-doc, child, 0, 0);
+ignore_value(VIR_STRDUP(tmpString, (char *)xmlBufferContent(tmpBuf)));
+xmlParseInNodeContext(parent, tmpString, (int)strlen(tmpString), 0, 
tmpNode);
+if (tmpNode) {
+if (xmlAddChild(parent, xmlCopyNode(tmpNode, 1)) == NULL) {
+VIR_DEBUG(Error while adding %s to %s, (char *)tmpNode-name, 
(char *)parent-name);
+}
+}
+xmlFree(tmpNode);
+xmlBufferFree(tmpBuf);
+}
+
+static void
+vboxSnapshotXmlRetrieveMachineNode(xmlNodePtr root,
+xmlNodePtr *machineNode)
+{
+xmlNodePtr cur = root-xmlChildrenNode;
+while (cur  xmlIsBlankNode(cur)) {
+cur = cur - next;
+}

[libvirt] [PATCHv2 RESEND 0/5] Handling of undefine and redefine snapshots with VirtualBox 4.2

2013-09-02 Thread Manuel VIVES
Hi,
This is a serie of patches in order to support undefining and redefining
snapshots with VirtualBox 4.2.

The serie of patches is rather big, and adds among other things some utility 
functions unrelated to VirtualBox in patches 1  2.
The code review could be done in several parts: e.g. patches 1  2 separately 
to validate the utility functions.

This 2nd version brings a different function for string replacement, because of 
the license problem with
the first one.

The VirtualBox API provides only high level operations to manipulate snapshots,
so it not possible to support flags like VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE and
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY with only API calls.
Following an IRC talk with Eric Blake, the decision was taken to emulate these
behaviours by manipulating directly the .vbox XML files.

The first two patches are some util methods for handling uuid and strings that
will be used after.

The third patch brings more details in the snapshot XML returned by libvirt.
We will need those modifications in order to redefine the snapshots.

The fourth patch brings the support of the VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE
and VIR_DOMAIN_SNAPSHOT_CREATE_CURRENT flags in virDomainSnapshotCreateXML.

The fifth and last patch brings the support of the 
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY
flag in virDomainSnapshotDelete.

The patches are only for Virtualbox 4.2

Regards,
Manuel VIVES


Manuel VIVES (5):
  viruuid.h/c: Util method for finding uuid patterns in some strings
  virstring.h/c: Util method for making some find and replace in
strings
  vbox_tmpl.c: Better XML description for snapshots
  vbox_tmpl.c: Patch for redefining snapshots
  vbox_tmpl.c: Add methods for undefining snapshots

 src/conf/domain_conf.c   |   20 +-
 src/libvirt_private.syms |2 +
 src/util/virstring.c |   48 ++
 src/util/virstring.h |2 +
 src/util/viruuid.c   |   79 ++
 src/util/viruuid.h   |1 +
 src/vbox/vbox_tmpl.c | 1846 +++---
 7 files changed, 1878 insertions(+), 120 deletions(-)

-- 
1.7.10.4

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


[libvirt] [PATCHv2 RESEND 3/5] vbox_tmpl.c: Better XML description for snapshots

2013-09-02 Thread Manuel VIVES
It will be needed for the futur patches because we will
redefine snapshots
---
 src/conf/domain_conf.c |   20 ++-
 src/vbox/vbox_tmpl.c   |  427 ++--
 2 files changed, 427 insertions(+), 20 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f1623f1..c98ff63 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16810,15 +16810,17 @@ virDomainDefFormatInternal(virDomainDefPtr def,
 if (virDomainChrDefFormat(buf, console, flags)  0)
 goto error;
 }
-if (STREQ(def-os.type, hvm) 
-def-nconsoles == 0 
-def-nserials  0) {
-virDomainChrDef console;
-memcpy(console, def-serials[n], sizeof(console));
-console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
-console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
-if (virDomainChrDefFormat(buf, console, flags)  0)
-goto error;
+if (def-os.type) {
+if (STREQ(def-os.type, hvm) 
+def-nconsoles == 0 
+def-nserials  0) {
+virDomainChrDef console;
+memcpy(console, def-serials[n], sizeof(console));
+console.deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+console.targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL;
+if (virDomainChrDefFormat(buf, console, flags)  0)
+goto error;
+}
 }
 
 for (n = 0; n  def-nchannels; n++)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 5e5ea85..ded179f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -38,6 +38,7 @@
 #include sys/types.h
 #include sys/stat.h
 #include fcntl.h
+#include libxml/xmlwriter.h
 
 #include internal.h
 #include datatypes.h
@@ -58,6 +59,8 @@
 #include fdstream.h
 #include viruri.h
 #include virstring.h
+#include virtime.h
+#include virutil.h
 
 /* This one changes from version to version. */
 #if VBOX_API_VERSION == 2002
@@ -271,10 +274,16 @@ static vboxGlobalData *g_pVBoxGlobalData = NULL;
 
 #endif /* VBOX_API_VERSION = 4000 */
 
+#define reportInternalErrorIfNS_FAILED(message) \
+if (NS_FAILED(rc)) { \
+virReportError(VIR_ERR_INTERNAL_ERROR, %s, _(message)); \
+goto cleanup; \
+}
+
+
 static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml);
 static int vboxDomainCreate(virDomainPtr dom);
 static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags);
-
 static void vboxDriverLock(vboxGlobalData *data) {
 virMutexLock(data-lock);
 }
@@ -283,6 +292,12 @@ static void vboxDriverUnlock(vboxGlobalData *data) {
 virMutexUnlock(data-lock);
 }
 
+typedef enum {
+VBOX_STORAGE_DELETE_FLAG = 0,
+#if VBOX_API_VERSION = 4002
+VBOX_STORAGE_CLOSE_FLAG = 1,
+#endif
+} vboxStorageDeleteOrCloseFlags;
 #if VBOX_API_VERSION == 2002
 
 static void nsIDtoChar(unsigned char *uuid, const nsID *iid) {
@@ -5907,7 +5922,8 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
 virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL);
 
 if (!(def = virDomainSnapshotDefParseString(xmlDesc, data-caps,
-data-xmlopt, 0, 0)))
+data-xmlopt, -1, 
VIR_DOMAIN_SNAPSHOT_PARSE_DISKS |
+  
VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE)))
 goto cleanup;
 
 if (def-ndisks) {
@@ -5915,7 +5931,6 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
_(disk snapshots not supported yet));
 goto cleanup;
 }
-
 vboxIIDFromUUID(domiid, dom-uuid);
 rc = VBOX_OBJECT_GET_MACHINE(domiid.value, machine);
 if (NS_FAILED(rc)) {
@@ -5923,7 +5938,6 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
_(no domain with matching UUID));
 goto cleanup;
 }
-
 rc = machine-vtbl-GetState(machine, state);
 if (NS_FAILED(rc)) {
 virReportError(VIR_ERR_INTERNAL_ERROR, %s,
@@ -5998,6 +6012,344 @@ cleanup:
 return ret;
 }
 
+#if VBOX_API_VERSION =4002
+static
+int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def,
+virDomainSnapshotPtr snapshot)
+{
+virDomainPtr dom = snapshot-domain;
+VBOX_OBJECT_CHECK(dom-conn, int, -1);
+vboxIID domiid = VBOX_IID_INITIALIZER;
+IMachine *machine = NULL;
+ISnapshot *snap = NULL;
+IMachine *snapMachine = NULL;
+bool error = false;
+vboxArray mediumAttachments = VBOX_ARRAY_INITIALIZER;
+PRUint32   maxPortPerInst[StorageBus_Floppy + 1] = {};
+PRUint32   maxSlotPerPort[StorageBus_Floppy + 1] = {};
+int diskCount = 0;
+nsresult rc;
+vboxIID snapIid = VBOX_IID_INITIALIZER;
+char *snapshotUuidStr = NULL;
+size_t i = 0;
+vboxIIDFromUUID(domiid, dom-uuid);
+rc = VBOX_OBJECT_GET_MACHINE(domiid.value, machine);
+reportInternalErrorIfNS_FAILED(no domain with 

[libvirt] [PATCHv2 RESEND 5/5] vbox_tmpl.c: Add methods for undefining snapshots

2013-09-02 Thread Manuel VIVES
All the informations concerning snapshots (and snapshot disks)
will be deleted from the vbox xml. But the differencing disks will be
kept so you will be able to redefine the snapshots.
---
 src/vbox/vbox_tmpl.c |  387 ++
 1 file changed, 387 insertions(+)

diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 2b07dec..4bc1054 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -6082,6 +6082,68 @@ vboxSnapshotXmlAppendDiskToMediaRegistry(xmlNodePtr 
*inMediaRegistry,
 }
 }
 
+
+static void
+vboxRemoveAllDisksExceptParentFromMediaRegistry(xmlNodePtr mediaRegistryNode){
+xmlNodePtr cur_node = NULL;
+for (cur_node = mediaRegistryNode; cur_node; cur_node = cur_node-next) {
+if (cur_node) {
+if (cur_node-type == XML_ELEMENT_NODE
+ !xmlStrcmp(cur_node-name, (const xmlChar *) HardDisk)) {
+xmlNodePtr child = NULL;
+for (child = cur_node-children; child; child = child-next) {
+/*We look over all the children
+ *If there is a node element, we delete it
+ */
+if (child-type == XML_ELEMENT_NODE) {
+xmlUnlinkNode(child);
+xmlFreeNode(child);
+}
+}
+}
+}
+if ((cur_node-children))
+
vboxRemoveAllDisksExceptParentFromMediaRegistry((cur_node-children));
+}
+}
+
+static void
+vboxRemoveDiskFromMediaRegistryIfNoChildren(xmlNodePtr mediaRegistryNode,
+char *diskLocation)
+{
+/*
+ *This function will remove a disk from the media registry only if it 
doesn't
+ *have any children
+ */
+xmlNodePtr cur_node = NULL;
+for (cur_node = mediaRegistryNode; cur_node; cur_node = cur_node-next) {
+if (cur_node) {
+if (cur_node-type == XML_ELEMENT_NODE
+ !xmlStrcmp(cur_node-name, (const xmlChar *) HardDisk)
+ xmlHasProp(cur_node, BAD_CAST location) != NULL
+ strstr(diskLocation, (char *)xmlHasProp(cur_node, BAD_CAST 
location)-children-content) != NULL) {
+
+xmlNodePtr child = NULL;
+bool deleteNode = true;
+for (child = cur_node-children; child; child = child-next) {
+/*We look over all the children
+ *If there is a node element, we don't delete it
+ */
+if (child-type == XML_ELEMENT_NODE)
+deleteNode = false;
+}
+if (deleteNode) {
+xmlUnlinkNode(cur_node);
+xmlFreeNode(cur_node);
+}
+return;
+}
+}
+if ((cur_node-children))
+vboxRemoveDiskFromMediaRegistryIfNoChildren((cur_node-children), 
diskLocation);
+}
+}
+
 static int
 vboxSnapshotGenerateVboxXML(xmlNodePtr rootElementVboxXML,
 char *storageControllerString,
@@ -8022,7 +8084,314 @@ cleanup:
 vboxArrayRelease(children);
 return ret;
 }
+#if VBOX_API_VERSION = 4002
+static int
+vboxCloseDisk(virDomainPtr dom,
+  IMedium *baseDisk) {
+VBOX_OBJECT_CHECK(dom-conn, int, -1);
+nsresult rc;
+vboxArray childrenDiskArray = VBOX_ARRAY_INITIALIZER;
+size_t i = 0;
+if (!baseDisk)
+return -1;
+
+rc = vboxArrayGet(childrenDiskArray, baseDisk, 
baseDisk-vtbl-GetChildren);
+if (NS_FAILED(rc)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(could not get children disks));
+ret = -1;
+goto cleanup;
+}
+for (i=0; i  childrenDiskArray.count; ++i)
+vboxCloseDisk(dom, childrenDiskArray.items[i]);
+
+baseDisk-vtbl-Close(baseDisk);
+ret = 0;
+cleanup:
+vboxArrayRelease(childrenDiskArray);
+return ret;
+}
+
+static int
+vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot)
+{
+/*This function will remove the node in the vbox xml corresponding to
+ *the snapshot. It is usually called by vboxDomainSnapshotDelete() with
+ *the flag VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY.
+ *If you want to use it anywhere else, be careful, if the snapshot you 
want to delete has children,
+ *the result is not granted, they will probably will be deleted in the 
xml, but you may have
+ *a problem with hard drives
+ *
+ *If the snapshot which is being deleted is the current, we will set the 
current snapshot of the machine to
+ *its parent.
+ *
+ *Before the writing of the modified xml file, we undefine the machine 
from vbox
+ *After the modification, we redefine the machine
+ */
+
+virDomainPtr dom = snapshot-domain;
+VBOX_OBJECT_CHECK(dom-conn, int, -1);
+IMachine *machine = NULL;
+IMachine *newMachine = 

[libvirt] [PATCHv2 RESEND 1/5] viruuid.h/c: Util method for finding uuid patterns in some strings

2013-09-02 Thread Manuel VIVES
---
 src/libvirt_private.syms |1 +
 src/util/viruuid.c   |   79 ++
 src/util/viruuid.h   |1 +
 3 files changed, 81 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 35f0f1b..a6af540 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2080,6 +2080,7 @@ virValidateWWN;
 
 # util/viruuid.h
 virGetHostUUID;
+virSearchUuid;
 virSetHostUUIDStr;
 virUUIDFormat;
 virUUIDGenerate;
diff --git a/src/util/viruuid.c b/src/util/viruuid.c
index c5fa9a8..3786393 100644
--- a/src/util/viruuid.c
+++ b/src/util/viruuid.c
@@ -34,6 +34,7 @@
 #include sys/stat.h
 #include time.h
 #include unistd.h
+#include regex.h
 
 #include c-ctype.h
 #include internal.h
@@ -43,11 +44,14 @@
 #include viralloc.h
 #include virfile.h
 #include virrandom.h
+#include virstring.h
 
 #ifndef ENODATA
 # define ENODATA EIO
 #endif
 
+#define VIR_FROM_THIS VIR_FROM_NONE
+
 static unsigned char host_uuid[VIR_UUID_BUFLEN];
 
 static int
@@ -333,3 +337,78 @@ int virGetHostUUID(unsigned char *uuid)
 
 return ret;
 }
+
+
+/**
+ * virSearchUuid:
+ * Return the nth occurrence of a substring in sourceString which matches an 
uuid pattern
+ * If there is no substring, ret is not modified
+ *
+ * @sourceString: String to parse
+ * @occurrence: We will return the nth occurrence of uuid in substring, if 
equals to 0 (or negative), will return the first occurence
+ * @ret: nth occurrence substring matching an uuid pattern
+ * @code
+char *source = 6853a496-1c10-472e-867a-8244937bd6f0 
773ab075-4cd7-4fc2-8b6e-21c84e9cb391 bbb3c75c-d60f-43b0-b802-fd56b84a4222 
60c04aa1-0375-4654-8d9f-e149d9885273 4548d465-9891-4c34-a184-3b1c34a26aa8;
+char *ret1=NULL;
+char *ret2=NULL;
+char *ret3=NULL;
+char *ret4=NULL;
+virSearchUuid(source, 4,ret1);  //ret1 = 
60c04aa1-0375-4654-8d9f-e149d9885273
+virSearchUuid(source, 0,ret2);  //ret2 = 
6853a496-1c10-472e-867a-8244937bd6f0
+virSearchUuid(source, 1,ret3);  //ret3 = 
6853a496-1c10-472e-867a-8244937bd6f0
+virSearchUuid(source, -4,ret4); //ret4 = 
6853a496-1c10-472e-867a-8244937bd6f0
+ * @endcode
+ */
+
+char **
+virSearchUuid(const char *sourceString, int occurrence,char **ret)
+{
+int position = ((occurrence -1)  0) ? (occurrence -1) : 0;
+
+const char *uuidRegex = 
([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12});
+regex_t pregUuidBracket;
+size_t i = 0;
+size_t nmatch = 0;
+regmatch_t *pmatch = NULL;
+if (regcomp(pregUuidBracket, uuidRegex, REG_EXTENDED) != 0) {
+VIR_DEBUG(Error while compiling regular expression);
+goto cleanup;
+}
+nmatch = pregUuidBracket.re_nsub;
+if (VIR_ALLOC_N(pmatch, nmatch) != 0) {
+virReportOOMError();
+goto cleanup;
+}
+while (i  (position+1)) {
+if (regexec(pregUuidBracket, sourceString, nmatch, pmatch, 0) == 0) {
+char *substring = NULL;
+int start = pmatch[0].rm_so;
+int end = pmatch[0].rm_eo;
+size_t size = end - start;
+if (VIR_ALLOC_N(substring, (size + 1)) != 0) {
+virReportOOMError();
+goto cleanup;
+}
+if (substring) {
+if (virStrncpy(substring, sourceString[start], size, size + 
1)) {
+substring[size] = '\0';
+if (VIR_STRDUP(*ret, substring)  0) {
+VIR_DEBUG(cannot duplicate %s, substring);
+goto cleanup;
+}
+}
+VIR_FREE(substring);
+}
+sourceString = sourceString[end];
+}
+++i;
+}
+regfree(pregUuidBracket);
+VIR_FREE(pmatch);
+return ret;
+
+cleanup:
+regfree(pregUuidBracket);
+VIR_FREE(pmatch);
+return ret;
+}
diff --git a/src/util/viruuid.h b/src/util/viruuid.h
index bebd338..276e85f 100644
--- a/src/util/viruuid.h
+++ b/src/util/viruuid.h
@@ -40,4 +40,5 @@ int virUUIDParse(const char *uuidstr,
 const char *virUUIDFormat(const unsigned char *uuid,
   char *uuidstr) ATTRIBUTE_NONNULL(1) 
ATTRIBUTE_NONNULL(2);
 
+char ** virSearchUuid(const char *sourceString, int occurrence, char **ret);
 #endif /* __VIR_UUID_H__ */
-- 
1.7.10.4

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


Re: [libvirt] [PATCH v3 8/8] qemu: Support virtio-mmio transport for virtio on ARM

2013-09-02 Thread Cole Robinson
On 09/02/2013 08:52 AM, Daniel P. Berrange wrote:
 On Fri, Aug 30, 2013 at 12:41:36PM -0400, Cole Robinson wrote:
 Starting with qemu 1.6, the qemu-system-arm vexpress-a9 model has a
 hardcoded virtio-mmio transport which enables attaching all virtio
 devices.

 On the command line, we have to use virtio-XXX-device rather than
 virtio-XXX-pci, thankfully s390 already set the precedent here so
 it's fairly straight forward.

 At the XML level, this adds a new device address type virtio-mmio.
 The controller and addressing don't have any subelements at the
 moment because we they aren't needed for this usecase, but could
 be added later if needed.

 Add a test case for an ARM guest with one of every virtio device
 enabled.
 ---
  src/conf/domain_conf.c | 12 +++-
  src/conf/domain_conf.h |  1 +
  src/qemu/qemu_capabilities.c   | 17 --
  src/qemu/qemu_capabilities.h   |  2 +
  src/qemu/qemu_command.c| 65 
 +-
  .../qemuxml2argv-arm-vexpressa9-virtio.args| 14 +
  .../qemuxml2argv-arm-vexpressa9-virtio.xml | 45 +++
  tests/qemuxml2argvtest.c   |  4 ++
  8 files changed, 139 insertions(+), 21 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-arm-vexpressa9-virtio.xml
 
 ACK
 
 
 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index 380e2bb..1d70eba 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -207,6 +207,7 @@ enum virDomainDeviceAddressType {
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
 +VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO,
  
  VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
  };
 
 So there's no kind of address properties needed for the MMIO
 address type ?

There may be, when the qemu-system-arm -m virt machine lands, which AIUI will
behave more like qemu-system-x86, allowing us to fully specify topology on the
command line.

Right now the only virtio-mmio user (vexpress) hardcodes creation in the qemu
board init code. We might be able to explicitly specify addressing of virtio
devices with -device, but if we can it's not obvious to me, and it's pretty
pointless since we don't have that same control over the rest of the board 
config.

Long term I think the only qemu arm machine type we will really want to
'support' is -M virt since it's closer to what we are used to with x86.

- Cole

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


[libvirt] How to add uplink in esx virtual switch using libvirt

2013-09-02 Thread varun bhatnagar
Hi,

I have an ESXi server, on top of it I have created one VM whose IP address
is 192.168.79.1.
I want to connect to the VM on ESXi server from my host machine but I am
not able to do it.
I have created a network networkforSC and I have pasted my xml file
content below but I am not able to add any uplink (how to add it?) .
Below is the xml file of my node as well as the network which I am creating
on my ESXi server

*domain type='vmware'*
*nametestNode/name*
*uuid50115e16-9bdc-49d7-f171-53c4d7f91710/uuid*
*memory1048576/memory*
*currentMemory1048576/currentMemory*
*vcpu1/vcpu*
*console/dev/console/console*
*os*
*type arch='x86_64'hvm/type*
*/os*
*devices*
*disk type='file' device='disk'*
*source file='[datastore1] testNode/testNode.vmdk'/*
*target dev='sda' bus='scsi'/*
*address type='drive' controller='0' bus='0' unit='0'/*
*/disk*
*controller type='scsi' index='0' model='lsilogic'/*
*!--controller type='scsi' index='0'/--*
*interface type='bridge'*
*mac address='00:50:56:25:48:c7'/*
*source bridge='VM Network'/*
*/interface*
*interface type='bridge'*
*source bridge='test'/*
*/interface*
*/devices*
*/domain*

##

Network File:

*network*
*namenetworkforSC/name*
*portgroup name='test'*
*/portgroup*
*/network*

I have checked the network which got created on the server.
As I have not attached any uplink (vmnic0) I can not see it (I want to
attach it).

#esxcli network vswitch standard list
*
*
*networkforSC*
*Name: networkforSC*
*Class: etherswitch*
*Num Ports: 128*
*Used Ports: 2*
*Configured Ports: 128*
*MTU: 1500*
*CDP Status: listen*
*Beacon Enabled: false*
*Beacon Threshold: 3*
*Beacon Required By:*
*Uplinks:*
*Portgroups: test*


Can anyone please help me out in adding the uplink and also can anyone tell
me whether I am going in a right direction so that I could ping my virtual
machine created on ESXi server.


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

Re: [libvirt] [PATCH 1/2] Fix AM_LDFLAGS typo

2013-09-02 Thread Guido Günther
On Mon, Sep 02, 2013 at 12:37:45PM +0100, Daniel P. Berrange wrote:
 On Sun, Sep 01, 2013 at 11:30:46AM +0200, Guido Günther wrote:
  ---
  This should probably go into 1.1.2
  
   src/Makefile.am | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/src/Makefile.am b/src/Makefile.am
  index 636bcbc..19dfb81 100644
  --- a/src/Makefile.am
  +++ b/src/Makefile.am
  @@ -1455,7 +1455,7 @@ libvirt_driver_nwfilter_la_CFLAGS = \
  -I$(top_srcdir)/src/access \
  -I$(top_srcdir)/src/conf \
  $(AM_CFLAGS)
  -libvirt_driver_nwfilter_la_LDFLAGS = $(LD_AMFLAGS)
  +libvirt_driver_nwfilter_la_LDFLAGS = $(AM_LDFLAGS)
   libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS) $(LIBNL_LIBS) 
  $(DBUS_LIBS)
   if WITH_DRIVER_MODULES
   libvirt_driver_nwfilter_la_LIBADD += ../gnulib/lib/libgnu.la
 
 ACK

Both pushed. Thanks!
 -- Guido

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


Re: [libvirt] [PATCH v3 0/8] Support qemu-system-arm vexpress-a9

2013-09-02 Thread Cole Robinson
On 08/30/2013 12:41 PM, Cole Robinson wrote:
 This series adds the bits needed to kick of a qemu-system-arm -machine
 vexpress-a9 guest. vexpress-a15 likely works as well but is untested.
 
 Patches 1-2 are related bugfixes/improvements.
 
 Patch 6 adds disk bus=sd, which is often the only way to specify storage
 for ARM boards.
 
 Patch 8 adds virtio-mmio address support, which enables virtio
 for ARM vexpress machine types.
 
 The rest are mostly about fixing CLI generations. Unfortunately
 qemu ARM boards don't quite work like x86 where we can mix and match
 devices, so -device is out of the picture (for non-virtio), meaning
 we have to fall back to CLI infrastrucure like -net nic and -serial.
 
 v3:
 Rebased series
 Add qemu.conf nographics_allow_host_audio for patch #1
 Drop domain_conf.c default memballoon handling in patch #2, not #3
 
 Cole Robinson (8):
   qemu: Set QEMU_AUDIO_DRV=none with -nographic
   domain_conf: Add default memballoon in PostParse callbacks
   qemu: Don't add default memballoon device on ARM
   qemu: Fix specifying char devs for ARM
   qemu: Don't try to allocate PCI addresses for ARM
   domain_conf: Add disk bus=sd, wire it up for qemu
   qemu: Fix networking for ARM guests
   qemu: Support virtio-mmio transport for virtio on ARM
 
  docs/formatdomain.html.in  |   3 +-
  docs/schemas/domaincommon.rng  |  20 
  src/conf/domain_conf.c |  29 +++--
  src/conf/domain_conf.h |   2 +
  src/qemu/libvirtd_qemu.aug |   3 +
  src/qemu/qemu.conf |   9 ++
  src/qemu/qemu_capabilities.c   |  23 
  src/qemu/qemu_capabilities.h   |   6 +
  src/qemu/qemu_cgroup.c |   2 +-
  src/qemu/qemu_command.c| 127 
 +
  src/qemu/qemu_conf.c   |   1 +
  src/qemu/qemu_conf.h   |   1 +
  src/qemu/qemu_domain.c |  32 +-
  src/qemu/qemu_process.c|  37 +++---
  src/qemu/test_libvirtd_qemu.aug.in |   1 +
  src/xen/xen_driver.c   |   9 ++
  .../qemuxml2argv-arm-vexpressa9-basic.args |   8 ++
  .../qemuxml2argv-arm-vexpressa9-basic.xml  |  34 ++
  .../qemuxml2argv-arm-vexpressa9-nodevs.args|   5 +
  .../qemuxml2argv-arm-vexpressa9-nodevs.xml |  26 +
  .../qemuxml2argv-arm-vexpressa9-virtio.args|  14 +++
  .../qemuxml2argv-arm-vexpressa9-virtio.xml |  45 
  .../qemuxml2argv-balloon-device-auto.args  |   3 +-
  .../qemuxml2argv-balloon-device-period.args|   3 +-
  .../qemuxml2argv-balloon-device.args   |   3 +-
  tests/qemuxml2argvdata/qemuxml2argv-bios.args  |   2 +-
  .../qemuxml2argv-blkdeviotune.args |   3 +-
  .../qemuxml2argv-blkiotune-device.args |   3 +-
  tests/qemuxml2argvdata/qemuxml2argv-blkiotune.args |   3 +-
  .../qemuxml2argvdata/qemuxml2argv-boot-cdrom.args  |   3 +-
  .../qemuxml2argv-boot-complex-bootindex.args   |   2 +-
  .../qemuxml2argv-boot-complex.args |   2 +-
  .../qemuxml2argvdata/qemuxml2argv-boot-floppy.args |   3 +-
  ...xml2argv-boot-menu-disable-drive-bootindex.args |   3 +-
  .../qemuxml2argv-boot-menu-disable-drive.args  |   3 +-
  .../qemuxml2argv-boot-menu-disable.args|   3 +-
  .../qemuxml2argv-boot-menu-enable.args |   3 +-
  .../qemuxml2argvdata/qemuxml2argv-boot-multi.args  |   3 +-
  .../qemuxml2argv-boot-network.args |   3 +-
  .../qemuxml2argvdata/qemuxml2argv-boot-order.args  |   3 +-
  .../qemuxml2argvdata/qemuxml2argv-bootloader.args  |   3 +-
  .../qemuxml2argv-channel-guestfwd.args |   3 +-
  .../qemuxml2argv-channel-virtio-auto.args  |   3 +-
  .../qemuxml2argv-channel-virtio.args   |   3 +-
  .../qemuxml2argv-clock-france.args |   4 +-
  .../qemuxml2argv-clock-localtime.args  |   3 +-
  tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args |   3 +-
  .../qemuxml2argv-clock-variable.args   |   3 +-
  .../qemuxml2argv-console-compat-auto.args  |   3 +-
  .../qemuxml2argv-console-compat-chardev.args   |   3 +-
  .../qemuxml2argv-console-compat.args   |   3 +-
  .../qemuxml2argv-console-sclp.args |   3 +-
  .../qemuxml2argv-console-virtio-ccw.args   |   3 +-
  .../qemuxml2argv-console-virtio-many.args  |   3 +-
  .../qemuxml2argv-console-virtio-s390.args  |   3 +-
  .../qemuxml2argv-console-virtio.args   |   3 +-
  .../qemuxml2argv-cpu-eoi-disabled.args |   3 +-
  .../qemuxml2argv-cpu-eoi-enabled.args  |   3 +-
  .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |   3 +-
  

[libvirt] [PATCH] Drop ChangeLog generation

2013-09-02 Thread Cole Robinson
Fedora is perpetually low on space for its live cd, and a bug was filed
asking libvirt to drop the rather large ChangeLog from the RPM:

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

Really though, what's the point of a static ChangeLog these days? git
has won, and is far more useful for querying log info than a large
static blob.

This patch drops the ChangeLog generation. In its place there's now
a small stub file pointing to the online git log.

Additionally, the RPM was installing the ChangeLog and other doc
bits twice, once with the daemon and once with the client. Drop the
docs from the daemon package, it requires the client anyways.
---
 I clipped the removal of ChangeLog-old since it exceeded mail size for
 the list.

 .gitignore  | 1 -
 ChangeLog   | 8 +
 ChangeLog-old   | 16699 --
 Makefile.am |15 +-
 bootstrap.conf  | 4 +-
 cfg.mk  | 2 +-
 libvirt.spec.in | 4 +-
 7 files changed, 13 insertions(+), 16720 deletions(-)
 create mode 100644 ChangeLog
 delete mode 100644 ChangeLog-old

diff --git a/.gitignore b/.gitignore
index 8a94748..07594f4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,7 +28,6 @@
 .sc-start-sc_*
 /ABOUT-NLS
 /AUTHORS
-/ChangeLog
 /GNUmakefile
 /INSTALL
 /NEWS
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 000..13c0fa4
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,8 @@
+The git repository log is the canonical changelog. It can be viewed online
+at:
+
+http://libvirt.org/git/?p=libvirt.git;a=log
+
+The historical ChangeLog from pre-git times is at:
+
+http://libvirt.org/git/?p=libvirt.git;a=blob;f=ChangeLog-old;h=b5d44d5dced1382e62b43db7e16614231aeb15dd;hb=HEAD
diff --git a/Makefile.am b/Makefile.am
index 4e24ecf..92ba1d4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,7 +31,6 @@ XML_EXAMPLES = \
test/*.xml storage/*.xml)))
 
 EXTRA_DIST = \
-  ChangeLog-old \
   libvirt.spec libvirt.spec.in \
   mingw-libvirt.spec.in \
   libvirt.pc.in \
@@ -95,19 +94,7 @@ MAINTAINERCLEANFILES = .git-module-status
 # disable this check
 distuninstallcheck:
 
-dist-hook: gen-ChangeLog gen-AUTHORS
-
-# Generate the ChangeLog file (with all entries since the switch to git)
-# and insert it into the directory we're about to use to create a tarball.
-gen_start_date = 2009-07-04
-.PHONY: gen-ChangeLog
-gen-ChangeLog:
-   $(AM_V_GEN)if test -d .git; then\
- $(top_srcdir)/build-aux/gitlog-to-changelog   \
-   --since=$(gen_start_date)  $(distdir)/cl-t;\
- rm -f $(distdir)/ChangeLog;   \
- mv $(distdir)/cl-t $(distdir)/ChangeLog;  \
-   fi
+dist-hook: gen-AUTHORS
 
 .PHONY: gen-AUTHORS
 gen-AUTHORS:
diff --git a/bootstrap.conf b/bootstrap.conf
index 68c4a89..63f79c9 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -228,8 +228,8 @@ if `(${PYTHON_CONFIG-python-config} --version;
   PYTHON_CONFIG=true
 fi
 
-# Automake requires that ChangeLog and AUTHORS exist.
-touch AUTHORS ChangeLog || exit 1
+# Automake requires that AUTHORS exists.
+touch AUTHORS || exit 1
 
 # Override bootstrap's list - we don't use mdate-sh or texinfo.tex.
 gnulib_extra_files=
diff --git a/cfg.mk b/cfg.mk
index 9a9616c..d223e48 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -874,7 +874,7 @@ ifeq (0,$(MAKELEVEL))
   _clean_requested = $(filter %clean,$(MAKECMDGOALS))
   ifeq (1,$(_update_required)$(_clean_requested))
 $(info INFO: gnulib update required; running ./autogen.sh first)
-$(shell touch $(srcdir)/AUTHORS $(srcdir)/ChangeLog)
+$(shell touch $(srcdir)/AUTHORS)
 maint.mk Makefile: _autogen
   endif
 endif
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 85881ae..dd9702e 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1413,7 +1413,6 @@ of recent versions of Linux (and other OSes).
--enable-expensive-tests \
%{init_scripts}
 make %{?_smp_mflags}
-gzip -9 ChangeLog
 
 %install
 rm -fr %{buildroot}
@@ -1739,7 +1738,6 @@ fi
 %files daemon
 %defattr(-, root, root)
 
-%doc AUTHORS ChangeLog.gz NEWS README COPYING COPYING.LESSER TODO
 %dir %attr(0700, root, root) %{_sysconfdir}/libvirt/
 
 %if %{with_network}
@@ -2011,7 +2009,7 @@ fi
 
 %files client -f %{name}.lang
 %defattr(-, root, root)
-%doc AUTHORS ChangeLog.gz NEWS README COPYING COPYING.LESSER TODO
+%doc AUTHORS ChangeLog NEWS README COPYING COPYING.LESSER TODO
 
 %config(noreplace) %{_sysconfdir}/libvirt/libvirt.conf
 %config(noreplace) %{_sysconfdir}/libvirt/virt-login-shell.conf
-- 
1.8.3.1

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


Re: [libvirt] [PATCHv3 4/4] VMX: Some serial ports are not actually connected

2013-09-02 Thread Doug Goldstein
On Thu, Aug 29, 2013 at 5:19 AM, Michal Privoznik mpriv...@redhat.comwrote:

 On 28.08.2013 23:53, Doug Goldstein wrote:
  Sometimes a serial port might not be actually wired to a device when the
  user does not have the VM powered on and we should not consider this a
  fatal error.
  ---
   src/vmx/vmx.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
  diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
  index bcbb997..036e234 100644
  --- a/src/vmx/vmx.c
  +++ b/src/vmx/vmx.c
  @@ -2702,7 +2702,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr
 conf, int port,
 
   /* vmx:fileName - def:data.file.path */
   if (virVMXGetConfigString(conf, fileName_name, fileName, false) 
 0) {
  -goto cleanup;
  +goto ignore;
   }
 
   /* vmx:network.endPoint - def:data.tcp.listen */
 

 ACK

 Michal


Pushed. thanks.


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

Re: [libvirt] [PATCH]LXC doc: Add warns if net namespace not enabled

2013-09-02 Thread Chen Hanxiao
Hi
Any comments?

Thanks

 -Original Message-
 From: Chen Hanxiao [mailto:chenhanx...@cn.fujitsu.com]
 Sent: Friday, August 23, 2013 1:18 PM
 To: libvir-list@redhat.com
 Cc: chenhanx...@cn.fujitsu.com
 Subject: [libvirt][PATCH]LXC doc: Add warns if net namespace not enabled
 
 From: Chen Hanxiao chenhanx...@cn.fujitsu.com
 
 If we don't enable network namespace, we could shutdown host by executing
 command 'shutdown' inside container.
 This patch will add some warnings in LXC docs and give some advice to readers.
 
 Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
 ---
  docs/drvlxc.html.in |7 +++
  1 files changed, 7 insertions(+), 0 deletions(-)
 
 diff --git a/docs/drvlxc.html.in b/docs/drvlxc.html.in index 640968f..8f3a36a
 100644
 --- a/docs/drvlxc.html.in
 +++ b/docs/drvlxc.html.in
 @@ -50,6 +50,13 @@ processes inside containers cannot be securely isolated
 from host  process without the use of a mandatory access control technology
 such as SELinux or AppArmor./strong  /p
 +p
 +strongWARNING: If 'net' namespace inot/i enabled for container,
 +host OS could be ishutdown/i by executing command like 'reboot'
 +inside container.br/So make sure 'net' namespace was available and
 +set the lt;privnet/gt; feature in the XML, or configure virtual NICs.
 +Then this issue could be circumvented./strong /p
 
  h2a name=initDefault container setup/a/h2
 
 --
 1.7.1




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


Re: [libvirt] [Qemu-devel] [PATCH 3/5] qemu: add usb-bot support from disks points of view

2013-09-02 Thread Guannan Ren

On 09/02/2013 08:57 PM, Daniel P. Berrange wrote:

On Mon, Sep 02, 2013 at 05:38:42PM +0800, Guannan Ren wrote:

usb-bot only supports 16 luns(0~15) and they must be contiguous,
(using lun 0 and 2 without 1 doesn't work). In this case qemu
doesn't throw an error, we can not find the lun 2 in guests. So
Adding a checking function in libvirt to prevent from this case.

Hmm, this seems like a problematic restriction.

How does this work if we start off a guest with 3 disks
attached to the usb-bot SCSI controller. Then hot-unplug
the 2nd disk.


Currently, the qemu will throw out an error when I hot-unplug any of 
disks attached to usb-bot controller.


{ execute: device_del, arguments: { id: scsi1-0-0-1}}
{error: {class: GenericError, desc: Bus 'scsi1.0' does not 
support hotplugging}}


Libvirt will report an error:
# virsh detach-disk rhel64qcow2 sdd --current
error: Failed to detach disk
error: internal error: unable to execute QEMU command 'device_del': Bus 
'scsi1.0' does not support hotplugging





Next time we need will need to start with with LUNs 0
and 2 populated only, otherwise we have ABI change upon
migrate or save/restore.

I think this restriction about contiguous luns must be
removed if this device is to be usable with multiple luns.

Daniel


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


[libvirt] [PATCH] Docs: fix a typo in virt-login-shell.pod

2013-09-02 Thread Alex Jia

Signed-off-by: Alex Jia a...@redhat.com
---
 tools/virt-login-shell.pod |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/virt-login-shell.pod b/tools/virt-login-shell.pod
index e27d500..bcd7855 100644
--- a/tools/virt-login-shell.pod
+++ b/tools/virt-login-shell.pod
@@ -11,7 +11,7 @@ Bvirt-login-shell
 The Bvirt-login-shell program is a setuid shell that is used to join
 an LXC container that matches the user's name.  If the container is not
 running, virt-login-shell will attempt to start the container.
-virt-sandbox-shell is not allowed to be run by root.  Normal users will get
+virt-login-shell is not allowed to be run by root.  Normal users will get
 added to a container that matches their username, if it exists, and they are
 configured in /etc/libvirt/virt-login-shell.conf.
 
-- 
1.7.1

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


Re: [libvirt] Libvirt multi queue support

2013-09-02 Thread Naor Shlomo
Hi Michal

First of all I want to let you know that I really appreciate your guidance.
Second thing, after I successfully installed the kernel headers I was able to 
compile libvirt again, this time it let me start the Guest with queues='5'
The Guest runs Kernel 3.9.7 but for some reason virtio_has_feature(vdev, 
VIRTIO_NET_F_MQ) returns false for multi queue.

Could you please tell me what am I missing?

Thanks,
Naor

-Original Message-
From: Michal Privoznik [mailto:mpriv...@redhat.com] 
Sent: Thursday, August 29, 2013 10:13 AM
To: Naor Shlomo
Cc: libvir-list@redhat.com
Subject: Re: [libvirt] Libvirt multi queue support

On 29.08.2013 08:55, Naor Shlomo wrote:
 How odd.
 
 The Kernel is the first thing I upgraded, here's the output of uname -r:
 3.10.9
 
 I searched for IFF_MULTI_QUEUE in /usr/include/linux/if_tun.h and indeed it 
 wasn't there.
 I believe Kernel 3.10 should support the Multi Queue, do I need to recompile 
 it? maybe change its config file?

You shouldn't need to enable anything in the .config. However, you may need to 
update the linux-headers if you're building the libvirt on your own. There's a 
build-time check for IFF_MULTI_QUEUE.

Michal

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