Re: [libvirt] [PATCH v2 09/10] qemu: hotplug support for scsi hostdev

2013-04-05 Thread Han Cheng

On 04/03/2013 06:20 PM, Osier Yang wrote:

On 01/04/13 20:01, Han Cheng wrote:

And user should hotplug a virtio-scsi controller if doesn't exist.


I'm wondering if it could be implicitly added.


As I know, adding controller implicitly is for back compatibility. New 
codes don't need to do this.

Am I right?


Usb hostdev related codes are in qemuDomainAttachHostDevice, push down to
qemuDomainAttachHostUsbDevice.

Signed-off-by: Han Cheng hanc.f...@cn.fujitsu.com
---
src/qemu/qemu_hotplug.c | 211
++-
1 files changed, 173 insertions(+), 38 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b978b97..a78b410 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
+
+ if (qemuAssignDeviceHostdevAlias(vm-def, hostdev, 0)  0)
+ goto error;
+ if (!(drvstr = qemuBuildSCSIHostdevDrvStr(hostdev, priv-qemuCaps)))
+ goto error;
+ if (!(devstr = qemuBuildSCSIHostdevDevStr(vm-def, hostdev,
priv-qemuCaps)))
+ goto error;
+
+ if (VIR_REALLOC_N(vm-def-hostdevs, vm-def-nhostdevs+1)  0) {


vm-def-nhostdevs + 1


+ virReportOOMError();
+ goto error;
+ }


vm-def-hostdevs[def-nhostdevs] is leaked if it errors out later.


I don't think so. vm-def-hostdevs[def-nhostdevs] is still tracked by 
vm-def-hostdevs. It is comsumed but without any data. It will be free 
when we free or realloc vm-def-hostdevs. And it is not big(sizeof(void 
*)).

Besides, others code in this file deal with it in the same way.

Actually, I find memory leak with usb code in the file. I fix it in this 
patch. I'll point it as following. Could you check it for me?




@@ -1123,6 +1215,26 @@ int
qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
int ret;
qemuDomainObjPrivatePtr priv = vm-privateData;
char *devstr = NULL;
+ virUSBDeviceList *list;
+ virUSBDevicePtr usb = NULL;
+
+
+ if (!(list = virUSBDeviceListNew()))
+ goto error;
+
+ if (qemuFindHostdevUSBDevice(hostdev, true, usb)  0)
+ goto error;
+
+ if (virUSBDeviceListAdd(list, usb)  0) {
+ virUSBDeviceFree(usb);
+ usb = NULL;
+ goto error;
+ }
+
+ if (qemuPrepareHostdevUSBDevices(driver, vm-def-name, list)  0) {
+ usb = NULL;
+ goto error;
+ }
if (virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE)) {
if (qemuAssignDeviceHostdevAlias(vm-def, hostdev, -1)  0)
@@ -1138,7 +1250,6 @@ int
qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_DEVICES)) {
virCgroupPtr cgroup = NULL;
- virUSBDevicePtr usb;
qemuCgroupData data;
if (virCgroupForDomain(driver-cgroup, vm-def-name, cgroup, 0) != 0) {
@@ -1148,19 +1259,12 @@ int
qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
goto error;
}
- if ((usb = virUSBDeviceNew(hostdev-source.subsys.u.usb.bus,
- hostdev-source.subsys.u.usb.device,
- NULL)) == NULL)
- goto error;
-
data.vm = vm;
data.cgroup = cgroup;
if (virUSBDeviceFileIterate(usb, qemuSetupHostUsbDeviceCgroup,
data)  0) {
- virUSBDeviceFree(usb);
goto error;
}
- virUSBDeviceFree(usb);
}
qemuDomainObjEnterMonitor(driver, vm);
@@ -1177,11 +1281,16 @@ int
qemuDomainAttachHostUsbDevice(virQEMUDriverPtr driver,
vm-def-hostdevs[vm-def-nhostdevs++] = hostdev;
+ virUSBDeviceListSteal(list, usb);
+ virObjectUnref(list);
VIR_FREE(devstr);
return 0;
error:
+ if (usb)
+ virUSBDeviceListSteal(driver-activeUsbHostdevs, usb);
+ virObjectUnref(list);
VIR_FREE(devstr);
return -1;
}
@@ -1190,9 +1299,6 @@ int qemuDomainAttachHostDevice(virQEMUDriverPtr
driver,
virDomainObjPtr vm,
virDomainHostdevDefPtr hostdev)
{
- virUSBDeviceList *list;
- virUSBDevicePtr usb = NULL;
-
if (hostdev-mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(hostdev mode '%s' not supported),
@@ -1200,30 +1306,10 @@ int
qemuDomainAttachHostDevice(virQEMUDriverPtr driver,
return -1;
}
- if (!(list = virUSBDeviceListNew()))
- goto cleanup;
-
- if (hostdev-source.subsys.type ==
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) {
- if (qemuFindHostdevUSBDevice(hostdev, true, usb)  0)
- goto cleanup;
-
- if (virUSBDeviceListAdd(list, usb)  0) {
- virUSBDeviceFree(usb);
- usb = NULL;
- goto cleanup;
- }
-
- if (qemuPrepareHostdevUSBDevices(driver, vm-def-name, list)  0) {
- usb = NULL;
- goto cleanup;
- }
-
- virUSBDeviceListSteal(list, usb);


We steal usb from list.
*usb is tracked both by usb and driver-activeUsbHostdevs.
If it errors later, we goto error: [1]

- }
if (virSecurityManagerSetHostdevLabel(driver-securityManager,
vm-def, hostdev, NULL)  0)
- goto cleanup;
+ return -1;
switch (hostdev-source.subsys.type) {
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
@@ -1238,6 +1324,12 @@ int qemuDomainAttachHostDevice(virQEMUDriverPtr
driver,
goto error;
break;
+ case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+ if (qemuDomainAttachHostScsiDevice(driver, vm,
+ hostdev)  0)
+ goto error;
+ break;
+
default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(hostdev subsys type '%s' not supported),
@@ -1245,18 +1337,12 @@ int
qemuDomainAttachHostDevice(virQEMUDriverPtr driver,
goto error;
}
- 

Re: [libvirt] [PATCH 2/8] Introduce new XMLs to specify disk source using libvirt storage

2013-04-05 Thread Paolo Bonzini
Il 04/04/2013 21:40, Osier Yang ha scritto:

 Depending on the pool type, this should be treated as file or block.
 You do this correctly in patch 8, but I think it is not complete.  For
 example, will your patches allow SCSI passthrough of a volume inside an
 iSCSI pool?
 
 No, it will be another patch set. On top of Han cheng's patches.

scsi-generic support for iSCSI pool would need his patches, but
scsi-block shouldn't.

My impression is that you already have half baked support for this
feature in patches 7/8, and you should either complete it, or leave it
out of this series.

Paolo

 I'm waiting for those patches go in first, or I will rebase/update
 it if Han doesn't have enough time to do it, and do the work
 after that.

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


[libvirt] [PATCH 1/2] Update structure and XML definitions to support hostdev caps=net.

2013-04-05 Thread Bogdan Purcareata
Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
---
 docs/formatdomain.html.in | 15 +--
 docs/schemas/domaincommon.rng | 14 ++
 src/conf/domain_conf.c| 28 +++-
 src/conf/domain_conf.h|  4 
 4 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cf382e8..8ac2441 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2326,18 +2326,29 @@
 ...
 /pre
 
+...
+lt;hostdev mode='capabilities' type='net'gt;
+  lt;sourcegt;
+lt;interfacegt;eth0lt;/interfacegt;
+  lt;/sourcegt;
+lt;/hostdevgt;
+...
+/pre
+
 dl
   dtcodehostdev/code/dt
   ddThe codehostdev/code element is the main container for describing
 host devices. For block/character device passthrough codemode/code 
is
 always capabilities and codetype/code is block for a block
-device and char for a character device.
+device, char for a character device and interface for a host
+network interface.
   /dd
   dtcodesource/code/dt
   ddThe source element describes the device as seen from the host.
 For block devices, the path to the block device in the host
 OS is provided in the nested block element, while for character
-devices the char element is used
+devices the char element is used. For network interfaces, the
+name of the interface is provided in the interface element.
   /dd
 /dl
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 454ebdb..208c4c2 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2956,6 +2956,9 @@
   group
 ref name=hostdevcapsmisc/
   /group
+  group
+ref name=hostdevcapsnet/
+  /group
 /choice
   /define
 
@@ -3016,6 +3019,17 @@
 /element
   /define
 
+  define name=hostdevcapsnet
+attribute name=type
+  valuenet/value
+/attribute
+element name=source
+  element name=interface
+ref name=deviceName/
+  /element
+/element
+  /define
+
   define name=usbproduct
 element name=vendor
   attribute name=id
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cc26f21..c1ce696 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -577,7 +577,8 @@ VIR_ENUM_IMPL(virDomainHostdevSubsys, 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST,
   storage,
-  misc)
+  misc,
+  net)
 
 VIR_ENUM_IMPL(virDomainPciRombarMode,
   VIR_DOMAIN_PCI_ROMBAR_LAST,
@@ -1566,6 +1567,9 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 VIR_FREE(def-source.caps.u.misc.chardev);
 break;
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+VIR_FREE(def-source.caps.u.net.interface);
+break;
 }
 }
 }
@@ -3440,6 +3444,14 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node 
ATTRIBUTE_UNUSED,
 goto error;
 }
 break;
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+if (!(def-source.caps.u.net.interface =
+  virXPathString(string(./source/interface[1]), ctxt))) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(Missing interface element in hostdev net 
device));
+goto error;
+}
+break;
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(address type='%s' not supported in hostdev 
interfaces),
@@ -8602,6 +8614,14 @@ virDomainHostdevMatchCapsMisc(virDomainHostdevDefPtr a,
   b-source.caps.u.misc.chardev);
 }
 
+static int
+virDomainHostdevMatchCapsNet(virDomainHostdevDefPtr a,
+  virDomainHostdevDefPtr b)
+{
+return STREQ_NULLABLE(a-source.caps.u.net.interface,
+  b-source.caps.u.net.interface);
+}
+
 
 static int
 virDomainHostdevMatchCaps(virDomainHostdevDefPtr a,
@@ -8615,6 +8635,8 @@ virDomainHostdevMatchCaps(virDomainHostdevDefPtr a,
 return virDomainHostdevMatchCapsStorage(a, b);
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 return virDomainHostdevMatchCapsMisc(a, b);
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+return virDomainHostdevMatchCapsNet(a, b);
 }
 return 0;
 }
@@ -13295,6 +13317,10 @@ virDomainHostdevDefFormatCaps(virBufferPtr buf,
 virBufferEscapeString(buf, char%s/char\n,
   def-source.caps.u.misc.chardev);
 break;
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+virBufferEscapeString(buf, interface%s/interface\n,
+  def-source.caps.u.net.interface);
+break;
 default:
 virReportError(VIR_ERR_INTERNAL_ERROR,

[libvirt] libvirt_lxc: implement hostdev caps=net device isolation in containers

2013-04-05 Thread Bogdan Purcareata
From Bogdan Purcareata bogdan.purcare...@freescale.com # This line is 
ignored.
From: Bogdan Purcareata bogdan.purcare...@freescale.com
Subject: libvirt_lxc: implement hostdev caps=net device isolation in 
containers
In-Reply-To: 


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


[libvirt] [PATCH 2/2] Implement support for hostdev caps=net. This allows a container-type domain to have exclusive access to one of the host's NICs.

2013-04-05 Thread Bogdan Purcareata
Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
---
 src/lxc/lxc_container.c  |  4 +++-
 src/lxc/lxc_controller.c | 19 +++
 src/lxc/lxc_hostdev.c|  1 +
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 002ba9e..e59bfdf 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1551,7 +1551,6 @@ cleanup:
 return ret;
 }
 
-
 static int lxcContainerSetupHostdevSubsys(virDomainDefPtr vmDef,
   virDomainHostdevDefPtr def,
   const char *dstprefix,
@@ -1582,6 +1581,9 @@ static int lxcContainerSetupHostdevCaps(virDomainDefPtr 
vmDef,
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 return lxcContainerSetupHostdevCapsMisc(vmDef, def, dstprefix, 
securityDriver);
 
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+return 0; // case is handled in virLXCControllerMoveInterfaces
+
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Unsupported host device mode %s),
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index cede445..ab488d8 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1050,12 +1050,31 @@ cleanup2:
 static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
 {
 size_t i;
+virDomainDefPtr def = ctrl-def;
 
 for (i = 0 ; i  ctrl-nveths ; i++) {
 if (virNetDevSetNamespace(ctrl-veths[i], ctrl-initpid)  0)
 return -1;
 }
 
+for (i = 0; i  def-nhostdevs; i ++) {
+   virDomainHostdevDefPtr hdev = def-hostdevs[i];
+
+   if (hdev-mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
+continue;
+}
+
+virDomainHostdevCaps hdcaps = hdev-source.caps;
+
+   if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) {
+   continue;
+}
+
+if (virNetDevSetNamespace(hdcaps.u.net.interface, ctrl-initpid)  0) {
+return -1;
+   }
+}
+
 return 0;
 }
 
diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c
index 33b0b60..53a1a31 100644
--- a/src/lxc/lxc_hostdev.c
+++ b/src/lxc/lxc_hostdev.c
@@ -307,6 +307,7 @@ int virLXCPrepareHostDevices(virLXCDriverPtr driver,
 switch (dev-source.subsys.type) {
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE:
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
 break;
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
1.7.11.7


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



[libvirt] [PATCH 2/2] Implement support for hostdev caps=net

2013-04-05 Thread Bogdan Purcareata
This allows a container-type domain to have exclusive access to one of
the host's NICs.

Wire hostdev caps=net with the lxc_controller - when moving the newly
created veth devices into a new namespace, also look for any hostdev
devices that should be moved. Note: once the container domain has been
destroyed, there is no code that moves the interfaces back to the 
original namespace. This does happen, though, probably due to default
cleanup on namespace destruction.

Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
---
 src/lxc/lxc_container.c  |  4 +++-
 src/lxc/lxc_controller.c | 19 +++
 src/lxc/lxc_hostdev.c|  1 +
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 002ba9e..e59bfdf 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1551,7 +1551,6 @@ cleanup:
 return ret;
 }
 
-
 static int lxcContainerSetupHostdevSubsys(virDomainDefPtr vmDef,
   virDomainHostdevDefPtr def,
   const char *dstprefix,
@@ -1582,6 +1581,9 @@ static int lxcContainerSetupHostdevCaps(virDomainDefPtr 
vmDef,
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 return lxcContainerSetupHostdevCapsMisc(vmDef, def, dstprefix, 
securityDriver);
 
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+return 0; // case is handled in virLXCControllerMoveInterfaces
+
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Unsupported host device mode %s),
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index cede445..ab488d8 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1050,12 +1050,31 @@ cleanup2:
 static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
 {
 size_t i;
+virDomainDefPtr def = ctrl-def;
 
 for (i = 0 ; i  ctrl-nveths ; i++) {
 if (virNetDevSetNamespace(ctrl-veths[i], ctrl-initpid)  0)
 return -1;
 }
 
+for (i = 0; i  def-nhostdevs; i ++) {
+   virDomainHostdevDefPtr hdev = def-hostdevs[i];
+
+   if (hdev-mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
+continue;
+}
+
+virDomainHostdevCaps hdcaps = hdev-source.caps;
+
+   if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) {
+   continue;
+}
+
+if (virNetDevSetNamespace(hdcaps.u.net.interface, ctrl-initpid)  0) {
+return -1;
+   }
+}
+
 return 0;
 }
 
diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c
index 33b0b60..53a1a31 100644
--- a/src/lxc/lxc_hostdev.c
+++ b/src/lxc/lxc_hostdev.c
@@ -307,6 +307,7 @@ int virLXCPrepareHostDevices(virLXCDriverPtr driver,
 switch (dev-source.subsys.type) {
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE:
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
 break;
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
1.7.11.7


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


[libvirt] [PATCH 1/2] Update structure XML definitions to support hostdev caps=net.

2013-04-05 Thread Bogdan Purcareata
This updates the definitions and supporting structures in the XML 
schema and domain configuration files.

Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
---
 docs/formatdomain.html.in | 15 +--
 docs/schemas/domaincommon.rng | 14 ++
 src/conf/domain_conf.c| 28 +++-
 src/conf/domain_conf.h|  4 
 4 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cf382e8..8ac2441 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2326,18 +2326,29 @@
 ...
 /pre
 
+...
+lt;hostdev mode='capabilities' type='net'gt;
+  lt;sourcegt;
+lt;interfacegt;eth0lt;/interfacegt;
+  lt;/sourcegt;
+lt;/hostdevgt;
+...
+/pre
+
 dl
   dtcodehostdev/code/dt
   ddThe codehostdev/code element is the main container for describing
 host devices. For block/character device passthrough codemode/code 
is
 always capabilities and codetype/code is block for a block
-device and char for a character device.
+device, char for a character device and interface for a host
+network interface.
   /dd
   dtcodesource/code/dt
   ddThe source element describes the device as seen from the host.
 For block devices, the path to the block device in the host
 OS is provided in the nested block element, while for character
-devices the char element is used
+devices the char element is used. For network interfaces, the
+name of the interface is provided in the interface element.
   /dd
 /dl
 
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 454ebdb..208c4c2 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2956,6 +2956,9 @@
   group
 ref name=hostdevcapsmisc/
   /group
+  group
+ref name=hostdevcapsnet/
+  /group
 /choice
   /define
 
@@ -3016,6 +3019,17 @@
 /element
   /define
 
+  define name=hostdevcapsnet
+attribute name=type
+  valuenet/value
+/attribute
+element name=source
+  element name=interface
+ref name=deviceName/
+  /element
+/element
+  /define
+
   define name=usbproduct
 element name=vendor
   attribute name=id
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cc26f21..c1ce696 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -577,7 +577,8 @@ VIR_ENUM_IMPL(virDomainHostdevSubsys, 
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST,
 
 VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST,
   storage,
-  misc)
+  misc,
+  net)
 
 VIR_ENUM_IMPL(virDomainPciRombarMode,
   VIR_DOMAIN_PCI_ROMBAR_LAST,
@@ -1566,6 +1567,9 @@ void virDomainHostdevDefClear(virDomainHostdevDefPtr def)
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 VIR_FREE(def-source.caps.u.misc.chardev);
 break;
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+VIR_FREE(def-source.caps.u.net.interface);
+break;
 }
 }
 }
@@ -3440,6 +3444,14 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node 
ATTRIBUTE_UNUSED,
 goto error;
 }
 break;
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+if (!(def-source.caps.u.net.interface =
+  virXPathString(string(./source/interface[1]), ctxt))) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(Missing interface element in hostdev net 
device));
+goto error;
+}
+break;
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(address type='%s' not supported in hostdev 
interfaces),
@@ -8602,6 +8614,14 @@ virDomainHostdevMatchCapsMisc(virDomainHostdevDefPtr a,
   b-source.caps.u.misc.chardev);
 }
 
+static int
+virDomainHostdevMatchCapsNet(virDomainHostdevDefPtr a,
+  virDomainHostdevDefPtr b)
+{
+return STREQ_NULLABLE(a-source.caps.u.net.interface,
+  b-source.caps.u.net.interface);
+}
+
 
 static int
 virDomainHostdevMatchCaps(virDomainHostdevDefPtr a,
@@ -8615,6 +8635,8 @@ virDomainHostdevMatchCaps(virDomainHostdevDefPtr a,
 return virDomainHostdevMatchCapsStorage(a, b);
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 return virDomainHostdevMatchCapsMisc(a, b);
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+return virDomainHostdevMatchCapsNet(a, b);
 }
 return 0;
 }
@@ -13295,6 +13317,10 @@ virDomainHostdevDefFormatCaps(virBufferPtr buf,
 virBufferEscapeString(buf, char%s/char\n,
   def-source.caps.u.misc.chardev);
 break;
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+virBufferEscapeString(buf, interface%s/interface\n,
+  

[libvirt] libvirt_lxc: implement hostdev caps=net device isolation in containers

2013-04-05 Thread Bogdan Purcareata
This set of patches implements hostdev caps=net interface isolation in
containers, thus allowing an interface NIC to be assigned exclusively to
a container-domain. This is done like moving veth devices in container
namespaces, only this time it is actual host devices.


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


Re: [libvirt] [PATCH v5.1 04/11] qemu: Record the default NIC model in the domain XML

2013-04-05 Thread Viktor Mihajlovski

On 04/04/2013 09:50 PM, Peter Krempa wrote:


I don't know if the realtek card works on the s390 qemu too, but if it
doesn't I don't mind changing it to virtio. In case it does work, we
need to consider if we aren't regressing here.



commit 539d73d intercepts this global defaulting but relies on the model
being NULL. So your patch is indeed causing a regression. We can fix
this before the next release though. No need for a V5.1.1 ;-)

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

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

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


Re: [libvirt] [PATCH] qemu: Remove maximum cpu limit when setting processor count using the API

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 12:11:31AM +0200, Peter Krempa wrote:
 When setting processor count for a domain using the API libvirt enforced
 a maximum processor count, while it isn't enforced when taking the XML path.
 
 This patch removes the check to match the API.

Do you mean  s/API/XML/ here ?

I'm not sure whether removing this check is a good idea. Should we not
instead make the guest startup code also validate max CPU count when
generating the CLI args ?

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] Device backend in another domain (xen)

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 01:23:15AM +0200, Marek Marczykowski wrote:
 Hi all,
 
 Xen have (AFAIK unique) feature of having backend device in other domU
 (sometimes called driver domain) instead of dom0. Currently libxl support it
 for disk and network devices, but in general it is valid for any device
 (perhaps excluding PCI). Current implementation requires ID of backend domain
 to be specified during device attach/domain startup. There are some upcoming
 patches to allow also use domain name.
 
 I'd like to add support for it into libvirt. The question is how specify
 domain reference. The simplest approach is to use direct domain ID, logically
 it fits in source/ tag, so something like:
 disk type='file'
   source file='/path/to/file/inside/domain/7' domid='7'/
   target dev='xvdb'/
 /disk
 interface type='bridge'
   source bridge='name-of-bridge-in-domiain-7' domid='7'/
 /interface
 
 This have obvious limitation that domain ID changes with each domain restart.
 But perhaps more correct approach is to use name or UUID?

Yeah, I think you're going to want to use the name/uuid here as
they are long term stable.

 Extending source/ tag is right thing to do? Or should I add a new tag
 (backenddomain uuid='...'/ ? )?

I think perhaps the new tag like backenddomain is a good idea.
Perhaps just shorten that name to domain

 Regarding implementation I need some hints how to do the value verification
 (check if domain exists at least). If it has to be done in domain_conf.c
 (during XML parsing) it will require predetermined domain load order, which
 IMHO isn't acceptable. So perhaps the check should be done at domain
 startup/device attach (by driver)?
 In any case: is it possible at all to check if domain with given name/UUID
 exists in scope of domain_conf.c? It looks like it requires connection
 reference, which isn't passed to virDomain*DefParseXML.

The code in domain_conf.c should only concern itself with syntactic
validation. Any kind of semantic validation should live in the driver
code, for example in src/xen/*.c  (or src/.libxl/*.c if you're planning
to use the new xen driver).

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] [PATCHv3 6/6] rpc: Fix connection close callback race condition and memory corruption/crash

2013-04-05 Thread Peter Krempa

On 04/05/13 04:50, Eric Blake wrote:

On 03/31/2013 10:20 AM, Peter Krempa wrote:

The last Viktor's effort to fix the race and memory corruption unfortunately
wasn't complete in the case the close callback was not registered in an
connection. At that time, the trail of event's that I'll describe later could
still happend and corrupt the memory or cause a crash of the client (including
the daemon in case of a p2p migration).




The new object - virConnectCloseCallbackData - is a lockable object that keeps
the pointers to the real user registered callback and ensures that the
connection callback is either not called if the connection was already freed or
that the connection isn't freed while this is being called.
---
  src/datatypes.c| 55 
  src/datatypes.h| 22 ++
  src/libvirt.c  | 29 ---
  src/remote/remote_driver.c | 57 +++---
  4 files changed, 112 insertions(+), 51 deletions(-)


I've (finally) completed my stress-testing, and agree that this patch is
sufficient to avoid the race (especially when patch 1/6 is also applied
to make the race more obvious).

ACK, and let's get this applied and backported to maintenance branches
as appropriate.


Thanks I've pushed this upstream and I will post a 0.10.2 backport later.

Peter

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


Re: [libvirt] [PATCH v2 10/10] tests: tests for scsi hostdev

2013-04-05 Thread Han Cheng



On 04/03/2013 06:26 PM, Osier Yang wrote:

On 01/04/13 20:01, Han Cheng wrote:

diff --git a/tests/qemuhelpdata/qemu-1.0-device
b/tests/qemuhelpdata/qemu-1.0-device
index 0bdfbbd..d557f0e 100644
--- a/tests/qemuhelpdata/qemu-1.0-device
+++ b/tests/qemuhelpdata/qemu-1.0-device
@@ -136,3 +136,13 @@ virtio-net-pci.romfile=string
virtio-net-pci.rombar=uint32
virtio-net-pci.multifunction=on/off
virtio-net-pci.command_serr_enable=on/off
+scsi-generic.drive=drive
+scsi-generic.logical_block_size=uint16
+scsi-generic.physical_block_size=uint16
+scsi-generic.min_io_size=uint16
+scsi-generic.opt_io_size=uint32
+scsi-generic.bootindex=int32


I might be wrong, but what I got is bootindex showed up since
qemu 1.2.


I checked again. Compile from qemu v1.0 
(1c8a881daaca6fe0646a425b0970fb3ad25f6732). It is there.

Could you check it again?

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


Re: [libvirt] [PATCH v2 01/10] conf: Introduce readonly to hostdev and change helper function

2013-04-05 Thread Han Cheng

On 04/02/2013 10:15 AM, Hu Tao wrote:

On Mon, Apr 01, 2013 at 08:00:53PM +0800, Han Cheng wrote:

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index edddf25..f8e3973 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -439,6 +439,8 @@ struct _virDomainHostdevDef {
  } source;
  virDomainHostdevOrigStates origstates;
  virDomainDeviceInfoPtr info; /* Guest address */
+/* readonly is only used for scsi hostdev */
+unsigned int readonly;


bool readonly;


  };

  /* Two types of disk backends */


How about:
struct _virDomainHostdevDef {
...
unsigned int managed : 1;
unsigned int missing : 1;
unsigned int readonly : 1; /* readonly is only used for scsi hostdev */
...
};

Cheng

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


Re: [libvirt] [PATCH] qemu: Remove maximum cpu limit when setting processor count using the API

2013-04-05 Thread Peter Krempa

On 04/05/13 10:37, Daniel P. Berrange wrote:

On Fri, Apr 05, 2013 at 12:11:31AM +0200, Peter Krempa wrote:

When setting processor count for a domain using the API libvirt enforced
a maximum processor count, while it isn't enforced when taking the XML path.

This patch removes the check to match the API.


Do you mean  s/API/XML/ here ?


Indeed.



I'm not sure whether removing this check is a good idea. Should we not
instead make the guest startup code also validate max CPU count when
generating the CLI args ?


Well, I don't think so. Adding the check to the CLI generator would 
introduce more problems than it would solve:


1) chicken and egg problem: we can't use the new QMP query-cpu-max 
command as we need a running qemu for this and in order to start a qemu 
you already need to provide the desired number of cpus:


$ qemu-system-x86_64 -smp 256 -M pc -S --monitor stdio
Unsupported number of maxcpus
$ qemu-system-x86_64 -smp 255 -M pc -S --monitor stdio
QEMU 1.4.50 monitor - type 'help' for more information
(qemu) info cpu_max
Maximum number of CPUs is 255
(qemu) quit
$

2) qemuGetMaxVCPUs() is obsolete and doesn't report apropriate numbers.
For non-kvm guests this would limit us to 16 cpus per guest and for kvm 
guests it depends if the kernel supports the KVM_CAP_MAX_VCPUS ioctl 
(introduced in linux-3.2) and reports a correct value or we return the 
recommended value of processors (KVM_CAP_NR_VCPUS ioctl) that is 
hardcoded to 160. If neither of the ioctls is supported, 4 will be 
returned as the maximum count (according to kernel docs).


qemuGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED, const char *type) {
if (!type)
return 16;

if (STRCASEEQ(type, qemu))
return 16;

if (STRCASEEQ(type, kvm))
return kvmGetMaxVCPUs();

if (STRCASEEQ(type, kqemu))
return 1;

...


I don't see a way how we could reliably determine the maximum for a 
guest before we start it and it doesn't make sense to start it to find 
out. I think we should just remove the check and let qemu handle the limit.


Peter

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


Re: [libvirt] [PATCH] qemu: Remove maximum cpu limit when setting processor count using the API

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 11:13:17AM +0200, Peter Krempa wrote:
 On 04/05/13 10:37, Daniel P. Berrange wrote:
 On Fri, Apr 05, 2013 at 12:11:31AM +0200, Peter Krempa wrote:
 When setting processor count for a domain using the API libvirt enforced
 a maximum processor count, while it isn't enforced when taking the XML path.
 
 This patch removes the check to match the API.
 
 Do you mean  s/API/XML/ here ?
 
 Indeed.
 
 
 I'm not sure whether removing this check is a good idea. Should we not
 instead make the guest startup code also validate max CPU count when
 generating the CLI args ?
 
 Well, I don't think so. Adding the check to the CLI generator would
 introduce more problems than it would solve:
 
 1) chicken and egg problem: we can't use the new QMP query-cpu-max
 command as we need a running qemu for this and in order to start a
 qemu you already need to provide the desired number of cpus:
 
 $ qemu-system-x86_64 -smp 256 -M pc -S --monitor stdio
 Unsupported number of maxcpus
 $ qemu-system-x86_64 -smp 255 -M pc -S --monitor stdio
 QEMU 1.4.50 monitor - type 'help' for more information
 (qemu) info cpu_max
 Maximum number of CPUs is 255
 (qemu) quit
 $
 
 2) qemuGetMaxVCPUs() is obsolete and doesn't report apropriate numbers.
 For non-kvm guests this would limit us to 16 cpus per guest and for
 kvm guests it depends if the kernel supports the KVM_CAP_MAX_VCPUS
 ioctl (introduced in linux-3.2) and reports a correct value or we
 return the recommended value of processors (KVM_CAP_NR_VCPUS ioctl)
 that is hardcoded to 160. If neither of the ioctls is supported, 4
 will be returned as the maximum count (according to kernel docs).
 
 qemuGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED, const char *type) {
 if (!type)
 return 16;
 
 if (STRCASEEQ(type, qemu))
 return 16;
 
 if (STRCASEEQ(type, kvm))
 return kvmGetMaxVCPUs();
 
 if (STRCASEEQ(type, kqemu))
 return 1;
 
 ...
 
 
 I don't see a way how we could reliably determine the maximum for a
 guest before we start it and it doesn't make sense to start it to
 find out. I think we should just remove the check and let qemu
 handle the limit.

Ok, that makes sense now.


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

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


Re: [libvirt] [PATCH v2 03/10] conf: Introduce scsi hostdev

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 01:00:00PM +0800, Han Cheng wrote:
 On 04/02/2013 11:19 AM, Hu Tao wrote:
 On Mon, Apr 01, 2013 at 08:00:55PM +0800, Han Cheng wrote:
 diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
 index a776058..2fb5989 100644
 --- a/src/conf/domain_audit.c
 +++ b/src/conf/domain_audit.c
 @@ -398,6 +398,16 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
 virDomainHostdevDefPtr hostdev,
   goto cleanup;
   }
   break;
 +case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
 +if (virAsprintf(address, %s:%d:%d:%d,
 +hostdev-source.subsys.u.scsi.adapter,
 +hostdev-source.subsys.u.scsi.bus,
 +hostdev-source.subsys.u.scsi.target,
 +hostdev-source.subsys.u.scsi.unit)  0) {
 +VIR_WARN(OOM while encoding audit message);
 
 virReportOOMError();
 
 I'm not sure this is good.
 Other functions in this file use VIR_WARN to report OOM. If we
 change this place, we should change all others for consistence.
 Besides, Michal Privoznik is try to drop almost all virReportOOMError.

Yep, you are correctin what youoriginally had. The domain_audit.c
file is special in that it does *not* use virReport*Error, only
VIR_WARN, becasue we don't want to treat audit log failure as fatal
to guest startup.

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] maint: update to latest gnulib

2013-04-05 Thread Daniel P. Berrange
On Thu, Apr 04, 2013 at 08:33:16PM -0600, Eric Blake wrote:
 On 04/01/2013 12:55 PM, Eric Blake wrote:
  While this update doesn't address any reported problems in libvirt,
  doing a post-release update to latest gnulib makes it easier to
  stay in sync with best upstream practices.
  
  * .gnulib: Update to latest.
  * bootstrap: Resynchronize.
  ---
 
 Ping.

ACK, I thought we'd previously agreed that you'd just push
gnulib updates without needing ACKs, as long as we're not in
freeze :-)

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 v5.1 04/11] qemu: Record the default NIC model in the domain XML

2013-04-05 Thread Peter Krempa

On 04/05/13 09:37, Viktor Mihajlovski wrote:

On 04/04/2013 09:50 PM, Peter Krempa wrote:


I don't know if the realtek card works on the s390 qemu too, but if it
doesn't I don't mind changing it to virtio. In case it does work, we
need to consider if we aren't regressing here.



commit 539d73d intercepts this global defaulting but relies on the model
being NULL. So your patch is indeed causing a regression. We can fix
this before the next release though. No need for a V5.1.1 ;-)



That's the place I overlooked! :D okay, I will go with your fix in the 
connection callback and then we can get rid of the workarounds and have 
the management centralised.


Peter

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


[libvirt] [PATCH 2/3] qemu: Clean up network device CLI generator

2013-04-05 Thread Peter Krempa
With the default model assigned in the parse callback, this code is now 
obsolete.
---
 src/qemu/qemu_command.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 493e5f8..8a76fba 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3664,27 +3664,22 @@ qemuBuildNicDevStr(virDomainNetDefPtr net,
virQEMUCapsPtr qemuCaps)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
-const char *nic;
+const char *nic = net-model;
 bool usingVirtio = false;
 char macaddr[VIR_MAC_STRING_BUFLEN];

-if (!net-model) {
-nic = rtl8139;
-} else if (STREQ(net-model, virtio)) {
-if (net-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW) {
+if (STREQ(net-model, virtio)) {
+if (net-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW)
 nic = virtio-net-ccw;
-} else if (net-info.type ==
-   VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) {
+else if (net-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390)
 nic = virtio-net-s390;
-} else  {
+else
 nic = virtio-net-pci;
-}
+
 usingVirtio = true;
-} else {
-nic = net-model;
 }

-virBufferAdd(buf, nic, strlen(nic));
+virBufferAdd(buf, nic, -1);
 if (usingVirtio  net-driver.virtio.txmode) {
 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_TX_ALG)) {
 virBufferAddLit(buf, ,tx=);
-- 
1.8.1.5

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


[libvirt] [PATCH 3/3] qemu: Remove now obsolete assignment of default netwokr card model for s390 hosts

2013-04-05 Thread Peter Krempa
This effectively reverts commit 539d73dbf64cb35558ffd3992f82e0b482cd0e70 as the
changes aren't needed after introduction of the XML post parse callbacks.
---
 src/qemu/qemu_command.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8a76fba..dd3e5ca 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -919,11 +919,6 @@ qemuDomainPrimeS390VirtioDevices(virDomainDefPtr def,
 }

 for (i = 0; i  def-nnets ; i++) {
-if ((def-os.arch == VIR_ARCH_S390 ||
- def-os.arch == VIR_ARCH_S390X) 
-def-nets[i]-model == NULL) {
-def-nets[i]-model = strdup(virtio);
-}
 if (STREQ(def-nets[i]-model,virtio) 
 def-nets[i]-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
 def-nets[i]-info.type = type;
-- 
1.8.1.5

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


[libvirt] [PATCH 1/3] qemu: Use correct default model on s390

2013-04-05 Thread Peter Krempa
From: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com

Commit a68d6726679323823ee5be47f0144e9ccffa0757 breaks networking on s390 as it
changes the default network card model.
---
I assigned the authorship to Viktor as I just took his suggested patch from the
mail thread regarding the close callback.

 src/qemu/qemu_domain.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f431aec..9dedd4a 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -678,7 +678,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,

 static int
 qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDefPtr def,
  virCapsPtr caps ATTRIBUTE_UNUSED,
  void *opaque)
 {
@@ -688,9 +688,15 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,

 if (dev-type == VIR_DOMAIN_DEVICE_NET 
 dev-data.net-type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+const char *model = NULL;
+if (def-os.arch == VIR_ARCH_S390 ||
+def-os.arch == VIR_ARCH_S390X)
+model = virtio;
+else
+model = rtl8139;
 if (!dev-data.net-model 
-!(dev-data.net-model = strdup(rtl8139)))
-goto no_memory;
+!(dev-data.net-model = strdup(model)))
+goto no_memory;
 }

 /* set default disk types and drivers */
-- 
1.8.1.5

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


[libvirt] [PATCH 0/3] Un-break s390 default network model and clean up obsolete

2013-04-05 Thread Peter Krempa
This series fixes the default network model for s390 that was broken by the
recent addition of post parse close callbacks and cleans up code obsoleted by
that addition.

Peter Krempa (2):
  qemu: Clean up network device CLI generator
  qemu: Remove now obsolete assignment of default netwokr card model for
s390 hosts

Viktor Mihajlovski (1):
  qemu: Use correct default model on s390

 src/qemu/qemu_command.c | 24 +++-
 src/qemu/qemu_domain.c  | 12 +---
 2 files changed, 16 insertions(+), 20 deletions(-)

-- 
1.8.1.5

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


Re: [libvirt] [PATCH 1/3] qemu: Use correct default model on s390

2013-04-05 Thread Viktor Mihajlovski

On 04/05/2013 12:12 PM, Peter Krempa wrote:

@@ -688,9 +688,15 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,

  if (dev-type == VIR_DOMAIN_DEVICE_NET 
  dev-data.net-type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+const char *model = NULL;

Now that I see what I wrote: the NULL assignment above is useless.
I assume you will need a third pair of eyes?

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

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

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


Re: [libvirt] [sandbox PATCH 01/15] virt-sandbox-service-util needs to free allocated memory.

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:19PM -0400, Dan Walsh wrote:
 Coverity found that we could be leaking memory with virt-sandbox-service-util 
 -e
 ---
  bin/virt-sandbox-service-util.c | 9 +++--
  1 file changed, 7 insertions(+), 2 deletions(-)
 
 diff --git a/bin/virt-sandbox-service-util.c b/bin/virt-sandbox-service-util.c
 index 4d164d8..a292fcd 100644
 --- a/bin/virt-sandbox-service-util.c
 +++ b/bin/virt-sandbox-service-util.c
 @@ -194,8 +194,9 @@ static int set_process_label(pid_t pid) {
  static int container_execute( GVirSandboxContext *ctx, const gchar *command, 
 pid_t pid ) {
  
  int ret = EXIT_FAILURE;
 -char **argv;
 -int argc;
 +char **argv = NULL;
 +int argc=-1;
 +int i;
  
  if (set_process_label(pid)  0)
  goto cleanup;
 @@ -227,6 +228,10 @@ static int container_execute( GVirSandboxContext *ctx, 
 const gchar *command, pid
  }
  
  cleanup:
 +for (i = argc; i = 0; i--)

Can you use the more normal  (i = 0 ; i  argc ; i++)

 +free(argv[i]);

Identation is off here

 +free(argv);
 +
  return ret;
  }

ACK if those two things are fixed before pushing.

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] [sandbox PATCH 02/15] Add support for InteractiveContainers to virt-sandbox-service-util

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:20PM -0400, Dan Walsh wrote:
 We need to add support for interactive sandbox/containers for OpenShift.
 
 This patch will create the correct container type based off the 
 /etc/libvirt-sandbox/service/*
 ---
  bin/virt-sandbox-service-util.c | 31 +++
  1 file changed, 19 insertions(+), 12 deletions(-)
 @@ -452,16 +450,25 @@ int main(int argc, char **argv) {
  goto cleanup;
  }
  
 -cfg = GVIR_SANDBOX_CONFIG_SERVICE(config);
 +if (GVIR_SANDBOX_IS_CONFIG_INTERACTIVE(config)) {
 +GVirSandboxContextInteractive *service;
 +if (!(service = gvir_sandbox_context_interactive_new(hv, 
 GVIR_SANDBOX_CONFIG_INTERACTIVE(config {
 +g_printerr(_(Unable to create new context service: %s\n),
 +   err  err-message ? err-message : 
 _(unknown));
 +goto cleanup;

Again your identation here is not right - 4 space indent is the norm,

 +}
 +ctx = GVIR_SANDBOX_CONTEXT(service);
 +} else {
 +GVirSandboxContextService *service;
  
 -if (!(service = gvir_sandbox_context_service_new(hv, cfg))) {
 -g_printerr(_(Unable to create new context service: %s\n),
 -   err  err-message ? err-message : _(unknown));
 -goto cleanup;
 +if (!(service = gvir_sandbox_context_service_new(hv, 
 GVIR_SANDBOX_CONFIG_SERVICE(config {
 +g_printerr(_(Unable to create new context service: %s\n),
 +   err  err-message ? err-message : 
 _(unknown));
 +goto cleanup;

And here


ACK if identation is fixed before pushing


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/3] qemu: Clean up network device CLI generator

2013-04-05 Thread Viktor Mihajlovski

On 04/05/2013 12:12 PM, Peter Krempa wrote:

With the default model assigned in the parse callback, this code is now 
obsolete.
---
  src/qemu/qemu_command.c | 19 +++
  1 file changed, 7 insertions(+), 12 deletions(-)


[Unauthoritative] ACK.

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

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

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


Re: [libvirt] [sandbox PATCH 05/15] Change virt-sandbox-service-create.pod to use correct command --copy

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:23PM -0400, Dan Walsh wrote:
 Current the documentation says that you use --clone while the code uses --copy
 when you are createing a sandbox service container.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service-create.pod | 6 +++---
  1 file changed, 3 insertions(+), 3 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] [sandbox PATCH 03/15] Move virt-sandbox-service bash completion script to default directory.

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:21PM -0400, Dan Walsh wrote:
 bash_completion scripts have added a new way to do completions, where you
 place you scripts in /usr/share/bash_completion/completions rather then
 /etc/bash_completions.d.
 
 We should follow the new standard, and this patch moves our bash_completion
 script to the proper location with the proper name.
 ---
  bin/Makefile.am | 7 +--
  1 file changed, 5 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] [sandbox PATCH 07/15] Remove distinction from Internal vs External Functions.

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:25PM -0400, Dan Walsh wrote:
 This patch removes all __METHOD and _METHOD functions calls.  Since it is not
 intended that virt-sandbox-service will be imported into another python 
 module,
 there is limited value to using the internal indicators.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 118 
 +++
  1 file changed, 59 insertions(+), 59 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 3/3] qemu: Remove now obsolete assignment of default netwokr card model for s390 hosts

2013-04-05 Thread Viktor Mihajlovski

On 04/05/2013 12:12 PM, Peter Krempa wrote:

This effectively reverts commit 539d73dbf64cb35558ffd3992f82e0b482cd0e70 as the
changes aren't needed after introduction of the XML post parse callbacks.
---
  src/qemu/qemu_command.c | 5 -
  1 file changed, 5 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8a76fba..dd3e5ca 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -919,11 +919,6 @@ qemuDomainPrimeS390VirtioDevices(virDomainDefPtr def,
  }

  for (i = 0; i  def-nnets ; i++) {
-if ((def-os.arch == VIR_ARCH_S390 ||
- def-os.arch == VIR_ARCH_S390X) 
-def-nets[i]-model == NULL) {
-def-nets[i]-model = strdup(virtio);
-}
  if (STREQ(def-nets[i]-model,virtio) 
  def-nets[i]-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
  def-nets[i]-info.type = type;


[Unauthoritative] ACK

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

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

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


Re: [libvirt] [sandbox PATCH 08/15] Make CONFIG_PATH external to the Container Class

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:26PM -0400, Dan Walsh wrote:
 This patch moves CONFIG_PATH external from the Container Class.  This will
 eliminate the need to create a container to get this constant.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 13 +
  1 file changed, 9 insertions(+), 4 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] [sandbox PATCH 09/15] Add exception handler GlibGerror to virt-sandbox-service

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:27PM -0400, Dan Walsh wrote:
 GlibGerror can be raised by virt-sandbox-service, this patch will catch
 the exception and write the error to stderr.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 4 
  1 file changed, 4 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] [sandbox PATCH 10/15] Change variable config to config_path to avoid confusion.

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:28PM -0400, Dan Walsh wrote:
 save_config uses an internal variable to indicate the path to the virt-sandbox
 configuration file, this path renames this variable to prevent confusion.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 12 ++--
  1 file changed, 6 insertions(+), 6 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] [sandbox PATCH 11/15] Refactor Container class into Container and ServiceContainer Class.

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:29PM -0400, Dan Walsh wrote:
 This way we can share common methods between the ServiceContainer and the
 InteractiveContainer (Patch to be added)
 ---
  bin/virt-sandbox-service | 754 
 ---
  1 file changed, 385 insertions(+), 369 deletions(-)

  container.set_copy(args.copy)
 -if args.network:
 -for net in args.network:
 -container.add_network(net)
 +for net in args.network:
 +container.add_network(net)

Hmm, I had the  'if args.network' because this would raise
an error about 'args.network' not existing, if no --network
args were provided on the command line. Are you sure this
still works when no  --network args are used ?


ACK if this issue is not a problem anymore, or if this chunk is
reverted.

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] [sandbox PATCH 12/15] Add support for InteractiveContainer

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:30PM -0400, Dan Walsh wrote:
 First use case will be OpenShift
 
 Differentiate on create based on whether one or more unit files specified
 (ServiceContainer), or a command is specified (Interactive Container).
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service| 165 
 
  bin/virt-sandbox-service-bash-completion.sh |  16 +--
  bin/virt-sandbox-service-create.pod |  15 ++-
  3 files changed, 136 insertions(+), 60 deletions(-)

 +parser.add_argument(-n, --network, dest=network,
 +action=SetNet, default=[],
 +help=_(Specify the network configuration))


 -parser.add_argument(-N, --network, dest=network,
 -action=SetNet,
 -help=_(Specify the network configuration))
 -
 -image = parser.add_argument_group(Create On Disk Image File)

You're still changing -N into -n here.


ACK if you remove that change before pushing.

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] [sandbox PATCH 13/15] Use args.uri rather then hard coding lxc:///

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:31PM -0400, Dan Walsh wrote:
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
 index 8571374..8c9ea76 100755
 --- a/bin/virt-sandbox-service
 +++ b/bin/virt-sandbox-service
 @@ -928,7 +928,7 @@ def fullpath(cmd):
  return cmd
  
  def execute(args):
 -myexec = [ virsh, -c, lxc:///, lxc-enter-namespace ]
 +myexec = [ virsh, -c, args.uri, lxc-enter-namespace ]
  #myexec = [ virt-sandbox-service-util, execute ]
  if args.noseclabel:
  myexec.append(--noseclabel)

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] [sandbox PATCH 14/15] Check for LXC if virt-sandbox-service execute command specified

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:32PM -0400, Dan Walsh wrote:
 virt-sandbox-service execute is not supported on qemu sandboxes.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 5 -
  1 file changed, 4 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] [sandbox PATCH 15/15] Create new /etc/rc.d directory to bind mount over system.

2013-04-05 Thread Daniel P. Berrange
On Wed, Apr 03, 2013 at 07:17:33PM -0400, Dan Walsh wrote:
 We need to prevent SYSVInit scripts from running by default in the
 ServiceContainer.  The so we recreate all of the directories under /etc/rc.d
 and copy the functions file over.
 
 Signed-off-by: Dan Walsh dwa...@redhat.com
 ---
  bin/virt-sandbox-service | 10 +++---
  1 file changed, 7 insertions(+), 3 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 3/3] qemu: Remove now obsolete assignment of default netwokr card model for s390 hosts

2013-04-05 Thread Viktor Mihajlovski


Oops: typo in the subject line s/netwokr/network/

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

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

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


Re: [libvirt] [PATCH v2 01/10] conf: Introduce readonly to hostdev and change helper function

2013-04-05 Thread Paolo Bonzini
Il 03/04/2013 05:37, Osier Yang ha scritto:
 
 codereadonly/code
 ddIndicates the device is readonly, only valid for SCSI device.
 span class=sinceSince 1.0.5/span.
 /dd
 
 dtcodeboot/code/dt
 ddSpecifies that the device is bootable. The codeorder/code
 attribute determines the order in which devices will be tried
 during
 diff --git a/docs/schemas/domaincommon.rng
 b/docs/schemas/domaincommon.rng
 index 8d7e6db..ccf0913 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -2911,6 +2911,11 @@
   ref name=alias/
 /optional
 optional
 +element name='readonly'
 +  empty/
 +/element
 +  /optional
 +  optional
 
 Since the readonly is only valid for SCSI device. This patch should be
 either
 merged into 3/10, or rebased after it. It should be grouped in
 hostdevsubsysscsi,
 to make sure it's only valid for SCSI device when doing RNG validation.

Note that sgio=filtered/unfiltered/default can also be a valid
attribute.

Paolo

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


Re: [libvirt] [PATCH 1/2] Update structure XML definitions to support hostdev caps=net.

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 03:28:07AM -0400, Bogdan Purcareata wrote:
 This updates the definitions and supporting structures in the XML 
 schema and domain configuration files.
 
 Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
 ---
  docs/formatdomain.html.in | 15 +--
  docs/schemas/domaincommon.rng | 14 ++
  src/conf/domain_conf.c| 28 +++-
  src/conf/domain_conf.h|  4 
  4 files changed, 58 insertions(+), 3 deletions(-)

 @@ -422,6 +423,9 @@ struct _virDomainHostdevCaps {
  struct {
  char *chardev;
  } misc;
 +struct {
 +char *interface;
 +} net;

You'll need to  s/interface/iface/ since 'interface' clashes with
a symbol in the public header files on Win32 platforms :-(

Looks good apart from that.

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] Implement support for hostdev caps=net

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 03:28:08AM -0400, Bogdan Purcareata wrote:
 This allows a container-type domain to have exclusive access to one of
 the host's NICs.
 
 Wire hostdev caps=net with the lxc_controller - when moving the newly
 created veth devices into a new namespace, also look for any hostdev
 devices that should be moved. Note: once the container domain has been
 destroyed, there is no code that moves the interfaces back to the 
 original namespace. This does happen, though, probably due to default
 cleanup on namespace destruction.
 
 Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
 ---
  src/lxc/lxc_container.c  |  4 +++-
  src/lxc/lxc_controller.c | 19 +++
  src/lxc/lxc_hostdev.c|  1 +
  3 files changed, 23 insertions(+), 1 deletion(-)
 
 diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
 index 002ba9e..e59bfdf 100644
 --- a/src/lxc/lxc_container.c
 +++ b/src/lxc/lxc_container.c
 @@ -1551,7 +1551,6 @@ cleanup:
  return ret;
  }
  
 -
  static int lxcContainerSetupHostdevSubsys(virDomainDefPtr vmDef,
virDomainHostdevDefPtr def,
const char *dstprefix,
 @@ -1582,6 +1581,9 @@ static int lxcContainerSetupHostdevCaps(virDomainDefPtr 
 vmDef,
  case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
  return lxcContainerSetupHostdevCapsMisc(vmDef, def, dstprefix, 
 securityDriver);
  
 +case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
 +return 0; // case is handled in virLXCControllerMoveInterfaces
 +
  default:
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 _(Unsupported host device mode %s),
 diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
 index cede445..ab488d8 100644
 --- a/src/lxc/lxc_controller.c
 +++ b/src/lxc/lxc_controller.c
 @@ -1050,12 +1050,31 @@ cleanup2:
  static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
  {
  size_t i;
 +virDomainDefPtr def = ctrl-def;
  
  for (i = 0 ; i  ctrl-nveths ; i++) {
  if (virNetDevSetNamespace(ctrl-veths[i], ctrl-initpid)  0)
  return -1;
  }
  
 +for (i = 0; i  def-nhostdevs; i ++) {
 + virDomainHostdevDefPtr hdev = def-hostdevs[i];
 +
 + if (hdev-mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES) {
 +continue;
 +}

No need for {} for a body which is only 1 statement.

 +
 +virDomainHostdevCaps hdcaps = hdev-source.caps;
 +
 + if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET) {
 +   continue;
 +}

No need for {}

 +
 +if (virNetDevSetNamespace(hdcaps.u.net.interface, ctrl-initpid)  
 0) {
 +return -1;
 + }

No need for {}

You've got some tab characters in here which is making the
indentation go funny. Run 'make syntax-check' and it'll
tell you where any problems are.

Functionally it all looks fine.

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] LXC: rework mounting cgroupfs in container

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 10:16:43AM +0800, Gao feng wrote:
 On 2013/03/27 13:26, Gao feng wrote:
  On 2013/03/20 16:14, Gao feng wrote:
  There are 3 reason we need to rework the cgroupfs
  mounting in container.
 
  1, Yin Olivia reported a failed to mount cgroup
 problem, now we given that the name of cgroup mount point
 is same with the subsystem type, Or libvirt_lxc
 will fail to start.
 
  2, The cgroup configuration is leaked to the container,
 even user can change host's cgroup configuration in
 container.
 
  3, After we enable userns, the cgroupfs is unable to be
 mounted in uninit-userns.
 
  This patch tries to resolve these 3 problem,
  uses mount --bind to set cgroupfs for container.
 
  It means the directory /sys/fs/cgroup/memory/libvirt/lxc/domain
  of host will be binded to the directory /sys/fs/cgroup/memory of
  container.
 
  
  what's your idea about this patch?
  
 
 Ping Again

The pach has the right idea, but it clashes with the refactoring I've
done for cgroups and LXC. I'll update your patch to apply ontop of this
series:

  https://www.redhat.com/archives/libvir-list/2013-April/msg00352.html

and copy you on the mail when i post it.

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

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


Re: [libvirt] [PATCH 1/3] qemu: Use correct default model on s390

2013-04-05 Thread Peter Krempa

On 04/05/13 13:02, Viktor Mihajlovski wrote:

On 04/05/2013 12:12 PM, Peter Krempa wrote:

@@ -688,9 +688,15 @@
qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,

  if (dev-type == VIR_DOMAIN_DEVICE_NET 
  dev-data.net-type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
+const char *model = NULL;

Now that I see what I wrote: the NULL assignment above is useless.
I assume you will need a third pair of eyes?



Oh, indeed :). My morning coffee hasn't kicked in at that time. We can 
even drop the model variable and duplicate the strdups to avoid the 
intermediate variable. V2 commencing.


Peter

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


[libvirt] [PATCH v2 2/2] Implement support for hostdev caps=net

2013-04-05 Thread Bogdan Purcareata
This allows a container-type domain to have exclusive access to one of
the host's NICs.

Wire hostdev caps=net with the lxc_controller - when moving the newly
created veth devices into a new namespace, also look for any hostdev
devices that should be moved. Note: once the container domain has been
destroyed, there is no code that moves the interfaces back to the
original namespace. This does happen, though, probably due to default
cleanup on namespace destruction.

Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
---
 src/lxc/lxc_container.c  |  4 +++-
 src/lxc/lxc_controller.c | 16 
 src/lxc/lxc_hostdev.c|  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 002ba9e..e59bfdf 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1551,7 +1551,6 @@ cleanup:
 return ret;
 }
 
-
 static int lxcContainerSetupHostdevSubsys(virDomainDefPtr vmDef,
   virDomainHostdevDefPtr def,
   const char *dstprefix,
@@ -1582,6 +1581,9 @@ static int lxcContainerSetupHostdevCaps(virDomainDefPtr 
vmDef,
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 return lxcContainerSetupHostdevCapsMisc(vmDef, def, dstprefix, 
securityDriver);
 
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+return 0; // case is handled in virLXCControllerMoveInterfaces
+
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Unsupported host device mode %s),
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index cede445..edd99bf 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1050,12 +1050,28 @@ cleanup2:
 static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
 {
 size_t i;
+virDomainDefPtr def = ctrl-def;
 
 for (i = 0 ; i  ctrl-nveths ; i++) {
 if (virNetDevSetNamespace(ctrl-veths[i], ctrl-initpid)  0)
 return -1;
 }
 
+for (i = 0; i  def-nhostdevs; i ++) {
+virDomainHostdevDefPtr hdev = def-hostdevs[i];
+
+if (hdev-mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES)
+continue;
+
+virDomainHostdevCaps hdcaps = hdev-source.caps;
+
+if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
+   continue;
+
+if (virNetDevSetNamespace(hdcaps.u.net.iface, ctrl-initpid)  0)
+return -1;
+}
+
 return 0;
 }
 
diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c
index 33b0b60..53a1a31 100644
--- a/src/lxc/lxc_hostdev.c
+++ b/src/lxc/lxc_hostdev.c
@@ -307,6 +307,7 @@ int virLXCPrepareHostDevices(virLXCDriverPtr driver,
 switch (dev-source.subsys.type) {
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE:
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
 break;
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
1.7.11.7


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


[libvirt] [PATCH v2 0/2] libvirt_lxc: implement hostdev caps=net device isolation in containers

2013-04-05 Thread Bogdan Purcareata
This set of patches implements hostdev caps=net interface isolation in
containers, thus allowing an interface NIC to be assigned exclusively to
a container-domain. This is done like moving veth devices in container
namespaces, only this time it is actual host devices.


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


[libvirt] [PATCH v2 2/2] Implement support for hostdev caps=net

2013-04-05 Thread Bogdan Purcareata
This allows a container-type domain to have exclusive access to one of
the host's NICs.

Wire hostdev caps=net with the lxc_controller - when moving the newly
created veth devices into a new namespace, also look for any hostdev
devices that should be moved. Note: once the container domain has been
destroyed, there is no code that moves the interfaces back to the
original namespace. This does happen, though, probably due to default
cleanup on namespace destruction.

Signed-off-by: Bogdan Purcareata bogdan.purcare...@freescale.com
---
 src/lxc/lxc_container.c  |  4 +++-
 src/lxc/lxc_controller.c | 16 
 src/lxc/lxc_hostdev.c|  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 002ba9e..e59bfdf 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1551,7 +1551,6 @@ cleanup:
 return ret;
 }
 
-
 static int lxcContainerSetupHostdevSubsys(virDomainDefPtr vmDef,
   virDomainHostdevDefPtr def,
   const char *dstprefix,
@@ -1582,6 +1581,9 @@ static int lxcContainerSetupHostdevCaps(virDomainDefPtr 
vmDef,
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
 return lxcContainerSetupHostdevCapsMisc(vmDef, def, dstprefix, 
securityDriver);
 
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
+return 0; // case is handled in virLXCControllerMoveInterfaces
+
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(Unsupported host device mode %s),
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index cede445..edd99bf 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1050,12 +1050,28 @@ cleanup2:
 static int virLXCControllerMoveInterfaces(virLXCControllerPtr ctrl)
 {
 size_t i;
+virDomainDefPtr def = ctrl-def;
 
 for (i = 0 ; i  ctrl-nveths ; i++) {
 if (virNetDevSetNamespace(ctrl-veths[i], ctrl-initpid)  0)
 return -1;
 }
 
+for (i = 0; i  def-nhostdevs; i ++) {
+virDomainHostdevDefPtr hdev = def-hostdevs[i];
+
+if (hdev-mode != VIR_DOMAIN_HOSTDEV_MODE_CAPABILITIES)
+continue;
+
+virDomainHostdevCaps hdcaps = hdev-source.caps;
+
+if (hdcaps.type != VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET)
+   continue;
+
+if (virNetDevSetNamespace(hdcaps.u.net.iface, ctrl-initpid)  0)
+return -1;
+}
+
 return 0;
 }
 
diff --git a/src/lxc/lxc_hostdev.c b/src/lxc/lxc_hostdev.c
index 33b0b60..53a1a31 100644
--- a/src/lxc/lxc_hostdev.c
+++ b/src/lxc/lxc_hostdev.c
@@ -307,6 +307,7 @@ int virLXCPrepareHostDevices(virLXCDriverPtr driver,
 switch (dev-source.subsys.type) {
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_STORAGE:
 case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_MISC:
+case VIR_DOMAIN_HOSTDEV_CAPS_TYPE_NET:
 break;
 default:
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
1.7.11.7


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


Re: [libvirt] [PATCH 0/7] Fix multiple compiler warnings on ARMv7

2013-04-05 Thread Michal Privoznik
On 03.04.2013 17:06, Daniel P. Berrange wrote:
 The ARMv7 builds of libvirt generate a number of warnings, mostly
 about cast alignment
 
 http://arm.koji.fedoraproject.org/packages/libvirt/1.0.4/1.fc19/data/logs/armv7hl/build.log
 
 this patch series fixes as many as possible, and then disables warnings
 for the rest using a pragma
 
 

ACK series - passes my compile test on my ARMv6 based machine. I've
prepared something similar a while ago but never get to send it actually.

Michal

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


[libvirt] [PATCHv2] qemu: Use correct default model on s390

2013-04-05 Thread Peter Krempa
From: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com

Commit a68d6726679323823ee5be47f0144e9ccffa0757 breaks networking on s390 as it
changes the default network card model.
---
 src/qemu/qemu_domain.c | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index f431aec..6ed2b40 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -678,7 +678,7 @@ qemuDomainDefPostParse(virDomainDefPtr def,

 static int
 qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
- virDomainDefPtr def ATTRIBUTE_UNUSED,
+ virDomainDefPtr def,
  virCapsPtr caps ATTRIBUTE_UNUSED,
  void *opaque)
 {
@@ -687,10 +687,16 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
 virQEMUDriverConfigPtr cfg = NULL;

 if (dev-type == VIR_DOMAIN_DEVICE_NET 
-dev-data.net-type != VIR_DOMAIN_NET_TYPE_HOSTDEV) {
-if (!dev-data.net-model 
-!(dev-data.net-model = strdup(rtl8139)))
-goto no_memory;
+dev-data.net-type != VIR_DOMAIN_NET_TYPE_HOSTDEV 
+!dev-data.net-model) {
+if (def-os.arch == VIR_ARCH_S390 ||
+def-os.arch == VIR_ARCH_S390X)
+dev-data.net-model = strdup(virtio);
+else
+dev-data.net-model = strdup(rtl8139);
+
+if (!dev-data.net-model)
+goto no_memory;
 }

 /* set default disk types and drivers */
-- 
1.8.1.5

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


Re: [libvirt] [PATCH 1/7] Rewrite keycode map to avoid a struct

2013-04-05 Thread Michal Privoznik
On 03.04.2013 17:06, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 Playing games with field offsets in a struct causes all sorts
 of alignment warnings on ARM platforms
 
 util/virkeycode.c: In function '__virKeycodeValueFromString':
 util/virkeycode.c:26:7: warning: cast increases required alignment of target 
 type [-Wcast-align]
  (*(typeof(field_type) *)((char *)(object) + field_offset))
^
 util/virkeycode.c:91:28: note: in expansion of macro 'getfield'
  const char *name = getfield(virKeycodes + i, const char *, 
 name_offset);
 ^
 util/virkeycode.c:26:7: warning: cast increases required alignment of target 
 type [-Wcast-align]
  (*(typeof(field_type) *)((char *)(object) + field_offset))
^
 util/virkeycode.c:94:20: note: in expansion of macro 'getfield'
  return getfield(virKeycodes + i, unsigned short, code_offset);
 ^
 util/virkeycode.c: In function '__virKeycodeValueTranslate':
 util/virkeycode.c:26:7: warning: cast increases required alignment of target 
 type [-Wcast-align]
  (*(typeof(field_type) *)((char *)(object) + field_offset))
^
 util/virkeycode.c:127:13: note: in expansion of macro 'getfield'
  if (getfield(virKeycodes + i, unsigned short, from_offset) == 
 key_value)
  ^
 util/virkeycode.c:26:7: warning: cast increases required alignment of target 
 type [-Wcast-align]
  (*(typeof(field_type) *)((char *)(object) + field_offset))
^
 util/virkeycode.c:128:20: note: in expansion of macro 'getfield'
  return getfield(virKeycodes + i, unsigned short, to_offset);
 
 There is no compelling reason to use a struct for the keycode
 tables. It can easily just use an array of arrays instead,
 avoiding all alignment problems
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/util/virkeycode-mapgen.py |  78 ++---
  src/util/virkeycode.c | 130 
 ++
  2 files changed, 110 insertions(+), 98 deletions(-)
 
 diff --git a/src/util/virkeycode-mapgen.py b/src/util/virkeycode-mapgen.py
 index d3d2aae..34de637 100755
 --- a/src/util/virkeycode-mapgen.py
 +++ b/src/util/virkeycode-mapgen.py
 @@ -13,7 +13,22 @@ instead of keymaps.csv which is a mirror.
  import sys
  import re
  
 -namecolums = (0,2,10)
 +cols = (
 +[linux, True],
 +[linux, False],
 +[os_x, True],
 +[os_x, False],
 +[atset1, False],
 +[atset2, False],
 +[atset3, False],
 +[xt, False],
 +[xt_kbd, False],
 +[usb, False],
 +[win32, True],
 +[win32, False],
 +[rfb, False],
 +)
 +
  xtkbdkey_index = 8
  
  def quotestring(str):
 @@ -28,29 +43,48 @@ print '''
  # error do not use this; it is not a public header
  #endif
  
 -struct keycode virKeycodes[] = {
  '''
  
  sys.stdin.readline() # eat the fist line.
  
 +keycodes = []
 +
 +max = 0
 +
  for line in sys.stdin.xreadlines():
 -a = re.match(([^,]*), * 13 + ([^,]*)$, line[0:-1]).groups()
 -b = 
 -rfbkey = 0
 -for i in namecolums:
 -b = b + (a[i] and quotestring(a[i]) or 'NULL') + ','
 -for i in [ x for x in range(12) if not x in namecolums ]:
 -b = b + (a[i] or '0') + ','
 -if i == xtkbdkey_index:
 -# RFB keycodes are XT kbd keycodes with a slightly
 -# different encoding of 0xe0 scan codes. RFB uses
 -# the high bit of the first byte, instead of the low
 -# bit of the second byte.
 -rfbkey = int(a[i] or '0')
 -rfbkey = (rfbkey  0x100)  1 | (rfbkey  0x7f)
 -
 -# Append RFB keycode as the last column
 -b = b + str(rfbkey)
 -print {  + b + },
 -
 -print '};'
 +values = re.match(([^,]*), * 13 + ([^,]*)$, line[0:-1]).groups()
 +
 +data = []
 +for v in values:
 +data.append(v)
 +
 +# RFB keycodes are XT kbd keycodes with a slightly
 +# different encoding of 0xe0 scan codes. RFB uses
 +# the high bit of the first byte, instead of the low
 +# bit of the second byte.
 +rfbkey = int(data[xtkbdkey_index] or '0')
 +rfbkey = (rfbkey  0x100)  1 | (rfbkey  0x7f)
 +data.append(rfbkey)
 +
 +keycodes.append(data)
 +max = max + 1
 +
 +print #define VIR_KEYMAP_ENTRY_MAX  + str(max)
 +
 +for i in range(len(cols)):
 +col=cols[i]
 +name=col[0]
 +isname=col[1]
 +if isname:
 +print const char *virKeymapNames_ + name + [] = {
 +else:
 +print unsigned short virKeymapValues_ + name + [] = {
 +
 +for entry in keycodes:
 +if isname:
 +print+ quotestring(entry[i] or NULL) + ,
 +else:
 +print+ (entry[i] or 0) + ,
 +
 +print };\n
 +

Empty line at EOF.

Michal

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


Re: [libvirt] [PATCH 6/7] Disable of unused sysinfotest functions

2013-04-05 Thread Michal Privoznik
On 03.04.2013 17:06, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 Certain functions in the sysinfotest.c are not used unless
 a whitelisted architecture is being built. Disable those
 functions unless required to avoid warnings about unused
 functions.
 
 sysinfotest.c:93:1: warning: 'sysinfotest_run' defined but not used 
 [-Wunused-function]
  sysinfotest_run(const char *test,
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  tests/sysinfotest.c | 5 +
  1 file changed, 5 insertions(+)
 
 diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c
 index aee57e6..94493a3 100644
 --- a/tests/sysinfotest.c
 +++ b/tests/sysinfotest.c
 @@ -38,6 +38,10 @@
  
  #if defined (__linux__)
  
 +# if defined(__s390__) || defined(__s390x__) || \
 + defined(__powerpc__) || defined(__powerpc64__) || \
 + defined(__i386__) || defined(__x86_64__) || defined(__amd64__)
 +
  /* from sysinfo.c */
  void virSysinfoSetup(const char *decoder,
   const char *sysinfo,
 @@ -122,6 +126,7 @@ error:
  VIR_FREE(testdata.expected);
  return ret;
  }
 +# endif
  
  # if defined(__s390__) || defined(__s390x__)
  static int
 

Seems like you (accidentally?) pushed this one already.

Michal

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


Re: [libvirt] [PATCH 3/5] virstring: Introduce virVasprintfNOOM and make virVasprintf report OOM

2013-04-05 Thread Michal Privoznik
On 05.04.2013 12:45, Daniel P. Berrange wrote:
 On Tue, Apr 02, 2013 at 04:22:56PM +0200, Michal Privoznik wrote:
 ---
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_domain.c   |  4 +---
  src/util/viraudit.c  |  2 +-
  src/util/vircommand.c|  4 ++--
  src/util/virerror.c  |  2 +-
  src/util/virlog.c|  2 +-
  src/util/virstring.c | 22 --
  src/util/virstring.h |  3 +++
  8 files changed, 30 insertions(+), 10 deletions(-)
 
 This patch is incomplete, missing a number of places which don't report
 errors on enomem. There are probably others that this simple grep does
 not detect too.
 
 
 [berrange@avocado libvirt]$ git grep --after 1 virAsprintf  | grep --before 1 
 ENOMEM
 src/util/vircgroup.c:if (virAsprintf(strval, %llu, value) == -1)
 src/util/vircgroup.c-return -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(strval, %lld, value) == -1)
 src/util/vircgroup.c-return -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(path, %s/%s, grppath, 
 ent-d_name) == -1) {
 src/util/vircgroup.c-rc = -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(path, %s/%s, rootgrp-path, name) 
  0) {
 src/util/vircgroup.c-rc = -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(path, %s/%s, driver-path, name) 
  0)
 src/util/vircgroup.c-return -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(path, %s/vcpu%d, driver-path, 
 vcpuid)  0)
 src/util/vircgroup.c-return -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(path, %s/emulator, driver-path) 
  0)
 src/util/vircgroup.c-return -ENOMEM;
 --
 src/util/vircgroup.c:if (virAsprintf(subpath, %s/%s, group-path, 
 ent-d_name)  0) {
 src/util/vircgroup.c-rc = -ENOMEM;
 --
 src/util/virdnsmasq.c:if (virAsprintf(tmp, %s.new, path)  0)
 src/util/virdnsmasq.c-return -ENOMEM;
 --
 src/util/virdnsmasq.c:if (virAsprintf(tmp, %s.new, path)  0)
 src/util/virdnsmasq.c-return -ENOMEM;
 --
 src/util/virpidfile.c:if (virAsprintf(procPath, /proc/%lld/exe, (long 
 long)retPid)  0) {
 src/util/virpidfile.c-ret = -ENOMEM;
 [berrange@avocado libvirt]$ git grep --after 1 ALLOC  | grep --before 1 ENOMEM
 src/libvirt.c:if (VIR_ALLOC(lock)  0)
 src/libvirt.c-return ENOMEM;
 --
 src/node_device/node_device_hal.c:if (VIR_ALLOC(caps)  0)
 src/node_device/node_device_hal.c-return ENOMEM;
 --
 src/util/viralloc.c:if (VIR_ALLOC_VAR_OVERSIZED(struct_size, count, 
 element_size)) {
 src/util/viralloc.c-errno = ENOMEM;
 --
 src/util/vircgroup.c:if (VIR_ALLOC((*group)) != 0) {
 src/util/vircgroup.c-rc = -ENOMEM;
 --
 src/util/vircommand.c:if (VIR_REALLOC_N(*set, *set_size + 1)  0) {
 src/util/vircommand.c-return ENOMEM;
 --
 src/util/virthreadpthread.c:if (VIR_ALLOC(args)  0) {
 src/util/virthreadpthread.c-err = ENOMEM;
 
 
 
 Daniel
 


Yep, but it makes no harm if we report OOM error (write into logs) in
those cases. Those few cases I am overwriting in my patch are notably
python binding were we do not want to report OOM error anyway, and
virerror.c or virlog.c where reporting could mean infinite recursion.

The others are only those I found by chance. However, thank you for
finding yet another ones - I will look at them in my new round.

Michal

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


Re: [libvirt] [PATCH] qemu: Remove maximum cpu limit when setting processor count using the API

2013-04-05 Thread Peter Krempa

On 04/05/13 11:21, Daniel P. Berrange wrote:

On Fri, Apr 05, 2013 at 11:13:17AM +0200, Peter Krempa wrote:

On 04/05/13 10:37, Daniel P. Berrange wrote:

On Fri, Apr 05, 2013 at 12:11:31AM +0200, Peter Krempa wrote:

When setting processor count for a domain using the API libvirt enforced
a maximum processor count, while it isn't enforced when taking the XML path.

This patch removes the check to match the API.


Do you mean  s/API/XML/ here ?


Indeed.





I've fixed the commit message and ...



...


I don't see a way how we could reliably determine the maximum for a
guest before we start it and it doesn't make sense to start it to
find out. I think we should just remove the check and let qemu
handle the limit.


Ok, that makes sense now.



... pushed the patch now. If we decide that we still want to check the 
user supplied values we will need to do better than the code this patch 
removes.


Thanks.

Peter

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


Re: [libvirt] [PATCHv2] qemu: Use correct default model on s390

2013-04-05 Thread Viktor Mihajlovski

On 04/05/2013 03:16 PM, Peter Krempa wrote:

From: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com

Commit a68d6726679323823ee5be47f0144e9ccffa0757 breaks networking on s390 as it
changes the default network card model.
---
  src/qemu/qemu_domain.c | 16 +++-
  1 file changed, 11 insertions(+), 5 deletions(-)


+1

--

Mit freundlichen Grüßen/Kind Regards
   Viktor Mihajlovski

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

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


[libvirt] [PATCH v4 00/11] Add support for guests with TPM passthrough device

2013-04-05 Thread Stefan Berger
Hello!

The following set of patches adds support to libvirt for 
adding a TPM passthrough device to a QEMU guest. Support for
this was recently accepted into QEMU.

This set of patches borrows a lot from the recently added support
for rng's.


Regards,
Stefan

---
v3-v4:
  - followed tree to ce65b435
  - followed comments on v3

v2-v3:
  - followed tree to 03122d7b
  - some nits I found fixed

v1-v2:
  - Followed Daniel Berrange's comments
(except for the one on de-consolidating the JSON monitor code)

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


[libvirt] [PATCH v4 06/11] Convert QMP strings into QEMU capability bits

2013-04-05 Thread Stefan Berger
Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 src/qemu/qemu_capabilities.c |   56 +++
 1 file changed, 56 insertions(+)

Index: libvirt/src/qemu/qemu_capabilities.c
===
--- libvirt.orig/src/qemu/qemu_capabilities.c
+++ libvirt/src/qemu/qemu_capabilities.c
@@ -38,6 +38,7 @@
 #include virbitmap.h
 #include virnodesuspend.h
 #include qemu_monitor.h
+#include virstring.h
 
 #include fcntl.h
 #include sys/stat.h
@@ -2115,6 +2116,59 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEM
 
 
 static int
+virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
+   qemuMonitorPtr mon)
+{
+int nentries, i;
+char **entries = NULL;
+struct typeToCaps {
+int type;
+enum virQEMUCapsFlags caps;
+};
+const struct typeToCaps tpmTypesToCaps[] = {
+{
+.type = VIR_DOMAIN_TPM_TYPE_PASSTHROUGH,
+.caps = QEMU_CAPS_DEVICE_TPM_PASSTHROUGH,
+},
+};
+const struct typeToCaps tpmModelsToCaps[] = {
+{
+.type = VIR_DOMAIN_TPM_MODEL_TIS,
+.caps = QEMU_CAPS_DEVICE_TPM_TIS,
+},
+};
+
+if ((nentries = qemuMonitorGetTPMModels(mon, entries))  0)
+return -1;
+
+if (nentries  0) {
+for (i = 0; i  ARRAY_CARDINALITY(tpmModelsToCaps); i++) {
+const char *needle = virDomainTPMModelTypeToString(
+tpmModelsToCaps[i].type);
+if (virStringArrayHasString(entries, needle))
+virQEMUCapsSet(qemuCaps, tpmModelsToCaps[i].caps);
+}
+}
+virStringFreeList(entries);
+
+if ((nentries = qemuMonitorGetTPMTypes(mon, entries))  0)
+return -1;
+
+if (nentries  0) {
+for (i = 0; i  ARRAY_CARDINALITY(tpmTypesToCaps); i++) {
+const char *needle = virDomainTPMBackendTypeToString(
+tpmTypesToCaps[i].type);
+if (virStringArrayHasString(entries, needle))
+virQEMUCapsSet(qemuCaps, tpmTypesToCaps[i].caps);
+}
+}
+virStringFreeList(entries);
+
+return 0;
+}
+
+
+static int
 virQEMUCapsProbeQMPKVMState(virQEMUCapsPtr qemuCaps,
 qemuMonitorPtr mon)
 {
@@ -2467,6 +2521,8 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCa
 goto cleanup;
 if (virQEMUCapsProbeQMPKVMState(qemuCaps, mon)  0)
 goto cleanup;
+if (virQEMUCapsProbeQMPTPM(qemuCaps, mon)  0)
+goto cleanup;
 
 ret = 0;
 

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


[libvirt] [PATCH v4 08/11] Audit the starting of a guest using TPM passthrough

2013-04-05 Thread Stefan Berger
When a VM with a TPM passthrough device is started, the audit daemon
logs the following type of message:

type=VIRT_RESOURCE msg=audit(1365170222.460:3378): pid=16382 uid=0 
auid=4294967295 ses=4294967295 subj=system_u:system_r:virtd_t:s0-s0:c0.c1023 
msg='virt=kvm resrc=dev reason=start vm=TPM-PT 
uuid=a4d7cd22-da89-3094-6212-079a48a309a1 device=/dev/tpm0 
exe=/usr/sbin/libvirtd hostname=? addr=? terminal=? res=success'

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 src/conf/domain_audit.c |   55 
 1 file changed, 55 insertions(+)

Index: libvirt/src/conf/domain_audit.c
===
--- libvirt.orig/src/conf/domain_audit.c
+++ libvirt/src/conf/domain_audit.c
@@ -524,6 +524,58 @@ cleanup:
 
 
 /**
+ * virDomainAuditTPM:
+ * @vm: domain making a change in pass-through host device
+ * @tpm: TPM device being attached or removed
+ * @reason: one of start, attach, or detach
+ * @success: true if the device passthrough operation succeeded
+ *
+ * Log an audit message about an attempted device passthrough change.
+ */
+static void
+virDomainAuditTPM(virDomainObjPtr vm, virDomainTPMDefPtr tpm,
+  const char *reason, bool success)
+{
+char uuidstr[VIR_UUID_STRING_BUFLEN];
+char *vmname;
+char *path = NULL;
+char *device = NULL;
+const char *virt;
+
+virUUIDFormat(vm-def-uuid, uuidstr);
+if (!(vmname = virAuditEncode(vm, vm-def-name))) {
+VIR_WARN(OOM while encoding audit message);
+return;
+}
+
+if (!(virt = virDomainVirtTypeToString(vm-def-virtType))) {
+VIR_WARN(Unexpected virt type %d while encoding audit message, 
vm-def-virtType);
+virt = ?;
+}
+
+switch (tpm-type) {
+case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+path = tpm-data.passthrough.source.data.file.path;
+if (!(device = virAuditEncode(device, VIR_AUDIT_STR(path {
+VIR_WARN(OOM while encoding audit message);
+goto cleanup;
+}
+
+VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success,
+  virt=%s resrc=dev reason=%s %s uuid=%s %s,
+  virt, reason, vmname, uuidstr, device);
+break;
+default:
+break;
+}
+
+cleanup:
+VIR_FREE(vmname);
+VIR_FREE(device);
+}
+
+
+/**
  * virDomainAuditCgroup:
  * @vm: domain making the cgroups ACL change
  * @cgroup: cgroup that manages the devices
@@ -761,6 +813,9 @@ virDomainAuditStart(virDomainObjPtr vm,
 if (vm-def-rng)
 virDomainAuditRNG(vm, vm-def-rng, NULL, start, true);
 
+if (vm-def-tpm)
+virDomainAuditTPM(vm, vm-def-tpm, start, true);
+
 virDomainAuditMemory(vm, 0, vm-def-mem.cur_balloon, start, true);
 virDomainAuditVcpu(vm, 0, vm-def-vcpus, start, true);
 

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


[libvirt] [PATCH v4 04/11] Helper functions for host TPM support

2013-04-05 Thread Stefan Berger
Implement helper functions to find the TPM's sysfs cancel file.

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 po/POTFILES.in   |1 
 src/Makefile.am  |1 
 src/libvirt_private.syms |4 +
 src/util/virtpm.c|  111 +++
 src/util/virtpm.h|   27 +++
 5 files changed, 144 insertions(+)

Index: libvirt/src/Makefile.am
===
--- libvirt.orig/src/Makefile.am
+++ libvirt/src/Makefile.am
@@ -122,6 +122,7 @@ UTIL_SOURCES =  
\
util/virthreadwin32.h   \
util/virthreadpool.c util/virthreadpool.h   \
util/virtime.h util/virtime.c   \
+   util/virtpm.h util/virtpm.c \
util/virtypedparam.c util/virtypedparam.h   \
util/virusb.c util/virusb.h \
util/viruri.h util/viruri.c \
Index: libvirt/src/util/virtpm.c
===
--- /dev/null
+++ libvirt/src/util/virtpm.c
@@ -0,0 +1,111 @@
+/*
+ * virtpm.c: TPM support
+ *
+ * Copyright (C) 2013 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ * Author: Stefan Berger stef...@linux.vnet.ibm.com
+ */
+
+#include config.h
+
+#include stdio.h
+#include dirent.h
+#include unistd.h
+#include sys/stat.h
+
+#include virobject.h
+#include viralloc.h
+#include virutil.h
+#include virerror.h
+#include virbuffer.h
+#include virtpm.h
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+/*
+ * Check whether the given base path, e.g.,  /sys/class/misc/tpm0/device,
+ * is the sysfs entry of a TPM. A TPM sysfs entry should be uniquely
+ * recognizable by the file entries 'pcrs' and 'cancel'.
+ * Upon success the basepath with '/cancel' appended is returned, NULL
+ * otherwise.
+ */
+static char *
+virTPMCheckSysfsCancel(char *basepath)
+{
+char *path = NULL;
+struct stat statbuf;
+
+if (virAsprintf(path, %s/pcrs, basepath)  0) {
+virReportOOMError();
+goto cleanup;
+}
+if (stat(path, statbuf) == -1 || !S_ISREG(statbuf.st_mode))
+goto cleanup;
+
+VIR_FREE(path);
+
+if (virAsprintf(path, %s/cancel, basepath)  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+if (stat(path, statbuf) == -1 || !S_ISREG(statbuf.st_mode))
+goto cleanup;
+
+return path;
+
+cleanup:
+VIR_FREE(path);
+return NULL;
+}
+
+
+char *
+virTPMFindCancelPath(void)
+{
+unsigned int idx;
+int len;
+DIR *pnp_dir;
+char *path = NULL, *basepath = NULL;
+struct dirent entry, *result;
+
+pnp_dir = opendir(/sys/class/misc);
+if (pnp_dir != NULL) {
+while (readdir_r(pnp_dir, entry, result) == 0 
+   result != NULL) {
+if (sscanf(entry.d_name, tpm%u%n, idx, len)  1 ||
+len = strlen(tpm) ||
+len != strlen(entry.d_name)) {
+continue;
+}
+if (virAsprintf(basepath, /sys/class/misc/%s/device,
+entry.d_name)  0) {
+virReportOOMError();
+break;
+}
+if ((path = virTPMCheckSysfsCancel(basepath)))
+break;
+
+VIR_FREE(basepath);
+}
+closedir(pnp_dir);
+}
+
+VIR_FREE(basepath);
+
+return path;
+}
Index: libvirt/src/libvirt_private.syms
===
--- libvirt.orig/src/libvirt_private.syms
+++ libvirt/src/libvirt_private.syms
@@ -1778,6 +1778,10 @@ virTimeStringThen;
 virTimeStringThenRaw;
 
 
+# util/virtpm.h
+virTPMFindCancelPath;
+
+
 # util/virtypedparam.h
 virTypedParameterArrayValidate;
 virTypedParameterAssign;
Index: libvirt/src/util/virtpm.h
===
--- /dev/null
+++ libvirt/src/util/virtpm.h
@@ -0,0 +1,27 @@
+/*
+ * virtpm.h: TPM support
+ *
+ * Copyright (C) 2013 IBM Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * 

[libvirt] [PATCH v4 11/11] Add test case for TPM passthrough

2013-04-05 Thread Stefan Berger
Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args |6 +++
 tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.xml  |   29 +++
 tests/qemuxml2argvtest.c |3 +
 tests/qemuxml2xmltest.c  |2 +
 4 files changed, 40 insertions(+)

Index: libvirt/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args
===
--- /dev/null
+++ libvirt/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.args
@@ -0,0 +1,6 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
+/usr/bin/qemu -S -M pc-0.12 -m 2048 -smp 1 -nographic -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -boot c -usb \
+-tpmdev 
passthrough,id=tpm-tpm0,path=/dev/tpm0,cancel-path=/sys/class/misc/tpm0/device/cancel
 \
+-device tpm-tis,tpmdev=tpm-tpm0,id=tpm0 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
Index: libvirt/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.xml
===
--- /dev/null
+++ libvirt/tests/qemuxml2argvdata/qemuxml2argv-tpm-passthrough.xml
@@ -0,0 +1,29 @@
+domain type='qemu'
+  nameTPM-VM/name
+  uuid11d7cd22-da89-3094-6212-079a48a309a1/uuid
+  memory unit='KiB'2097152/memory
+  currentMemory unit='KiB'512288/currentMemory
+  vcpu placement='static'1/vcpu
+  os
+type arch='x86_64' machine='pc-0.12'hvm/type
+boot dev='hd'/
+bootmenu enable='yes'/
+  /os
+  features
+acpi/
+  /features
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/qemu/emulator
+controller type='usb' index='0'/
+tpm model='tpm-tis'
+  backend type='passthrough'
+device path='/dev/tpm0'/
+  /backend
+/tpm
+memballoon model='virtio'/
+  /devices
+/domain
Index: libvirt/tests/qemuxml2argvtest.c
===
--- libvirt.orig/tests/qemuxml2argvtest.c
+++ libvirt/tests/qemuxml2argvtest.c
@@ -932,6 +932,9 @@ mymain(void)
 
 DO_TEST(ppc-dtb, QEMU_CAPS_KVM, QEMU_CAPS_DTB);
 
+DO_TEST(tpm-passthrough, QEMU_CAPS_DEVICE,
+QEMU_CAPS_DEVICE_TPM_PASSTHROUGH, QEMU_CAPS_DEVICE_TPM_TIS);
+
 virObjectUnref(driver.config);
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
Index: libvirt/tests/qemuxml2xmltest.c
===
--- libvirt.orig/tests/qemuxml2xmltest.c
+++ libvirt/tests/qemuxml2xmltest.c
@@ -272,6 +272,8 @@ mymain(void)
 
 DO_TEST_DIFFERENT(metadata);
 
+DO_TEST(tpm-passthrough);
+
 virObjectUnref(driver.caps);
 virObjectUnref(driver.xmlopt);
 

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


[libvirt] [PATCH v4 01/11] Add QMP probing for TPM

2013-04-05 Thread Stefan Berger
Probe for QEMU's QMP TPM support by querying the lists of
supported TPM models (query-tpm-models) and backend types
(query-tpm-types). 

The setting of the capability flags following the strings
returned from the commands above is only provided in the
patch where domain_conf.c gets TPM support due to dependencies
on functions only introduced there. 

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 src/qemu/qemu_capabilities.c |2 
 src/qemu/qemu_capabilities.h |3 +
 src/qemu/qemu_monitor.c  |   44 +
 src/qemu/qemu_monitor.h  |6 ++
 src/qemu/qemu_monitor_json.c |   90 +++
 src/qemu/qemu_monitor_json.h |8 +++
 6 files changed, 153 insertions(+)

Index: libvirt/src/qemu/qemu_capabilities.c
===
--- libvirt.orig/src/qemu/qemu_capabilities.c
+++ libvirt/src/qemu/qemu_capabilities.c
@@ -216,6 +216,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAS
 
   ipv6-migration, /* 135 */
   machine-opt,
+  tpm-passthrough,
+  tpm-tis,
 );
 
 struct _virQEMUCaps {
Index: libvirt/src/qemu/qemu_capabilities.h
===
--- libvirt.orig/src/qemu/qemu_capabilities.h
+++ libvirt/src/qemu/qemu_capabilities.h
@@ -176,6 +176,8 @@ enum virQEMUCapsFlags {
 QEMU_CAPS_SCSI_MEGASAS   = 134, /* -device megasas */
 QEMU_CAPS_IPV6_MIGRATION = 135, /* -incoming [::] */
 QEMU_CAPS_MACHINE_OPT= 136, /* -machine */
+QEMU_CAPS_DEVICE_TPM_PASSTHROUGH = 137, /* -tpmdev passthrough */
+QEMU_CAPS_DEVICE_TPM_TIS = 138, /* -device tpm_tis */
 
 QEMU_CAPS_LAST,   /* this must always be the last item */
 };
@@ -257,4 +259,5 @@ int virQEMUCapsParseDeviceStr(virQEMUCap
 VIR_ENUM_DECL(virQEMUCaps);
 
 bool virQEMUCapsUsedQMP(virQEMUCapsPtr qemuCaps);
+
 #endif /* __QEMU_CAPABILITIES_H__*/
Index: libvirt/src/qemu/qemu_monitor.c
===
--- libvirt.orig/src/qemu/qemu_monitor.c
+++ libvirt/src/qemu/qemu_monitor.c
@@ -3525,3 +3525,47 @@ int qemuMonitorNBDServerStop(qemuMonitor
 
 return qemuMonitorJSONNBDServerStop(mon);
 }
+
+
+int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
+char ***tpmmodels)
+{
+VIR_DEBUG(mon=%p tpmmodels=%p,
+  mon, tpmmodels);
+
+if (!mon) {
+virReportError(VIR_ERR_INVALID_ARG, %s,
+   _(monitor must not be NULL));
+return -1;
+}
+
+if (!mon-json) {
+virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
+   _(JSON monitor is required));
+return -1;
+}
+
+return qemuMonitorJSONGetTPMModels(mon, tpmmodels);
+}
+
+
+int qemuMonitorGetTPMTypes(qemuMonitorPtr mon,
+   char ***tpmtypes)
+{
+VIR_DEBUG(mon=%p tpmtypes=%p,
+  mon, tpmtypes);
+
+if (!mon) {
+virReportError(VIR_ERR_INVALID_ARG, %s,
+   _(monitor must not be NULL));
+return -1;
+}
+
+if (!mon-json) {
+virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
+   _(JSON monitor is required));
+return -1;
+}
+
+return qemuMonitorJSONGetTPMTypes(mon, tpmtypes);
+}
Index: libvirt/src/qemu/qemu_monitor.h
===
--- libvirt.orig/src/qemu/qemu_monitor.h
+++ libvirt/src/qemu/qemu_monitor.h
@@ -683,6 +683,12 @@ int qemuMonitorNBDServerAdd(qemuMonitorP
 const char *deviceID,
 bool writable);
 int qemuMonitorNBDServerStop(qemuMonitorPtr);
+int qemuMonitorGetTPMModels(qemuMonitorPtr mon,
+char ***tpmmodels);
+
+int qemuMonitorGetTPMTypes(qemuMonitorPtr mon,
+   char ***tpmtypes);
+
 /**
  * When running two dd process and using  redirection, we need a
  * shell that will not truncate files.  These two strings serve that
Index: libvirt/src/qemu/qemu_monitor_json.c
===
--- libvirt.orig/src/qemu/qemu_monitor_json.c
+++ libvirt/src/qemu/qemu_monitor_json.c
@@ -41,6 +41,7 @@
 #include datatypes.h
 #include virerror.h
 #include virjson.h
+#include virstring.h
 
 #ifdef WITH_DTRACE_PROBES
 # include libvirt_qemu_probes.h
@@ -4693,3 +4694,92 @@ qemuMonitorJSONNBDServerStop(qemuMonitor
 virJSONValueFree(reply);
 return ret;
 }
+
+
+static int
+qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char *qmpCmd,
+  char ***array)
+{
+int ret;
+virJSONValuePtr cmd;
+virJSONValuePtr reply = NULL;
+virJSONValuePtr data;
+char **list = NULL;
+int n = 0;
+size_t i;
+
+

[libvirt] [PATCH v4 05/11] Parse TPM passthrough XML in the domain XML

2013-04-05 Thread Stefan Berger
Parse the domain XML with TPM passthrough support.
The TPM passthrough XML may look like this:

tpm model='tpm-tis'
  backend type='passthrough'
device path='/dev/tpm0'/
  /backend
/tpm


Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 src/conf/domain_conf.c   |  179 +++
 src/conf/domain_conf.h   |   33 
 src/libvirt_private.syms |5 +
 3 files changed, 217 insertions(+)

Index: libvirt/src/conf/domain_conf.c
===
--- libvirt.orig/src/conf/domain_conf.c
+++ libvirt/src/conf/domain_conf.c
@@ -51,6 +51,7 @@
 #include netdev_bandwidth_conf.h
 #include netdev_vlan_conf.h
 #include device_conf.h
+#include virtpm.h
 
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
@@ -719,6 +720,13 @@ VIR_ENUM_IMPL(virDomainRNGBackend,
   random,
   egd);
 
+VIR_ENUM_IMPL(virDomainTPMModel, VIR_DOMAIN_TPM_MODEL_LAST,
+  tpm-tis)
+
+VIR_ENUM_IMPL(virDomainTPMBackend, VIR_DOMAIN_TPM_TYPE_LAST,
+  passthrough)
+
+
 #define VIR_DOMAIN_XML_WRITE_FLAGS  VIR_DOMAIN_XML_SECURE
 #define VIR_DOMAIN_XML_READ_FLAGS   VIR_DOMAIN_XML_INACTIVE
 
@@ -1601,6 +1609,23 @@ void virDomainHostdevDefClear(virDomainH
 }
 }
 
+void virDomainTPMDefFree(virDomainTPMDefPtr def)
+{
+if (!def)
+return;
+
+switch (def-type) {
+case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+VIR_FREE(def-data.passthrough.source.data.file.path);
+break;
+case VIR_DOMAIN_TPM_TYPE_LAST:
+break;
+}
+
+virDomainDeviceInfoClear(def-info);
+VIR_FREE(def);
+}
+
 void virDomainHostdevDefFree(virDomainHostdevDefPtr def)
 {
 if (!def)
@@ -1862,6 +1887,8 @@ void virDomainDefFree(virDomainDefPtr de
 
 virDomainRNGDefFree(def-rng);
 
+virDomainTPMDefFree(def-tpm);
+
 VIR_FREE(def-os.type);
 VIR_FREE(def-os.machine);
 VIR_FREE(def-os.init);
@@ -6677,6 +6704,103 @@ error:
 goto cleanup;
 }
 
+/* Parse the XML definition for a TPM device
+ *
+ * The XML looks like this:
+ *
+ * tpm model='tpm-tis'
+ *   backend type='passthrough'
+ * device path='/dev/tpm0'/
+ *   /backend
+ * /tpm
+ *
+ */
+static virDomainTPMDefPtr
+virDomainTPMDefParseXML(const xmlNodePtr node,
+xmlXPathContextPtr ctxt,
+unsigned int flags)
+{
+char *type = NULL;
+char *path = NULL;
+char *model = NULL;
+char *backend = NULL;
+virDomainTPMDefPtr def;
+xmlNodePtr save = ctxt-node;
+xmlNodePtr *backends = NULL;
+int nbackends;
+
+if (VIR_ALLOC(def)  0) {
+virReportOOMError();
+return NULL;
+}
+
+model = virXMLPropString(node, model);
+if (model != NULL 
+(int)(def-model = virDomainTPMModelTypeFromString(model))  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(Unknown TPM frontend model '%s'), model);
+goto error;
+} else {
+def-model = VIR_DOMAIN_TPM_MODEL_TIS;
+}
+
+ctxt-node = node;
+
+if ((nbackends = virXPathNodeSet(./backend, ctxt, backends))  0)
+goto error;
+
+if (nbackends  1) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(only one TPM backend is supported));
+goto error;
+}
+
+if (!(backend = virXMLPropString(backends[0], type))) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(missing TPM device backend type));
+goto error;
+}
+
+if ((int)(def-type = virDomainTPMBackendTypeFromString(backend))  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(Unknown TPM backend type '%s'),
+   backend);
+goto error;
+}
+
+switch (def-type) {
+case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+path = virXPathString(string(./backend/device/@path), ctxt);
+if (!path  !(path = strdup(VIR_DOMAIN_TPM_DEFAULT_DEVICE))) {
+virReportOOMError();
+goto error;
+}
+def-data.passthrough.source.data.file.path = path;
+def-data.passthrough.source.type = VIR_DOMAIN_CHR_TYPE_DEV;
+path = NULL;
+break;
+case VIR_DOMAIN_TPM_TYPE_LAST:
+goto error;
+}
+
+if (virDomainDeviceInfoParseXML(node, NULL, def-info, flags)  0)
+goto error;
+
+cleanup:
+VIR_FREE(type);
+VIR_FREE(path);
+VIR_FREE(model);
+VIR_FREE(backend);
+VIR_FREE(backends);
+ctxt-node = save;
+return def;
+
+error:
+virDomainTPMDefFree(def);
+def = NULL;
+goto cleanup;
+}
+
 /* Parse the XML definition for an input device */
 static virDomainInputDefPtr
 virDomainInputDefParseXML(const char *ostype,
@@ -10998,6 +11122,23 @@ virDomainDefParseXML(xmlDocPtr xml,
 goto error;
 VIR_FREE(nodes);
 }
+VIR_FREE(nodes);
+
+   

[libvirt] [PATCH v4 10/11] TPM support for QEMU command line

2013-04-05 Thread Stefan Berger
For TPM passthrough device support create command line parameters like:

-tpmdev 
passthrough,id=tpm-tpm0,path=/dev/tpm0,cancel-path=/sys/class/misc/tpm0/device/cancel
 -device tpm-tis,tpmdev=tpm-tpm0,id=tpm0

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

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

Index: libvirt/src/qemu/qemu_command.c
===
--- libvirt.orig/src/qemu/qemu_command.c
+++ libvirt/src/qemu/qemu_command.c
@@ -46,6 +46,7 @@
 #include base64.h
 #include device_conf.h
 #include virstoragefile.h
+#include virtpm.h
 
 #include sys/stat.h
 #include fcntl.h
@@ -799,6 +800,10 @@ qemuAssignDeviceAliases(virDomainDefPtr
 if (virAsprintf(def-rng-info.alias, rng%d, 0)  0)
 goto no_memory;
 }
+if (def-tpm) {
+if (virAsprintf(def-tpm-info.alias, tpm%d, 0)  0)
+goto no_memory;
+}
 
 return 0;
 
@@ -4791,6 +4796,92 @@ cleanup:
 }
 
 
+static char *qemuBuildTPMBackendStr(const virDomainDefPtr def,
+virQEMUCapsPtr qemuCaps,
+const char *emulator)
+{
+const virDomainTPMDefPtr tpm = def-tpm;
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+const char *type = virDomainTPMBackendTypeToString(tpm-type);
+const char *cancel_path;
+
+virBufferAsprintf(buf, %s,id=tpm-%s, type, tpm-info.alias);
+
+switch (tpm-type) {
+case VIR_DOMAIN_TPM_TYPE_PASSTHROUGH:
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_PASSTHROUGH))
+goto no_support;
+
+virBufferAddLit(buf, ,path=);
+virBufferEscape(buf, ',', ,, %s,
+tpm-data.passthrough.source.data.file.path);
+
+if (!(cancel_path = virTPMFindCancelPath())) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+_(TPM cancel path could not be determined));
+ goto error;
+}
+
+virBufferAddLit(buf, ,cancel-path=);
+virBufferEscape(buf, ',', ,, %s, cancel_path);
+VIR_FREE(cancel_path);
+
+break;
+case VIR_DOMAIN_TPM_TYPE_LAST:
+goto error;
+}
+
+if (virBufferError(buf)) {
+virReportOOMError();
+goto error;
+}
+
+return virBufferContentAndReset(buf);
+
+ no_support:
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(The QEMU executable %s does not support TPM 
+ backend type %s),
+   emulator, type);
+
+ error:
+virBufferFreeAndReset(buf);
+return NULL;
+}
+
+
+static char *qemuBuildTPMDevStr(const virDomainDefPtr def,
+virQEMUCapsPtr qemuCaps,
+const char *emulator)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+const virDomainTPMDefPtr tpm = def-tpm;
+const char *model = virDomainTPMModelTypeToString(tpm-model);
+
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_TPM_TIS)) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(The QEMU executable %s does not support TPM 
+   model %s),
+   emulator, model);
+goto error;
+}
+
+virBufferAsprintf(buf, %s,tpmdev=tpm-%s,id=%s,
+  model, tpm-info.alias, tpm-info.alias);
+
+if (virBufferError(buf)) {
+virReportOOMError();
+goto error;
+}
+
+return virBufferContentAndReset(buf);
+
+ error:
+virBufferFreeAndReset(buf);
+return NULL;
+}
+
+
 static char *qemuBuildSmbiosBiosStr(virSysinfoDefPtr def)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -7101,6 +7192,22 @@ qemuBuildCommandLine(virConnectPtr conn,
 }
 }
 
+if (def-tpm) {
+char *optstr;
+
+if (!(optstr = qemuBuildTPMBackendStr(def, qemuCaps, emulator)))
+goto error;
+
+virCommandAddArgList(cmd, -tpmdev, optstr, NULL);
+VIR_FREE(optstr);
+
+if (!(optstr = qemuBuildTPMDevStr(def, qemuCaps, emulator)))
+goto error;
+
+virCommandAddArgList(cmd, -device, optstr, NULL);
+VIR_FREE(optstr);
+}
+
 for (i = 0 ; i  def-ninputs ; i++) {
 virDomainInputDefPtr input = def-inputs[i];
 
@@ -8934,6 +9041,112 @@ error:
 
 
 static int
+qemuParseCommandLineTPM(virDomainDefPtr dom,
+const char *val)
+{
+int rc = 0;
+virDomainTPMDefPtr tpm;
+char **keywords;
+char **values;
+int nkeywords;
+int i;
+
+if (dom-tpm)
+goto error;
+
+nkeywords = qemuParseKeywords(val, keywords, values, 1);
+if (nkeywords  0)
+goto error;
+
+if (VIR_ALLOC(tpm)  0)
+goto no_memory;
+
+tpm-model = VIR_DOMAIN_TPM_MODEL_TIS;
+
+for (i = 0; i  nkeywords; i++) {
+if 

[libvirt] [PATCH v4 02/11] Add function to find a needle in a string array

2013-04-05 Thread Stefan Berger
Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 src/libvirt_private.syms |1 +
 src/util/virstring.c |   14 ++
 src/util/virstring.h |2 ++
 3 files changed, 17 insertions(+)

Index: libvirt/src/util/virstring.c
===
--- libvirt.orig/src/util/virstring.c
+++ libvirt/src/util/virstring.c
@@ -166,3 +166,17 @@ void virStringFreeList(char **strings)
 }
 VIR_FREE(strings);
 }
+
+
+bool
+virStringArrayHasString(char **strings, const char *needle)
+{
+size_t i = 0;
+
+while (strings[i]) {
+if (STREQ(strings[i++], needle))
+return true;
+}
+
+return false;
+}
Index: libvirt/src/util/virstring.h
===
--- libvirt.orig/src/util/virstring.h
+++ libvirt/src/util/virstring.h
@@ -35,4 +35,6 @@ char *virStringJoin(const char **strings
 
 void virStringFreeList(char **strings);
 
+bool virStringArrayHasString(char **strings, const char *needle);
+
 #endif /* __VIR_STRING_H__ */
Index: libvirt/src/libvirt_private.syms
===
--- libvirt.orig/src/libvirt_private.syms
+++ libvirt/src/libvirt_private.syms
@@ -1720,6 +1720,7 @@ virStorageFileResize;
 
 
 # util/virstring.h
+virStringArrayHasString;
 virStringFreeList;
 virStringJoin;
 virStringSplit;

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


[libvirt] [PATCH v4 03/11] Add documentation and schema for TPM passthrough

2013-04-05 Thread Stefan Berger
Supported TPM passthrough XML may look as follows:

tpm model='tpm-tis'
  backend type='passthrough'
device path='/dev/tpm0'/
  /backend
/tpm

Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com
Reviewed-by: Corey Bryant cor...@linux.vnet.ibm.com
Tested-by: Corey Bryant cor...@linux.vnet.ibm.com

---
 docs/formatdomain.html.in |   58 ++
 docs/schemas/domaincommon.rng |   43 +++
 2 files changed, 101 insertions(+)

Index: libvirt/docs/formatdomain.html.in
===
--- libvirt.orig/docs/formatdomain.html.in
+++ libvirt/docs/formatdomain.html.in
@@ -4385,6 +4385,64 @@ qemu-kvm -net nic,model=? /dev/null
 
 /dl
 
+h4a name=elementsTpmTPM device/a/h4
+
+p
+  The TPM device enables a QEMU guest to have access to TPM
+  functionality.
+/p
+p
+  The TPM passthrough device type provides access to the host's TPM
+  for one QEMU guest. No other software may be is using the TPM device,
+  typically /dev/tpm0, at the time the QEMU guest is started.
+  span class=since'passthrough' since 1.0.5/span
+/p
+
+p
+ Example: usage of the TPM passthrough device
+/p
+pre
+  ...
+  lt;devicesgt;
+lt;tpm model='tpm-tis'gt;
+  lt;backend type='passthrough'gt;
+lt;backend path='/dev/tpm0'/gt;
+  lt;/backendgt;
+lt;/tpmgt;
+  lt;/devicesgt;
+  ...
+/pre
+dl
+  dtcodemodel/code/dt
+  dd
+p
+  The codemodel/code attribute specifies what device
+  model QEMU provides to the guest. If no model name is provided,
+  codetpm-tis/code will automatically be chosen.
+/p
+  /dd
+  dtcodebackend/code/dt
+  dd
+p
+  The codebackend/code element specifies the type of
+  TPM device. The following types are supported:
+/p
+ul
+  li'passthrough' mdash; use the host's TPM device.
+/ul
+  /dd
+  dtcodebackend type='passthrough'/code/dt
+  dd
+p
+  This backend type requires exclusive access to a TPM device on
+  the host.
+  An example for such a device is /dev/tpm0. The filename is
+  specified as path attribute of the codesource/code element.
+  If no file name is specified then /dev/tpm0 is automatically used.
+/p
+  /dd
+/dl
+
 h3a name=seclabelSecurity label/a/h3
 
 p
Index: libvirt/docs/schemas/domaincommon.rng
===
--- libvirt.orig/docs/schemas/domaincommon.rng
+++ libvirt/docs/schemas/domaincommon.rng
@@ -2847,6 +2847,48 @@
   text/
 /element
   /define
+
+  define name=tpm
+element name=tpm
+  optional
+attribute name=model
+  choice
+valuetpm-tis/value
+  /choice
+/attribute
+  /optional
+  ref name=tpm-backend/
+  optional
+ref name=alias/
+  /optional
+/element
+  /define
+
+  define name=tpm-backend
+element name=backend
+   choice
+ group
+   attribute name=type
+  valuepassthrough/value
+   /attribute
+   ref name=tpm-passthrough-device/
+ /group
+   /choice
+/element
+  /define
+
+  define name=tpm-passthrough-device
+optional
+  element name=device
+optional
+  attribute name=path
+ref name=filePath/
+  /attribute
+/optional
+  /element
+   /optional
+  /define
+
   define name=input
 element name=input
   attribute name=type
@@ -3157,6 +3199,7 @@
 ref name=redirdev/
 ref name=redirfilter/
 ref name=rng/
+ref name=tpm/
   /choice
 /zeroOrMore
 optional

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


Re: [libvirt] [PATCH 8/8] qemu: Support sgio setting for volume type disk

2013-04-05 Thread Osier Yang

On 05/04/13 03:38, Osier Yang wrote:

---
  src/qemu/qemu_process.c | 7 +--
  1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 3ac0c70..757f8b8 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3235,9 +3235,12 @@ qemuSetUnprivSGIO(virDomainDiskDefPtr disk)
  /* sgio is only valid for block disk; cdrom
   * and floopy disk can have empty source.
   */
-if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK ||
+if (!disk-src ||
  disk-device != VIR_DOMAIN_DISK_DEVICE_LUN ||
-!disk-src)
+(disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK 
+ !(disk-type == VIR_DOMAIN_DISK_TYPE_VOLUME 
+   disk-srcpool 
+   disk-srcpool-voltype == VIR_STORAGE_VOL_BLOCK)))
  return 0;
  
  sysfs_path = virGetUnprivSGIOSysfsPath(disk-src, NULL);


With the following missed diff squashed in:


diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index c7b8045..e67c960 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1014,9 +1014,18 @@ qemuCheckSharedDisk(virHashTablePtr sharedDisks,
  disk-sgio == VIR_DOMAIN_DISK_SGIO_UNFILTERED))
 goto cleanup;
 
-virReportError(VIR_ERR_OPERATION_INVALID,
-   _(sgio of shared disk '%s' conflicts with other 
- active domains), disk-src);
+if (disk-type == VIR_DOMAIN_DISK_TYPE_VOLUME) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   _(sgio of shared disk 'pool=%s' 'volume=%s' conflicts 
+ with other active domains),
+   disk-srcpool-pool,
+   disk-srcpool-volume);
+} else {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   _(sgio of shared disk '%s' conflicts with other 
+ active domains), disk-src);
+}
+
 ret = -1;
 
 cleanup:
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH v2 03/10] conf: Introduce scsi hostdev

2013-04-05 Thread Osier Yang

On 05/04/13 16:33, Daniel P. Berrange wrote:

On Fri, Apr 05, 2013 at 01:00:00PM +0800, Han Cheng wrote:

On 04/02/2013 11:19 AM, Hu Tao wrote:

On Mon, Apr 01, 2013 at 08:00:55PM +0800, Han Cheng wrote:

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index a776058..2fb5989 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -398,6 +398,16 @@ virDomainAuditHostdev(virDomainObjPtr vm, 
virDomainHostdevDefPtr hostdev,
  goto cleanup;
  }
  break;
+case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
+if (virAsprintf(address, %s:%d:%d:%d,
+hostdev-source.subsys.u.scsi.adapter,
+hostdev-source.subsys.u.scsi.bus,
+hostdev-source.subsys.u.scsi.target,
+hostdev-source.subsys.u.scsi.unit)  0) {
+VIR_WARN(OOM while encoding audit message);

virReportOOMError();

I'm not sure this is good.
Other functions in this file use VIR_WARN to report OOM. If we
change this place, we should change all others for consistence.
Besides, Michal Privoznik is try to drop almost all virReportOOMError.

Yep, you are correctin what youoriginally had. The domain_audit.c
file is special in that it does *not* use virReport*Error, only
VIR_WARN, becasue we don't want to treat audit log failure as fatal
to guest startup.

We need a comment in the file...

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


Re: [libvirt] [PATCH 1/7] New XML attributes for storage pool source adapter

2013-04-05 Thread John Ferlan
On 03/25/2013 12:43 PM, Osier Yang wrote:
 This introduces 4 new attributes for storage pool source adapter.
 E.g.
 
 adapter type='fc_host' parent='scsi_host5' wwnn='2000c9831b4b' 
 wwpn='1000c9831b4b'/
 
 Attribute 'type' can be either 'scsi_host' or 'fc_host', and defaults
 to 'scsi_host' if attribute 'name' is specified. I.e. It's optional
 for 'scsi_host' adapter, for back-compat reason. However, mandatory
 for 'fc_host' adapter and any new future adapter types. Attribute
 'parent' is to specify the parent for the fc_host adapter.
 
 * docs/formatstorage.html.in:
   - Add documents for the 4 new attrs
 * docs/schemas/storagepool.rng:
   - Add RNG schema
 * src/conf/storage_conf.c:
   - Parse and format the new XMLs
 * src/conf/storage_conf.h:
   - New struct virStoragePoolSourceAdapter, replace char *adapter with it;
   - New enum virStoragePoolSourceAdapterType
 * src/libvirt_private.syms:
   - Export TypeToString and TypeFromString
 * src/phyp/phyp_driver.c:
   - Replace adapter with adapter.data.name, which is member of the union
 of the new struct virStoragePoolSourceAdapter now. Later patch will
 add the checking, as adapter.data.name is only valid for scsi_host
 adapter.
 * src/storage/storage_backend_scsi.c:
   - Like above
 * tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host.xml:
 * tests/storagepoolxml2xmlin/pool-scsi-type-fc-host.xml:
   - New test for 'fc_host' and scsi_host adapter
 * tests/storagepoolxml2xmlout/pool-scsi.xml:
   - Change the expected output, as the 'type' defaults to 'scsi_host' if 
 'name
 specified now
 * tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host.xml:
 * tests/storagepoolxml2xmlout/pool-scsi-type-fc-host.xml:
   - New test
 * tests/storagepoolxml2xmltest.c:
   - Include the test
 ---
  docs/formatstorage.html.in |  16 ++-
  docs/schemas/storagepool.rng   |  33 +-
  src/conf/storage_conf.c| 132 
 +++--
  src/conf/storage_conf.h|  23 +++-
  src/libvirt_private.syms   |   2 +
  src/phyp/phyp_driver.c |   8 +-
  src/storage/storage_backend_scsi.c |   6 +-
  .../pool-scsi-type-fc-host.xml |  15 +++
  .../pool-scsi-type-scsi-host.xml   |  15 +++
  .../pool-scsi-type-fc-host.xml |  18 +++
  .../pool-scsi-type-scsi-host.xml   |  18 +++
  tests/storagepoolxml2xmlout/pool-scsi.xml  |   2 +-
  tests/storagepoolxml2xmltest.c |   2 +
  13 files changed, 266 insertions(+), 24 deletions(-)
  create mode 100644 tests/storagepoolxml2xmlin/pool-scsi-type-fc-host.xml
  create mode 100644 tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host.xml
  create mode 100644 tests/storagepoolxml2xmlout/pool-scsi-type-fc-host.xml
  create mode 100644 tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host.xml
 
 diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
 index 9b68738..eff3016 100644
 --- a/docs/formatstorage.html.in
 +++ b/docs/formatstorage.html.in
 @@ -88,8 +88,20 @@
  span class=sinceSince 0.4.1/span/dd
dtcodeadapter/code/dt
ddProvides the source for pools backed by SCSI adapters. May
 -only occur once. Contains a single attribute codename/code
 -which is the SCSI adapter name (ex. host1).
 +only occur once. Attribute codename/code is the SCSI adapter
 +name (ex. host1). Attribute codetype/code
 +(span class=since1.0.4/span) specifies the adapter type.

1.0.5 now right

 +Valid value are fc_host and scsi_host.  If omitted and

s/value/values/

 +the codename/code attribute is specified, then it defaults to
 +scsi_host. To keep backwards compatibility, the attribute
 +codetype/code is optional for the scsi_host adapter, but
 +mandatory for the fc_host adapter.  Attributes codewwnn/code
 +(Word Wide Node Name) and codewwpn/code (Word Wide Port Name)
 +(span class=since1.0.4/span) are used by the fc_host adapter

1.0.5

 +to uniquely indentify the device in the Fibre Channel storage farbic

s/indentify/identify
s/farbic/fabric


 +(the device can be either a HBA or vHBA). The optional attribute

s/vHBA). The/vHBA).  Both wwnn and wwpn must be specified. The/

The point being - although both are optional, if one is specified, then
the other must be specified as well.

 +codeparent/code (span class=since1.0.4/span) specifies the

1.0.5

 +parent device for the fc_host adapter.

Does it need to be said that wwwn, wwpn, and parent have no meaning for
scsi_host?  Also could you add a note about how parent is used - that
is why would someone want/need to specify.

One other perhaps confusing element is that name is only valid for
scsi_host. I think rather discussing he attribute name first, start
with the type. 

Re: [libvirt] [PATCH 2/7] storage: Make the adapter name be consistent with node device driver

2013-04-05 Thread John Ferlan
On 03/25/2013 12:43 PM, Osier Yang wrote:
 node device driver names the HBA like scsi_host5, but storage
 driver uses host5, which could make the user confused. This
 changes them to be consistent. However, for back-compat reason,
 adapter name like host5 is still supported.
 
 v1 - v2:
   * Use virStrToLong_ui instead of sscanf
   * No tests addition or changes, because this patch only affects
 the way scsi backend works for adapter, adding xml2xml tests for
 it is just meaningless.
 ---
  docs/formatstorage.html.in | 15 ++-
  src/storage/storage_backend_scsi.c | 54 
 +-
  2 files changed, 50 insertions(+), 19 deletions(-)
 
 diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
 index eff3016..5fae933 100644
 --- a/docs/formatstorage.html.in
 +++ b/docs/formatstorage.html.in
 @@ -89,13 +89,14 @@
dtcodeadapter/code/dt
ddProvides the source for pools backed by SCSI adapters. May
  only occur once. Attribute codename/code is the SCSI adapter
 -name (ex. host1). Attribute codetype/code
 -(span class=since1.0.4/span) specifies the adapter type.
 -Valid value are fc_host and scsi_host.  If omitted and
 -the codename/code attribute is specified, then it defaults to
 -scsi_host. To keep backwards compatibility, the attribute
 -codetype/code is optional for the scsi_host adapter, but
 -mandatory for the fc_host adapter.  Attributes codewwnn/code
 +name (ex. scsi_host1. NB, although a name such as host1 is
 +still supported for backwards compatibility, it is not recommended).
 +Attribute codetype/code (span class=since1.0.4/span)
 +specifies the adapter type. Valid value are fc_host and 
 scsi_host.
 +If omitted and the codename/code attribute is specified, then it
 +defaults to scsi_host. To keep backwards compatibility, the
 +attribute codetype/code is optional for the scsi_host adapter,
 +but mandatory for the fc_host adapter.  Attributes 
 codewwnn/code
  (Word Wide Node Name) and codewwpn/code (Word Wide Port Name)
  (span class=since1.0.4/span) are used by the fc_host adapter
  to uniquely indentify the device in the Fibre Channel storage farbic
 diff --git a/src/storage/storage_backend_scsi.c 
 b/src/storage/storage_backend_scsi.c
 index c1c163e..cc1ebe2 100644
 --- a/src/storage/storage_backend_scsi.c
 +++ b/src/storage/storage_backend_scsi.c
 @@ -632,14 +632,49 @@ out:
  }
  
  static int
 +getHostNumber(const char *adapter_name,
 +  unsigned int *result)
 +{
 +char *host = (char *)adapter_name;
 +
 +/* Specifying adapter like 'host5' is still supported for
 + * back-compat reason.
 + */
 +if (STRPREFIX(host, scsi_host)) {
 +host += strlen(scsi_host);
 +} else if (STRPREFIX(host, host)) {
 +host += strlen(host);
 +} else {
 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(invalid adapter name '%s' for scsi pool),

s/invalid/Invalid
s/scsi/SCSI

 +   adapter_name);
 +return -1;
 +}
 +
 +if (result  virStrToLong_ui(host, NULL, 10, result) == -1) {

Consider using ATTRIBUTE_NONNULL(2) on the argument instead...  Although
this is a local/static function...

 +virReportError(VIR_ERR_INTERNAL_ERROR,
 +   _(invalid adapter name '%s' for scsi pool),

s/invalid/Invalid
s/scsi/SCSI

 +   adapter_name);
 +return -1;
 +}
 +
 +return 0;
 +}
 +
 +static int
  virStorageBackendSCSICheckPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 virStoragePoolObjPtr pool,
 bool *isActive)
  {
  char *path;
 +unsigned int host;
  
  *isActive = false;
 -if (virAsprintf(path, /sys/class/scsi_host/%s, 
 pool-def-source.adapter.data.name)  0) {
 +
 +if (getHostNumber(pool-def-source.adapter.data.name, host)  0)
 +return -1;
 +
 +if (virAsprintf(path, /sys/class/scsi_host/host%d, host)  0) {
  virReportOOMError();
  return -1;
  }
 @@ -656,29 +691,24 @@ static int
  virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
   virStoragePoolObjPtr pool)
  {
 -int retval = 0;
 -uint32_t host;
 +int ret = -1;
 +unsigned int host;
  
  pool-def-allocation = pool-def-capacity = pool-def-available = 0;
  
 -if (sscanf(pool-def-source.adapter.data.name, host%u, host) != 1) {
 -VIR_DEBUG(Failed to get host number from '%s',
 -pool-def-source.adapter.data.name);
 -retval = -1;
 +if (getHostNumber(pool-def-source.adapter.data.name, host)  0)
  goto out;
 -}
  
  VIR_DEBUG(Scanning host%u, host);
  
 -if (virStorageBackendSCSITriggerRescan(host)  0) {
 -retval = -1;
 +if 

[libvirt] [PATCH] Make guest OS bootable when hardware failure happens in log disk

2013-04-05 Thread Seiji Aguchi
[Problem]
Currently, guest OS's messages can be logged to a local disk of host OS 
by creating chadevs with options below.
  -chardev file,id=charserial0,path=log file's path -device 
isa-serial,chardev=chardevserial0,id=serial0

When a hardware failure happens in the disk, qemu-kvm can't create the chardevs.
In this case, guest OS doesn't boot up.

Actually, there are users who don't desire that guest OS goes down due to a 
hardware failure 
of a log disk only.Therefore, libvirt should offer some way to boot guest OS up 
even if the log 
disk is broken.

[Solution]
This patch changes a destination to /dev/null in case a log file can't be 
opened.

Signed-off-by: Seiji Aguchi seiji.agu...@hds.com
---
 src/qemu/qemu_process.c |   20 +++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 8c4bfb7..fdf26ad 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2440,7 +2440,25 @@ qemuProcessPrepareChardevDevice(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 virReportSystemError(errno,
  _(Unable to pre-create chardev file '%s'),
  dev-source.data.file.path);
-return -1;
+VIR_FREE(dev-source.data.file.path);
+/*
+ *  Change a destination to /dev/null to boot guest OS up
+ *  even if a log disk is broken.
+ */
+dev-source.data.file.path = strdup(/dev/null);
+
+if (!dev-source.data.file.path) {
+virReportOOMError();
+return -1;
+}
+
+if ((fd = open(dev-source.data.file.path,
+   O_CREAT | O_APPEND, S_IRUSR|S_IWUSR))  0) {
+virReportSystemError(errno,
+ _(Unable to pre-create chardev file '%s'),
+ dev-source.data.file.path);
+return -1;
+}
 }
 
 VIR_FORCE_CLOSE(fd);
-- 1.7.1 



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


Re: [libvirt] [PATCH 3/7] storage: Move virStorageBackendSCSIGetHostNumber into iscsi backend

2013-04-05 Thread John Ferlan
On 03/25/2013 12:43 PM, Osier Yang wrote:
 It's only used by iscsi backend.
 ---
  src/storage/storage_backend_iscsi.c | 39 
 -
  src/storage/storage_backend_scsi.c  | 39 
 -
  src/storage/storage_backend_scsi.h  |  3 ---
  3 files changed, 38 insertions(+), 43 deletions(-)
 
 diff --git a/src/storage/storage_backend_iscsi.c 
 b/src/storage/storage_backend_iscsi.c
 index f374961..f6b76ed 100644
 --- a/src/storage/storage_backend_iscsi.c
 +++ b/src/storage/storage_backend_iscsi.c
 @@ -23,6 +23,7 @@
  
  #include config.h
  
 +#include dirent.h
  #include sys/socket.h
  #include netdb.h
  #include sys/types.h
 @@ -401,6 +402,42 @@ cleanup:
  return ret;
  }
  
 +static int
 +virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
 +uint32_t *host)
 +{
 +int retval = 0;
 +DIR *sysdir = NULL;
 +struct dirent *dirent = NULL;
 +
 +VIR_DEBUG(Finding host number from '%s', sysfs_path);
 +
 +virFileWaitForDevices();
 +
 +sysdir = opendir(sysfs_path);
 +
 +if (sysdir == NULL) {
 +virReportSystemError(errno,
 + _(Failed to opendir path '%s'), sysfs_path);
 +retval = -1;
 +goto out;
 +}
 +
 +while ((dirent = readdir(sysdir))) {
 +if (STREQLEN(dirent-d_name, target, strlen(target))) {
 +if (sscanf(dirent-d_name,
 +   target%u:, host) != 1) {
 +VIR_DEBUG(Failed to parse target '%s', dirent-d_name);
 +retval = -1;
 +break;
 +}
 +}
 +}
 +
 +closedir(sysdir);
 +out:
 +return retval;
 +}
  
  static int
  virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
 @@ -416,7 +453,7 @@ virStorageBackendISCSIFindLUs(virStoragePoolObjPtr pool,
  return -1;
  }
  
 -if (virStorageBackendSCSIGetHostNumber(sysfs_path, host)  0) {
 +if (virStorageBackendISCSIGetHostNumber(sysfs_path, host)  0) {
  virReportSystemError(errno,
   _(Failed to get host number for iSCSI session 
 with path '%s'),
 diff --git a/src/storage/storage_backend_scsi.c 
 b/src/storage/storage_backend_scsi.c
 index cc1ebe2..1bf6c0b 100644
 --- a/src/storage/storage_backend_scsi.c
 +++ b/src/storage/storage_backend_scsi.c
 @@ -547,45 +547,6 @@ out:
  return retval;
  }
  
 -
 -int
 -virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
 -   uint32_t *host)
 -{
 -int retval = 0;
 -DIR *sysdir = NULL;
 -struct dirent *dirent = NULL;
 -
 -VIR_DEBUG(Finding host number from '%s', sysfs_path);
 -
 -virFileWaitForDevices();
 -
 -sysdir = opendir(sysfs_path);
 -
 -if (sysdir == NULL) {
 -virReportSystemError(errno,
 - _(Failed to opendir path '%s'), sysfs_path);
 -retval = -1;
 -goto out;
 -}
 -
 -while ((dirent = readdir(sysdir))) {
 -if (STREQLEN(dirent-d_name, target, strlen(target))) {
 -if (sscanf(dirent-d_name,
 -   target%u:, host) != 1) {
 -VIR_DEBUG(Failed to parse target '%s', dirent-d_name);
 -retval = -1;
 -break;
 -}
 -}
 -}
 -
 -closedir(sysdir);
 -out:
 -return retval;
 -}
 -
 -
  static int
  virStorageBackendSCSITriggerRescan(uint32_t host)
  {
 diff --git a/src/storage/storage_backend_scsi.h 
 b/src/storage/storage_backend_scsi.h
 index 1cdd0da..0984fd5 100644
 --- a/src/storage/storage_backend_scsi.h
 +++ b/src/storage/storage_backend_scsi.h
 @@ -33,9 +33,6 @@
  extern virStorageBackend virStorageBackendSCSI;
  
  int
 -virStorageBackendSCSIGetHostNumber(const char *sysfs_path,
 -   uint32_t *host);
 -int
  virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
   uint32_t scanhost);
  
 

ACK  (and FYI I did check - the backend_scsi.c module has other usages
of dirent.h)

John

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


Re: [libvirt] [PATCH 1/7] New XML attributes for storage pool source adapter

2013-04-05 Thread Osier Yang

On 05/04/13 22:53, John Ferlan wrote:

On 03/25/2013 12:43 PM, Osier Yang wrote:

This introduces 4 new attributes for storage pool source adapter.
E.g.

adapter type='fc_host' parent='scsi_host5' wwnn='2000c9831b4b' 
wwpn='1000c9831b4b'/

Attribute 'type' can be either 'scsi_host' or 'fc_host', and defaults
to 'scsi_host' if attribute 'name' is specified. I.e. It's optional
for 'scsi_host' adapter, for back-compat reason. However, mandatory
for 'fc_host' adapter and any new future adapter types. Attribute
'parent' is to specify the parent for the fc_host adapter.

* docs/formatstorage.html.in:
   - Add documents for the 4 new attrs
* docs/schemas/storagepool.rng:
   - Add RNG schema
* src/conf/storage_conf.c:
   - Parse and format the new XMLs
* src/conf/storage_conf.h:
   - New struct virStoragePoolSourceAdapter, replace char *adapter with it;
   - New enum virStoragePoolSourceAdapterType
* src/libvirt_private.syms:
   - Export TypeToString and TypeFromString
* src/phyp/phyp_driver.c:
   - Replace adapter with adapter.data.name, which is member of the union
 of the new struct virStoragePoolSourceAdapter now. Later patch will
 add the checking, as adapter.data.name is only valid for scsi_host
 adapter.
* src/storage/storage_backend_scsi.c:
   - Like above
* tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host.xml:
* tests/storagepoolxml2xmlin/pool-scsi-type-fc-host.xml:
   - New test for 'fc_host' and scsi_host adapter
* tests/storagepoolxml2xmlout/pool-scsi.xml:
   - Change the expected output, as the 'type' defaults to 'scsi_host' if 'name
 specified now
* tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host.xml:
* tests/storagepoolxml2xmlout/pool-scsi-type-fc-host.xml:
   - New test
* tests/storagepoolxml2xmltest.c:
   - Include the test
---
  docs/formatstorage.html.in |  16 ++-
  docs/schemas/storagepool.rng   |  33 +-
  src/conf/storage_conf.c| 132 +++--
  src/conf/storage_conf.h|  23 +++-
  src/libvirt_private.syms   |   2 +
  src/phyp/phyp_driver.c |   8 +-
  src/storage/storage_backend_scsi.c |   6 +-
  .../pool-scsi-type-fc-host.xml |  15 +++
  .../pool-scsi-type-scsi-host.xml   |  15 +++
  .../pool-scsi-type-fc-host.xml |  18 +++
  .../pool-scsi-type-scsi-host.xml   |  18 +++
  tests/storagepoolxml2xmlout/pool-scsi.xml  |   2 +-
  tests/storagepoolxml2xmltest.c |   2 +
  13 files changed, 266 insertions(+), 24 deletions(-)
  create mode 100644 tests/storagepoolxml2xmlin/pool-scsi-type-fc-host.xml
  create mode 100644 tests/storagepoolxml2xmlin/pool-scsi-type-scsi-host.xml
  create mode 100644 tests/storagepoolxml2xmlout/pool-scsi-type-fc-host.xml
  create mode 100644 tests/storagepoolxml2xmlout/pool-scsi-type-scsi-host.xml

diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in
index 9b68738..eff3016 100644
--- a/docs/formatstorage.html.in
+++ b/docs/formatstorage.html.in
@@ -88,8 +88,20 @@
  span class=sinceSince 0.4.1/span/dd
dtcodeadapter/code/dt
ddProvides the source for pools backed by SCSI adapters. May
-only occur once. Contains a single attribute codename/code
-which is the SCSI adapter name (ex. host1).
+only occur once. Attribute codename/code is the SCSI adapter
+name (ex. host1). Attribute codetype/code
+(span class=since1.0.4/span) specifies the adapter type.

1.0.5 now right


+Valid value are fc_host and scsi_host.  If omitted and

s/value/values/


+the codename/code attribute is specified, then it defaults to
+scsi_host. To keep backwards compatibility, the attribute
+codetype/code is optional for the scsi_host adapter, but
+mandatory for the fc_host adapter.  Attributes codewwnn/code
+(Word Wide Node Name) and codewwpn/code (Word Wide Port Name)
+(span class=since1.0.4/span) are used by the fc_host adapter

1.0.5


+to uniquely indentify the device in the Fibre Channel storage farbic

s/indentify/identify
s/farbic/fabric



+(the device can be either a HBA or vHBA). The optional attribute

s/vHBA). The/vHBA).  Both wwnn and wwpn must be specified. The/

The point being - although both are optional, if one is specified, then
the other must be specified as well.


+codeparent/code (span class=since1.0.4/span) specifies the

1.0.5


+parent device for the fc_host adapter.

Does it need to be said that wwwn, wwpn, and parent have no meaning for
scsi_host?


Yes.


Also could you add a note about how parent is used - that
is why would someone want/need to specify.


XML example will be good.  I will add when pushing.



One other perhaps confusing element is that name is only valid for
scsi_host. I think rather 

Re: [libvirt] [PATCH 4/7] phyp: Prohibit fc_host adapter for phyp driver

2013-04-05 Thread John Ferlan
On 03/25/2013 12:43 PM, Osier Yang wrote:
 It's possible to support fc_host adapter for phyp driver too, but
 at this stage I'd like to not allow it when I'm not that clear
 how it works.
 ---
  src/phyp/phyp_driver.c | 7 +++
  1 file changed, 7 insertions(+)
 
 diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
 index 3a97364..a4e327e 100644
 --- a/src/phyp/phyp_driver.c
 +++ b/src/phyp/phyp_driver.c
 @@ -2519,6 +2519,13 @@ phypBuildStoragePool(virConnectPtr conn, 
 virStoragePoolDefPtr def)
  int exit_status = 0;
  virBuffer buf = VIR_BUFFER_INITIALIZER;
  
 +if (source.adapter.type !=
 +VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {

So if it's == 0 (eg. DEFAULT) or not defined, then what happens here?
Can/will we get here in that scenario.


 +virReportError(VIR_ERR_XML_ERROR, %s,
 +   _(Only 'scsi_host' adapter is supported));
 +goto cleanup;
 +}
 +
  if (system_type == HMC)
  virBufferAsprintf(buf, viosvrcmd -m %s --id %d -c ',
managed_system, vios_id);
 

ACK with question/concern handled.

John

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


Re: [libvirt] [PATCH] Make guest OS bootable when hardware failure happens in log disk

2013-04-05 Thread Daniel P. Berrange
On Fri, Apr 05, 2013 at 02:36:45PM +, Seiji Aguchi wrote:
 [Problem]
 Currently, guest OS's messages can be logged to a local disk of host OS 
 by creating chadevs with options below.
   -chardev file,id=charserial0,path=log file's path -device 
 isa-serial,chardev=chardevserial0,id=serial0
 
 When a hardware failure happens in the disk, qemu-kvm can't create the 
 chardevs.
 In this case, guest OS doesn't boot up.
 
 Actually, there are users who don't desire that guest OS goes down due to a 
 hardware failure 
 of a log disk only.Therefore, libvirt should offer some way to boot guest OS 
 up even if the log 
 disk is broken.
 
 [Solution]
 This patch changes a destination to /dev/null in case a log file can't be 
 opened.
 
 Signed-off-by: Seiji Aguchi seiji.agu...@hds.com
 ---
  src/qemu/qemu_process.c |   20 +++-
  1 files changed, 19 insertions(+), 1 deletions(-)
 
 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
 index 8c4bfb7..fdf26ad 100644
 --- a/src/qemu/qemu_process.c
 +++ b/src/qemu/qemu_process.c
 @@ -2440,7 +2440,25 @@ qemuProcessPrepareChardevDevice(virDomainDefPtr def 
 ATTRIBUTE_UNUSED,
  virReportSystemError(errno,
   _(Unable to pre-create chardev file '%s'),
   dev-source.data.file.path);
 -return -1;
 +VIR_FREE(dev-source.data.file.path);
 +/*
 + *  Change a destination to /dev/null to boot guest OS up
 + *  even if a log disk is broken.
 + */
 +dev-source.data.file.path = strdup(/dev/null);
 +
 +if (!dev-source.data.file.path) {
 +virReportOOMError();
 +return -1;
 +}
 +
 +if ((fd = open(dev-source.data.file.path,
 +   O_CREAT | O_APPEND, S_IRUSR|S_IWUSR))  0) {
 +virReportSystemError(errno,
 + _(Unable to pre-create chardev file '%s'),
 + dev-source.data.file.path);
 +return -1;
 +}
  }

NACK this is putting inappropriate policy decisions into libvirt.
This may be how you want this scenario to work, but it is certainly
not what every user of libvirt will want.

If the storage is fubar  the management application wants to still
start the guest, they should change the XML config appropriately.

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

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


Re: [libvirt] [PATCH 4/7] phyp: Prohibit fc_host adapter for phyp driver

2013-04-05 Thread Osier Yang

On 05/04/13 23:20, John Ferlan wrote:

On 03/25/2013 12:43 PM, Osier Yang wrote:

It's possible to support fc_host adapter for phyp driver too, but
at this stage I'd like to not allow it when I'm not that clear
how it works.
---
  src/phyp/phyp_driver.c | 7 +++
  1 file changed, 7 insertions(+)

diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c
index 3a97364..a4e327e 100644
--- a/src/phyp/phyp_driver.c
+++ b/src/phyp/phyp_driver.c
@@ -2519,6 +2519,13 @@ phypBuildStoragePool(virConnectPtr conn, 
virStoragePoolDefPtr def)
  int exit_status = 0;
  virBuffer buf = VIR_BUFFER_INITIALIZER;
  
+if (source.adapter.type !=

+VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST) {

So if it's == 0 (eg. DEFAULT) or not defined, then what happens here?
Can/will we get here in that scenario.


It can't, see the XML parsing, the type is either SCSI_HOST or FC_HOST after
the parsing.





+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(Only 'scsi_host' adapter is supported));
+goto cleanup;
+}
+
  if (system_type == HMC)
  virBufferAsprintf(buf, viosvrcmd -m %s --id %d -c ',
managed_system, vios_id);


ACK with question/concern handled.

John

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


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


Re: [libvirt] [PATCH] Make guest OS bootable when hardware failure happens in log disk

2013-04-05 Thread Seiji Aguchi
 NACK this is putting inappropriate policy decisions into libvirt.
 This may be how you want this scenario to work, but it is certainly not what 
 every user of libvirt will want.

How about adding some option to libvirt so that  the users can choose policies?

 If the storage is fubar  the management application wants to still start the 
 guest, they should change the XML config appropriately.

I think that providing options is user-friendly rather than asking users to 
edit xml by hand after the storage is broken.

Seiji

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


[libvirt] [PATCH v2] qemu: Support multiple queue virtio-scsi

2013-04-05 Thread Osier Yang
This introduce a new attribute num_queues (same with the good name
QEMU uses) for virtio-scsi controller. An example of the XML:

controller type='scsi' index='0' model='virtio-scsi' num_queues='8'/

The corresponding QEMU command line:

-device virtio-scsi-pci,id=scsi0,num_queues=8,bus=pci.0,addr=0x3 \
---
 docs/formatdomain.html.in  | 18 +--
 docs/schemas/domaincommon.rng  |  5 +
 src/conf/domain_conf.c | 13 +++
 src/conf/domain_conf.h |  1 +
 src/qemu/qemu_command.c| 11 +
 .../qemuxml2argv-disk-virtio-scsi-num_queues.args  |  8 +++
 .../qemuxml2argv-disk-virtio-scsi-num_queues.xml   | 26 ++
 tests/qemuxml2argvtest.c   |  3 +++
 tests/qemuxml2xmltest.c|  1 +
 9 files changed, 79 insertions(+), 7 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-disk-virtio-scsi-num_queues.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index cf382e8..2973ce2 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2092,13 +2092,17 @@
   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
-  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,
-  span class=sincesince 0.10.0/span, if the USB bus needs to be
-  explicitly disabled for the guest, codemodel='none'/code may be used.
-  The PowerPC64 spapr-vio addresses do not have an associated controller.
+  vmpvscsi.  The attribute codenum_queues/code
+  (span class=since1.0.5 (QEMU and KVM only)/span) is to specify
+  the number of queues for the controller, it's recommended to specify
+  the value matching the number of vCPUs for best performance.  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, span class=sincesince 0.10.0/span, if the USB bus
+  needs to be explicitly disabled for the guest, codemodel='none'/code
+  may be used.  The PowerPC64 spapr-vio addresses do not have an
+  associated controller.
 /p
 
 p
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 63ba7d1..d486ae8 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1427,6 +1427,11 @@
 /attribute
   /optional
   optional
+attribute name=num_queues
+  ref name=unsignedInt/
+/attribute
+  /optional
+  optional
 ref name=usbmaster/
   /optional
   optional
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5ad3080..f50a964 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5034,6 +5034,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 char *type = NULL;
 char *idx = NULL;
 char *model = NULL;
+char *num_queues = NULL;
 
 if (VIR_ALLOC(def)  0) {
 virReportOOMError();
@@ -5069,6 +5070,14 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 def-model = -1;
 }
 
+if ((num_queues = virXMLPropString(node, num_queues))) {
+if (virStrToLong_ui(num_queues, NULL, 10, def-num_queues)  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(Malformed 'num_queues' value '%s'), num_queues);
+goto error;
+}
+}
+
 if (virDomainDeviceInfoParseXML(node, NULL, def-info, flags)  0)
 goto error;
 
@@ -5146,6 +5155,7 @@ cleanup:
 VIR_FREE(type);
 VIR_FREE(idx);
 VIR_FREE(model);
+VIR_FREE(num_queues);
 
 return def;
 
@@ -13195,6 +13205,9 @@ virDomainControllerDefFormat(virBufferPtr buf,
 virBufferEscapeString(buf,  model='%s', model);
 }
 
+if (def-num_queues)
+virBufferAsprintf(buf,  num_queues='%u', def-num_queues);
+
 switch (def-type) {
 case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
 if (def-opts.vioserial.ports != -1) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 700f03f..75e3f15 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -728,6 +728,7 @@ struct _virDomainControllerDef {
 int type;
 int idx;
 int model; /* -1 == undef */
+unsigned int num_queues;
 union {
 virDomainVirtioSerialOpts vioserial;
 } opts;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 493e5f8..53caba5 100644

[libvirt] [PATCH] qemu: Don't require a block or file when looking for an alias.

2013-04-05 Thread Wido den Hollander
From: root root@kvm01.(none)

This for example prohibits you to use iotune for Ceph or Sheepdog devices.

Signed-off-by: Wido den Hollander w...@widodh.nl
---
 src/qemu/qemu_driver.c |4 
 1 file changed, 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 552a81b..464d30a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13032,10 +13032,6 @@ qemuDiskPathToAlias(virDomainObjPtr vm, const char 
*path, int *idx)
 if (idx)
 *idx = i;
 
-if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK 
-disk-type != VIR_DOMAIN_DISK_TYPE_FILE)
-goto cleanup;
-
 if (disk-src) {
 if (virAsprintf(ret, drive-%s, disk-info.alias)  0) {
 virReportOOMError();
-- 
1.7.9.5

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


[libvirt] [PATCH v2] util: Add a helper to check if all bits of a bitmap are clear

2013-04-05 Thread Osier Yang
---
 src/libvirt_private.syms |  1 +
 src/util/virbitmap.c | 17 +
 src/util/virbitmap.h |  3 +++
 3 files changed, 21 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b7b9631..6b831b3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1046,6 +1046,7 @@ virBitmapEqual;
 virBitmapFormat;
 virBitmapFree;
 virBitmapGetBit;
+virBitmapIsAllClear;
 virBitmapIsAllSet;
 virBitmapNew;
 virBitmapNewCopy;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 21509ac..998c302 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -591,6 +591,23 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
 }
 
 /**
+ * virBitmapIsAllClear:
+ * @bitmap: the bitmap to check
+ *
+ * check if all bits in @bitmap are clear
+ */
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+{
+int i;
+
+for (i = 0; i  bitmap-map_len; i++)
+if (bitmap-map[i] != 0)
+return false;
+
+return true;
+}
+
+/**
  * virBitmapNextSetBit:
  * @bitmap: the bitmap
  * @pos: the position after which to search for a set bit
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index 044c7a6..b682523 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -100,6 +100,9 @@ void virBitmapClearAll(virBitmapPtr bitmap)
 bool virBitmapIsAllSet(virBitmapPtr bitmap)
 ATTRIBUTE_NONNULL(1);
 
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+ATTRIBUTE_NONNULL(1);
+
 ssize_t virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
 ATTRIBUTE_NONNULL(1);
 
-- 
1.8.1.4

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


Re: [libvirt] [PATCH] qemu: Don't require a block or file when looking for an alias.

2013-04-05 Thread Wido den Hollander

On 04/05/2013 05:36 PM, Wido den Hollander wrote:

From: root root@kvm01.(none)



My bad for this one, I noticed it to late.

Wido


This for example prohibits you to use iotune for Ceph or Sheepdog devices.

Signed-off-by: Wido den Hollander w...@widodh.nl
---
  src/qemu/qemu_driver.c |4 
  1 file changed, 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 552a81b..464d30a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13032,10 +13032,6 @@ qemuDiskPathToAlias(virDomainObjPtr vm, const char 
*path, int *idx)
  if (idx)
  *idx = i;

-if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK 
-disk-type != VIR_DOMAIN_DISK_TYPE_FILE)
-goto cleanup;
-
  if (disk-src) {
  if (virAsprintf(ret, drive-%s, disk-info.alias)  0) {
  virReportOOMError();



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


Re: [libvirt] [PATCH 2/8] Introduce new XMLs to specify disk source using libvirt storage

2013-04-05 Thread Osier Yang

On 05/04/13 14:53, Paolo Bonzini wrote:

Il 04/04/2013 21:40, Osier Yang ha scritto:

Depending on the pool type, this should be treated as file or block.
You do this correctly in patch 8, but I think it is not complete.  For
example, will your patches allow SCSI passthrough of a volume inside an
iSCSI pool?

No, it will be another patch set. On top of Han cheng's patches.

scsi-generic support for iSCSI pool would need his patches, but
scsi-block shouldn't.


Oh, right, for a lun device, it's only valid for block type disk
currently, so it can't work for a volume type disk (and the
volume is of block type), I'm making the patch.



My impression is that you already have half baked support for this
feature in patches 7/8, and you should either complete it, or leave it
out of this series.

Paolo


I'm waiting for those patches go in first, or I will rebase/update
it if Han doesn't have enough time to do it, and do the work
after that.


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


Re: [libvirt] [PATCH] qemu: Don't require a block or file when looking for an alias.

2013-04-05 Thread Eric Blake
On 04/05/2013 09:36 AM, Wido den Hollander wrote:
 From: root root@kvm01.(none)

Please resend, after properly configuring your git.

 
 This for example prohibits you to use iotune for Ceph or Sheepdog devices.
 
 Signed-off-by: Wido den Hollander w...@widodh.nl
 ---
  src/qemu/qemu_driver.c |4 
  1 file changed, 4 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 552a81b..464d30a 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -13032,10 +13032,6 @@ qemuDiskPathToAlias(virDomainObjPtr vm, const char 
 *path, int *idx)
  if (idx)
  *idx = i;
  
 -if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK 
 -disk-type != VIR_DOMAIN_DISK_TYPE_FILE)
 -goto cleanup;
 -
  if (disk-src) {
  if (virAsprintf(ret, drive-%s, disk-info.alias)  0) {
  virReportOOMError();
 

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



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

Re: [libvirt] [PATCH v2] util: Add a helper to check if all bits of a bitmap are clear

2013-04-05 Thread Eric Blake
On 04/05/2013 10:32 AM, Osier Yang wrote:
 ---
  src/libvirt_private.syms |  1 +
  src/util/virbitmap.c | 17 +
  src/util/virbitmap.h |  3 +++
  3 files changed, 21 insertions(+)

The implementation looks correct, but I still think this patch should be
the one that enhances the testsuite to prove that it works.

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



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

[libvirt] [PATCH] build: use proper pod for nested bulleted VIRSH_DEBUG list

2013-04-05 Thread Eric Blake
Newer pod (hello rawhide) complains if you attempt to mix bullets
and non-bullets in the same list:

virsh.pod around line 3177: Expected text after =item, not a bullet

As our intent was to nest an inner list, we make that explicit to
keep pod happy.

* tools/virsh.pod (ENVIRONMENT): Use correct pod syntax.
---

Pushing under the build-breaker rule.

 tools/virsh.pod | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 1c8f9ee..89467f6 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -3174,6 +3174,8 @@ of Cvirsh

 Turn on verbose debugging of virsh commands. Valid levels are

+=over 4
+
 =item * VIRSH_DEBUG=0

 DEBUG - Messages at ALL levels get logged
@@ -3194,6 +3196,8 @@ WARNING - Logs messages at levels WARNING and ERROR

 ERROR - Messages at only ERROR level gets logged.

+=back
+
 =item VIRSH_LOG_FILE=CLOGFILE

 The file to log virsh debug messages.
-- 
1.8.1.4

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


[libvirt] [PATCH] qemu: Don't require a block or file when looking for an alias.

2013-04-05 Thread Wido den Hollander
This for example prohibits you to use iotune for Ceph or Sheepdog devices.

Signed-off-by: Wido den Hollander w...@widodh.nl
---
 src/qemu/qemu_driver.c |4 
 1 file changed, 4 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 552a81b..464d30a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -13032,10 +13032,6 @@ qemuDiskPathToAlias(virDomainObjPtr vm, const char 
*path, int *idx)
 if (idx)
 *idx = i;
 
-if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK 
-disk-type != VIR_DOMAIN_DISK_TYPE_FILE)
-goto cleanup;
-
 if (disk-src) {
 if (virAsprintf(ret, drive-%s, disk-info.alias)  0) {
 virReportOOMError();
-- 
1.7.9.5

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


[libvirt] [PATCH 9/8] qemu: Allow volume type disk for device 'lun'

2013-04-05 Thread Osier Yang
This allows one use block type volume as the disk source for device
'lun'.
---
 src/qemu/qemu_command.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index c29796d..2fc63ae 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3131,10 +3131,11 @@ qemuBuildDriveDevStr(virDomainDefPtr def,

virDomainDiskProtocolTypeToString(disk-protocol));
 goto error;
 }
-} else if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _(disk device='lun' is not supported for 
type='%s'),
-   virDomainDiskTypeToString(disk-type));
+} else if (disk-type != VIR_DOMAIN_DISK_TYPE_BLOCK 
+   !(disk-type == VIR_DOMAIN_DISK_TYPE_VOLUME 
+ disk-srcpool-voltype == VIR_STORAGE_VOL_BLOCK)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(disk device='lun' is only valid for block type 
disk source));
 goto error;
 }
 if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_BLK_SG_IO)) {
-- 
1.8.1.4

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


[libvirt] [PATCH] Add a test suite for keycode mapping functions

2013-04-05 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Validate that translations between different keycode sets
are functioning.

Signed-off-by: Daniel P. Berrange berra...@redhat.com
---
 tests/virkeycodetest.c | 107 +
 1 file changed, 107 insertions(+)
 create mode 100644 tests/virkeycodetest.c

diff --git a/tests/virkeycodetest.c b/tests/virkeycodetest.c
new file mode 100644
index 000..d3c5975
--- /dev/null
+++ b/tests/virkeycodetest.c
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2013 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library;  If not, see
+ * http://www.gnu.org/licenses/.
+ *
+ * Author: Daniel P. Berrange berra...@redhat.com
+ */
+
+#include config.h
+
+#include stdlib.h
+
+#include testutils.h
+
+#include virkeycode.h
+#include virutil.h
+#include virerror.h
+#include viralloc.h
+#include virlog.h
+
+#include virlockspace.h
+
+#define VIR_FROM_THIS VIR_FROM_NONE
+
+
+static int testKeycodeMapping(const void *data ATTRIBUTE_UNUSED)
+{
+int ret = -1;
+int got;
+
+#define TRANSLATE(from, to, val, want)  \
+do {\
+if ((got = virKeycodeValueTranslate(VIR_KEYCODE_SET_##from, \
+VIR_KEYCODE_SET_##to,   \
+val)) != want) {\
+fprintf(stderr, Translating %d from %s to %s, got %d want %d\n, \
+val, #from, #to, got, want);\
+goto cleanup;   \
+}   \
+} while (0)
+
+TRANSLATE(LINUX, LINUX, 111, 111);
+TRANSLATE(LINUX, USB, 111, 76);
+TRANSLATE(LINUX, RFB, 88, 88);
+TRANSLATE(LINUX, RFB, 160, 163);
+TRANSLATE(ATSET2, ATSET3, 259, 55);
+
+#undef TRANSLATE
+
+ret = 0;
+cleanup:
+return ret;
+}
+
+
+static int testKeycodeStrings(const void *data ATTRIBUTE_UNUSED)
+{
+int ret = -1;
+int got;
+
+#define TRANSLATE(from, str, want)  \
+do {\
+if ((got = virKeycodeValueFromString(VIR_KEYCODE_SET_##from,\
+ str)) != want) {   \
+fprintf(stderr, Converting %s from %s, got %d want %d\n,  \
+str, #from, got, want); \
+goto cleanup;   \
+}   \
+} while (0)
+
+TRANSLATE(LINUX, KEY_DELETE, 111);
+TRANSLATE(OSX, Function, 0x3f);
+TRANSLATE(WIN32, VK_UP, 0x26);
+
+#undef TRANSLATE
+
+ret = 0;
+cleanup:
+return ret;
+}
+
+static int
+mymain(void)
+{
+int ret = 0;
+
+if (virtTestRun(Keycode mapping , 1, testKeycodeMapping, NULL)  0)
+ret = -1;
+if (virtTestRun(Keycode strings , 1, testKeycodeStrings, NULL)  0)
+ret = -1;
+
+return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+
+VIRT_TEST_MAIN(mymain)
-- 
1.8.1.4

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


Re: [libvirt] [PATCH] Add a test suite for keycode mapping functions

2013-04-05 Thread Eric Blake
On 04/05/2013 10:50 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 Validate that translations between different keycode sets
 are functioning.
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  tests/virkeycodetest.c | 107 
 +
  1 file changed, 107 insertions(+)
  create mode 100644 tests/virkeycodetest.c

Never hurts to add tests :)

 +static int
 +mymain(void)
 +{
 +int ret = 0;
 +
 +if (virtTestRun(Keycode mapping , 1, testKeycodeMapping, NULL)  0)
 +ret = -1;
 +if (virtTestRun(Keycode strings , 1, testKeycodeStrings, NULL)  0)
 +ret = -1;
 +
 +return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;

Spaces around ==.

ACK.

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



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

Re: [libvirt] [PATCH 0/8 v2] Glue domain and storage

2013-04-05 Thread Osier Yang

Like 7/8, 8/8, 9/8, there must be many places which also should be
modified to not prevent the new volume type disk out of the door,
but it's hard to find them out at once, disk related stuffs are always
hairy. Anyway, it doesn't affect to let the basic go in first, because
they are all additions, which are unlikely to introduce regressions.
so please give reviewing.  Thanks.

On 05/04/13 03:37, Osier Yang wrote:

This is the 4th part to implement NPIV migration support [1].

Part 1 and part 2 are pushed.

Part 3 (v3: pending for review):
   https://www.redhat.com/archives/libvir-list/2013-March/msg01440.html

==

This introduces new XMLs to specify the disk source with storage like

   disk type='volume' device='disk'
 driver name='qemu' type='raw' cache='none'/
 source pool=$pool_name volume='$vol_name'/
   seclabel relabel='no'/
 /source
 target dev='vdb' bus='virtio'/
   /disk

And before domain starting, and disk attaching/updating, the source represented
by storage is translated into the real underlying storage volume.

Future work:
   * Support network volume
   * Support disk backing chain?

v1 - v2:
   * Invoke storage APIs to translate the source directly in qemu driver
   * 1/8 in v1 is pushed.
   * 2/8 in v1 is splitted (the code refactoring now is a standalone patch)
   * Support shared disk for volume type disk
   * Support sgio setting for volume type disk
   * No network volume support in v2
   
RFC - v1:

   * The XMLs are more simpler - only using pool name and volume
 name to specify disk source.
   * Support network pool (rbd, and sheepdog)
   * Support startupPolicy for volume type disk
   * Support seclabels for volume type disk
   * Fix bugs on disk source formating

Osier Yang (8):
   conf: New helper virDomainDiskSourceDefFormat to format the disk
 source
   Introduce new XMLs to specify disk source using libvirt storage
   qemu: Translate the pool disk source when building drive string
   Support startupPolicy for 'volume' disk
   Support seclabels for volume type disk
   qemu: Translate the pool disk source earlier
   qemu: Support shareable volume type disk
   qemu: Support sgio setting for volume type disk

  docs/formatdomain.html.in  |  28 ++-
  docs/schemas/domaincommon.rng  |  24 ++
  src/conf/domain_conf.c | 274 ++---
  src/conf/domain_conf.h |  10 +
  src/qemu/qemu_command.c|  32 +++
  src/qemu/qemu_command.h|   1 -
  src/qemu/qemu_conf.c   |  68 -
  src/qemu/qemu_conf.h   |   3 +
  src/qemu/qemu_domain.c |   4 +-
  src/qemu/qemu_driver.c |  16 +-
  src/qemu/qemu_process.c|  14 +-
  .../qemuxml2argv-disk-source-pool.xml  |  37 +++
  tests/qemuxml2xmltest.c|   1 +
  13 files changed, 406 insertions(+), 106 deletions(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool.xml



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


[libvirt] [PATCH] build: check correct protocol.o file

2013-04-05 Thread Eric Blake
By default, libtool builds two .o files for every .lo rule:
src/foo.o - static builds
src/.libs/foo.o - shared library builds

But since commit ad42b34b disabled static builds, src/foo.o is
no longer built by default.  On a fresh checkout, this means our
protocol check rules using pdwtags were testing a missing file,
and thanks a lousy behavior of pdwtags happily giving no output
and 0 exit status (http://bugzilla.redhat.com/949034), we were
merely claiming that dwarves is too old and skipping the test.

However, if you swap between branches and do incremental builds,
such as building v0.10.2-maint and then switching back to master,
you end up with src/foo.o being leftover from its 0.10.2 state,
and then 'make check' fails because the .o file does not match
the protocol-structs file due to API additions in the meantime.

A simpler fix would be to always look in .libs for the .o to
be parsed; but since it is possible to pass ./configure options
to tell libtool to do a static-only build with no shared .o,
I went with the approach of finding the newest of the two files,
whenever both exist.

* src/Makefile.am (PDWTAGS): Ensure we test just-built file.
---

Pushing under the build-breaker rule.

 src/Makefile.am | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 78b4ab6..5dc58f9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -341,9 +341,16 @@ r1 = /\* \d+ \*/
 r2 = /\* [[:xdigit:]]+ \S+:\d+ \*/
 struct_prefix = (remote_|qemu_|lxc_|virNet|keepalive_)

+# Depending on configure options, libtool creates one or both of
+# {,.libs/}libvirt_remote_driver_la-remote_protocol.o.  We want the
+# newest of the two, in case configure options changed and a stale
+# file is left around from an earlier build.
 PDWTAGS = \
$(AM_V_GEN)if (pdwtags --help)  /dev/null 21; then   \
- pdwtags --verbose $(:.lo=.$(OBJEXT))  $(@F)-t1 2 $(@F)-t2; \
+ file=`ls -t $(:.lo=.$(OBJEXT)) .libs/$(:.lo=.$(OBJEXT)) \
+   2/dev/null | sed -n 1p`;   \
+ test -f $$file || { echo .o for $ not found 2; exit 1; };\
+ pdwtags --verbose $$file  $(@F)-t1 2 $(@F)-t2;  \
  if test -s $(@F)-t2; then \
rm -rf $(@F)-t?;\
echo 'WARNING: pdwtags appears broken; skipping the $@ test' 2;\
-- 
1.8.1.4

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


Re: [libvirt] [PATCH v2] util: Add a helper to check if all bits of a bitmap are clear

2013-04-05 Thread Osier Yang

On 05/04/13 23:59, Eric Blake wrote:

On 04/05/2013 10:32 AM, Osier Yang wrote:

---
  src/libvirt_private.syms |  1 +
  src/util/virbitmap.c | 17 +
  src/util/virbitmap.h |  3 +++
  3 files changed, 21 insertions(+)

The implementation looks correct, but I still think this patch should be
the one that enhances the testsuite to prove that it works.

Forgot it again, v3 posted. Thanks.

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


[libvirt] [PATCH v3] util: Add a helper to check if all bits of a bitmap are clear

2013-04-05 Thread Osier Yang
---
 src/libvirt_private.syms |  1 +
 src/util/virbitmap.c | 17 +
 src/util/virbitmap.h |  3 +++
 tests/virbitmaptest.c| 33 -
 4 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b7b9631..6b831b3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1046,6 +1046,7 @@ virBitmapEqual;
 virBitmapFormat;
 virBitmapFree;
 virBitmapGetBit;
+virBitmapIsAllClear;
 virBitmapIsAllSet;
 virBitmapNew;
 virBitmapNewCopy;
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index 21509ac..998c302 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -591,6 +591,23 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
 }
 
 /**
+ * virBitmapIsAllClear:
+ * @bitmap: the bitmap to check
+ *
+ * check if all bits in @bitmap are clear
+ */
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+{
+int i;
+
+for (i = 0; i  bitmap-map_len; i++)
+if (bitmap-map[i] != 0)
+return false;
+
+return true;
+}
+
+/**
  * virBitmapNextSetBit:
  * @bitmap: the bitmap
  * @pos: the position after which to search for a set bit
diff --git a/src/util/virbitmap.h b/src/util/virbitmap.h
index 044c7a6..b682523 100644
--- a/src/util/virbitmap.h
+++ b/src/util/virbitmap.h
@@ -100,6 +100,9 @@ void virBitmapClearAll(virBitmapPtr bitmap)
 bool virBitmapIsAllSet(virBitmapPtr bitmap)
 ATTRIBUTE_NONNULL(1);
 
+bool virBitmapIsAllClear(virBitmapPtr bitmap)
+ATTRIBUTE_NONNULL(1);
+
 ssize_t virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
 ATTRIBUTE_NONNULL(1);
 
diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
index 95d010a..3067f6e 100644
--- a/tests/virbitmaptest.c
+++ b/tests/virbitmaptest.c
@@ -125,6 +125,8 @@ static int test2(const void *data ATTRIBUTE_UNUSED)
 goto error;
 
 virBitmapClearAll(bitmap);
+if (!virBitmapIsAllClear(bitmap))
+goto error;
 if (testBit(bitmap, 0, size - 1, false)  0)
 goto error;
 if (virBitmapCountBits(bitmap) != 0)
@@ -154,6 +156,9 @@ static int test3(const void *data ATTRIBUTE_UNUSED)
 if (!virBitmapIsAllSet(bitmap))
 goto error;
 
+virBitmapClearAll(bitmap);
+if (!virBitmapIsAllClear(bitmap))
+goto error;
 ret = 0;
 
 error:
@@ -196,6 +201,9 @@ static int test4(const void *data ATTRIBUTE_UNUSED)
 if (virBitmapNextClearBit(bitmap, i) != -1)
 goto error;
 
+if (!virBitmapIsAllClear(bitmap))
+goto error;
+
 virBitmapFree(bitmap);
 bitmap = NULL;
 
@@ -406,6 +414,10 @@ static int test7(const void *v ATTRIBUTE_UNUSED)
 if (!virBitmapIsAllSet(bitmap))
 goto error;
 
+virBitmapClearAll(bitmap);
+if (!virBitmapIsAllClear(bitmap))
+goto error;
+
 virBitmapFree(bitmap);
 }
 
@@ -416,6 +428,24 @@ error:
 return -1;
 }
 
+static int test8(const void *v ATTRIBUTE_UNUSED)
+{
+virBitmapPtr bitmap = NULL;
+char data[108] = {0x00,};
+
+bitmap = virBitmapNewData(data, sizeof(data));
+if (!bitmap)
+goto error;
+
+if (!virBitmapIsAllClear(bitmap))
+goto error;
+
+return 0;
+error:
+virBitmapFree(bitmap);
+return -1;
+}
+
 static int
 mymain(void)
 {
@@ -435,7 +465,8 @@ mymain(void)
 ret = -1;
 if (virtTestRun(test7, 1, test7, NULL)  0)
 ret = -1;
-
+if (virtTestRun(test8, 1, test8, NULL)  0)
+ret = -1;
 
 return ret;
 }
-- 
1.8.1.4

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


Re: [libvirt] [PATCH 4/7] add pci-bridge controller type

2013-04-05 Thread Laine Stump
On 04/03/2013 11:50 AM, Ján Tomko wrote:
 From: liguang lig.f...@cn.fujitsu.com

 add a new controller type, then one can
 define a pci-bridge controller like this:
 controller type='pci-bridge' index='0'/

In the next patch we're prohibiting exactly this config (index='0')
because the pre-existing pci bus on the pc-* machinetypes is already
named pci.0. If we don't allow it, we shouldn't include it as an example
in the commit log :-)

More on this - one of the things this points out is that there is no
representation in the config of the pci.0 bus, it's just assumed to
always be there. That is the case for pc-* machinetypes (and probably
several others with PCI buses), but for q35, there is no pci.0 bus in
the basic machine, only a pcie.0; if you want a pci.0 on q35 (which
*will* be necessary in order to attach any pci devices, so I imagine we
will always want one), you have to attach a pcie-pci bridge, which is
the device i82801b11-bridge, to pcie.0.

The reason I bring this up here, is I'm wondering:

1) should we have some representation of the default pci.0 bus in the
config, even though it is just always there for the pc machinetypes
and there is no way to disable it, and nothing on the commandline that
specifies its existence?

2) For the q35 machinetype, should we just always add an
i82801b11-bridge device and name it pci.0? Or should that need to be
present in the xml?

3) Most important - depending on the answers to (1) and (2), should we
maybe name this device pci, and use a different backend depending on
index and machinetype? (or alternately explicitly specifiable with a
driver subelement). To be specific, we would have:

   controller type='pci' index='0'/

which on pc machinetypes would just be a placeholder in the config (and
always inserted if it wasn't there, for machinetypes that have a pci
bus). On the q35 machinetype, that same line would equate to adding an
i82801b11-bridge device (with source defaulting to
bus=pcie.0,addr=1e.0). This would serve several purposes:

a) on pc machinetypes, it would be a visual aid indicating that pci.0
exists, and that index='0' isn't available for a new pci controller.

b) it would make switching a domain config from pc to q35 simpler, since
pci.0 would always already be in place for attaching pci devices
(including pci.1, pci.2, etc)

c) it would make the config a true complete description of the machine
being created.

(I've suggested naming the controller pci rather than pci-bridge
because in the case of a root bus like pci.0 it seems to not be a
bridge, but maybe the name pci-bridge is always appropriate, even
when it's a root bus. Maybe someone with better pci/pcie knowledge can
provide an opinion on this)


 controller type='pci-bridge' index='1'
   address type='pci' domain='0x' bus='0x00' slot='0x05' 
 function='0x0'/
 /controller
 actually, it works as a pci-bus, so as to support
 multi-pci-bus via pci-to-pci bridge

 Signed-off-by: liguang lig.f...@cn.fujitsu.com
 ---
  docs/schemas/domaincommon.rng | 1 +
  src/conf/domain_conf.c| 3 ++-
  src/conf/domain_conf.h| 1 +
  3 files changed, 4 insertions(+), 1 deletion(-)

 diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
 index 8d7e6db..b6dc013 100644
 --- a/docs/schemas/domaincommon.rng
 +++ b/docs/schemas/domaincommon.rng
 @@ -1357,6 +1357,7 @@
  valuesata/value
  valueccid/value
  valueusb/value
 +valuepci-bridge/value
/choice
  /attribute
/optional
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index cc26f21..6a990bb 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -295,7 +295,8 @@ VIR_ENUM_IMPL(virDomainController, 
 VIR_DOMAIN_CONTROLLER_TYPE_LAST,
sata,
virtio-serial,
ccid,
 -  usb)
 +  usb,
 +  pci-bridge)
  
  VIR_ENUM_IMPL(virDomainControllerModelSCSI, 
 VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST,
auto,
 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index edddf25..1ec8564 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -682,6 +682,7 @@ enum virDomainControllerType {
  VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL,
  VIR_DOMAIN_CONTROLLER_TYPE_CCID,
  VIR_DOMAIN_CONTROLLER_TYPE_USB,
 +VIR_DOMAIN_CONTROLLER_TYPE_PCI_BRIDGE,
  
  VIR_DOMAIN_CONTROLLER_TYPE_LAST
  };

If nobody thinks making the name of the controller pci instead of
pci-bridge makes sense, then ACK once the commit log has the bad
example removed. (We'll need to make the default initial index be 1 for
these instead of 0, but I think that should go in the next patch anyway,
because as I said above, there may be a use for a pci controller with
index='0').

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


Re: [libvirt] [PATCH v3] util: Add a helper to check if all bits of a bitmap are clear

2013-04-05 Thread Eric Blake
On 04/05/2013 12:06 PM, Osier Yang wrote:
 ---
  src/libvirt_private.syms |  1 +
  src/util/virbitmap.c | 17 +
  src/util/virbitmap.h |  3 +++
  tests/virbitmaptest.c| 33 -
  4 files changed, 53 insertions(+), 1 deletion(-)

ACK with one suggestion:

 +static int test8(const void *v ATTRIBUTE_UNUSED)
 +{
 +virBitmapPtr bitmap = NULL;
 +char data[108] = {0x00,};
 +
 +bitmap = virBitmapNewData(data, sizeof(data));
 +if (!bitmap)
 +goto error;
 +
 +if (!virBitmapIsAllClear(bitmap))
 +goto error;

Here, it would also be handy to set a bit, then check that
virBitmapIsAllClear returns false (all the tests that you added merely
check that virBitmapIsAllClear returns true when it should).

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



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

Re: [libvirt] [PATCH 5/7] qemu: build command line for pci-bridge device

2013-04-05 Thread Laine Stump
On 04/03/2013 11:50 AM, Ján Tomko wrote:
 From: liguang lig.f...@cn.fujitsu.com

 ---
  src/qemu/qemu_capabilities.c |  2 ++
  src/qemu/qemu_capabilities.h |  1 +
  src/qemu/qemu_command.c  | 15 ++-
  tests/qemuhelptest.c | 21 ++---
  4 files changed, 31 insertions(+), 8 deletions(-)

 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index aa381b4..4377e08 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -216,6 +216,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
  
ipv6-migration, /* 135 */
machine-opt,
 +  pci-bridge,
  );
  
  struct _virQEMUCaps {
 @@ -1357,6 +1358,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] 
 = {
  { virtio-rng-ccw, QEMU_CAPS_DEVICE_VIRTIO_RNG },
  { rng-random, QEMU_CAPS_OBJECT_RNG_RANDOM },
  { rng-egd, QEMU_CAPS_OBJECT_RNG_EGD },
 +{ pci-bridge, QEMU_CAPS_DEVICE_PCI_BRIDGE },
  };
  
  static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBlk[] = {
 diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
 index b2dc588..e3bba52 100644
 --- a/src/qemu/qemu_capabilities.h
 +++ b/src/qemu/qemu_capabilities.h
 @@ -176,6 +176,7 @@ enum virQEMUCapsFlags {
  QEMU_CAPS_SCSI_MEGASAS   = 134, /* -device megasas */
  QEMU_CAPS_IPV6_MIGRATION = 135, /* -incoming [::] */
  QEMU_CAPS_MACHINE_OPT= 136, /* -machine */
 +QEMU_CAPS_DEVICE_PCI_BRIDGE  = 137, /* -device pci-bridge */
  
  QEMU_CAPS_LAST,   /* this must always be the last item */
  };
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index e221c82..7817b13 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -1972,7 +1972,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf,
   * When QEMU grows support for  1 PCI domain, then pci.0 change
   * to pciNN.0  where NN is the domain number
   */
 -if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS))
 +if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE))
 +virBufferAsprintf(buf, ,bus=pci.%u, info-addr.pci.bus);
 +else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS))
  virBufferAsprintf(buf, ,bus=pci.0);
  else
  virBufferAsprintf(buf, ,bus=pci);


The above looks like it would just cover up a configuration problem - if
info-addr.pci.bus is  0, then QEMU_CAPS_DEVICE_PCI_BRIDGE had better
be true, otherwise it's an error in the config (and I assume that if
DEVICE_PCI_BRIDGE is true, then soe is PCI_MULTIBUS, correct?). In this
case we shouldn't just silently use bus=pci.0 or bus=pci, we should log
an error:

if (virQEMUCapsGet(qemuCaps, QEMUCAPS_DEVICE_PCI_BRIDGE)) {
virBufferAsprintf(buf, ,bus=pci.%u, info-addr.pci.bus);
} else {
if (info-addr.pci.bus != 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
   _(Only PCI device addresses with bus=0 
 are supported with this QEMU binary));
return -1;
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_MULTIBUS))
virBufferAddLit(buf, ,bus=pci.0);
else
virBufferAddLit(buf, ,bus=pci);

}


 @@ -3576,6 +3578,16 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
  
  break;
  
 +case VIR_DOMAIN_CONTROLLER_TYPE_PCI_BRIDGE:
 +if (def-idx == 0) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
 +   _(PCI bridge index should be  0));
 +goto error;
 +}
 +virBufferAsprintf(buf, pci-bridge,chassis_nr=%d,id=pci.%d,
 +  def-idx, def-idx);
 +break;
 +

Depending on what others think about my comments in 4/7, when we see a
bridge with index='0', instead of erroring out, we may want to:

  1) ignore it if machinetype is pc-*
  2) generate a commandline for an i82801b11-bridge device attached to
pcie.0 if machinetype is q35-*


  /* We always get an IDE controller, whether we want it or not. */
  case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
  default:
 @@ -5674,6 +5686,7 @@ qemuBuildCommandLine(virConnectPtr conn,
  /* We don't add an explicit IDE or FD controller because the
   * provided PIIX4 device already includes one. It isn't possible to
   * remove the PIIX4. */
 +VIR_DOMAIN_CONTROLLER_TYPE_PCI_BRIDGE,
  VIR_DOMAIN_CONTROLLER_TYPE_USB,
  VIR_DOMAIN_CONTROLLER_TYPE_SCSI,
  VIR_DOMAIN_CONTROLLER_TYPE_SATA,
 diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
 index 43774f4..f0181ce 100644
 --- a/tests/qemuhelptest.c
 +++ b/tests/qemuhelptest.c
 @@ -397,7 +397,8 @@ mymain(void)
  QEMU_CAPS_DEVICE_CIRRUS_VGA,
  QEMU_CAPS_DEVICE_VMWARE_SVGA,
  

Re: [libvirt] [PATCH 1/7] Rewrite keycode map to avoid a struct

2013-04-05 Thread Eric Blake
On 04/03/2013 09:06 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 Playing games with field offsets in a struct causes all sorts
 of alignment warnings on ARM platforms
 
 util/virkeycode.c: In function '__virKeycodeValueFromString':
 util/virkeycode.c:26:7: warning: cast increases required alignment of target 
 type [-Wcast-align]
  (*(typeof(field_type) *)((char *)(object) + field_offset))

Wow.  The end result is still properly aligned if object was aligned to
begin with, but the warning is quite appropriate, as the code is hard to
follow.

 
 There is no compelling reason to use a struct for the keycode
 tables. It can easily just use an array of arrays instead,
 avoiding all alignment problems
 
 Signed-off-by: Daniel P. Berrange berra...@redhat.com
 ---
  src/util/virkeycode-mapgen.py |  78 ++---
  src/util/virkeycode.c | 130 
 ++
  2 files changed, 110 insertions(+), 98 deletions(-)

[Fair warning - my python is weak, so I cheated and looked at the
generated C code virkeymaps.h file pre- and post-patch instead - you
basically went from a single table of structs:

-struct keycode virKeycodes[] = {

-{ KEY_RESERVED,NULL,NULL,0,0,0,0,0,0,0,0,0,0},

to multiple tables of one piece of information per table:

+const char *virKeymapNames_linux[] = {
+  KEY_RESERVED,
...
+unsigned short virKeymapValues_linux[] = {
+  0,
]

 +++ b/src/util/virkeycode.c
 @@ -22,51 +22,57 @@
  #include string.h
  #include stddef.h
  
 -#define getfield(object, field_type, field_offset) \
 -(*(typeof(field_type) *)((char *)(object) + field_offset))
 -
 -struct keycode {
 -const char *linux_name;
 -const char *os_x_name;
 -const char *win32_name;
 -unsigned short linux_keycode;
 -unsigned short os_x;
 -unsigned short atset1;
 -unsigned short atset2;
 -unsigned short atset3;
 -unsigned short xt;
 -unsigned short xt_kbd;
 -unsigned short usb;
 -unsigned short win32;
 -unsigned short rfb;
 -};

This maps up with dropping the struct...

  
  #define VIRT_KEY_INTERNAL
  #include virkeymaps.h
  
 -static unsigned int codeOffset[] = {
 +static const char **virKeymapNames[] = {
  [VIR_KEYCODE_SET_LINUX] =
 -offsetof(struct keycode, linux_keycode),
 +  virKeymapNames_linux,

...and this maps up with pointing to the individual table, rather than a
funky offset within the struct at element 0 of the big array.

ACK (once you clean up the nit that Michal pointed out about 'make
syntax-check')

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



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

[libvirt] new libvirt pci controller type and pcie/q35 (was Re: [PATCH 4/7] add pci-bridge controller type)

2013-04-05 Thread Laine Stump
On 04/05/2013 01:38 PM, Daniel P. Berrange wrote:
 On Fri, Apr 05, 2013 at 12:32:04PM -0400, Laine Stump wrote:
 On 04/03/2013 11:50 AM, Ján Tomko wrote:
 From: liguang lig.f...@cn.fujitsu.com

 add a new controller type, then one can
 define a pci-bridge controller like this:
 controller type='pci-bridge' index='0'/
 In the next patch we're prohibiting exactly this config (index='0')
 because the pre-existing pci bus on the pc-* machinetypes is already
 named pci.0. If we don't allow it, we shouldn't include it as an example
 in the commit log :-)
 NB, it isn't always named 'pci.0' - on many arches it is merely 'pci'.

Yeah, I'm just using that as a convenient shorthand. The final decision
on whether to use pci.0 or pci happens down in the qemuBuildCommandline().


 More on this - one of the things this points out is that there is no
 representation in the config of the pci.0 bus, it's just assumed to
 always be there. That is the case for pc-* machinetypes (and probably
 several others with PCI buses), but for q35, there is no pci.0 bus in
 the basic machine, only a pcie.0; if you want a pci.0 on q35 (which
 *will* be necessary in order to attach any pci devices, so I imagine we
 will always want one), you have to attach a pcie-pci bridge, which is
 the device i82801b11-bridge, to pcie.0.
 The reason I bring this up here, is I'm wondering:

 1) should we have some representation of the default pci.0 bus in the
 config, even though it is just always there for the pc machinetypes
 and there is no way to disable it, and nothing on the commandline that
 specifies its existence?
 Yep, we should be aiming for the XML to fully describe the machine
 hardware. So since we're adding the concept of PCI controllers/bridges
 etc to the XML, we should be auto-adding the default bus to the XML.

 2) For the q35 machinetype, should we just always add an
 i82801b11-bridge device and name it pci.0? Or should that need to be
 present in the xml?
 We've been burnt before auto-adding stuff that ought to have
 been optional. So I'd tend towards only having the minimal
 config that is required. If the users want this, let them
 explicitly ask for the bridge

 Also from the apps POV the QEMU device name is irrelevant. The
 XML config works off the PCI addresses. So there's no need
 to force/specialcase a i82801b11-bridge to use the name
 'pci.0'.


Sure. I just mean pci bus 0 (hmm, but actually this does point out a
problem with my logic - the same namespace (well, numbering space) is
used for both pcie and pci buses, so on a q35 system, bus=0 is already
taken by pcie.0; that means that the first pci bus would need to use a
different bus number anyway, so it wouldn't be so easy to switch an
existing domain from pc to q35 - every PCI device would need to have its
bus number modified. I suppose that's reasonable to expect, though.


 3) Most important - depending on the answers to (1) and (2), should we
 maybe name this device pci, and use a different backend depending on
 index and machinetype? (or alternately explicitly specifiable with a
 driver subelement). To be specific, we would have:

controller type='pci' index='0'/

 which on pc machinetypes would just be a placeholder in the config (and
 always inserted if it wasn't there, for machinetypes that have a pci
 bus). On the q35 machinetype, that same line would equate to adding an
 i82801b11-bridge device (with source defaulting to
 bus=pcie.0,addr=1e.0). This would serve several purposes:

 a) on pc machinetypes, it would be a visual aid indicating that pci.0
 exists, and that index='0' isn't available for a new pci controller.

 b) it would make switching a domain config from pc to q35 simpler, since
 pci.0 would always already be in place for attaching pci devices
 (including pci.1, pci.2, etc)

 c) it would make the config a true complete description of the machine
 being created.

 (I've suggested naming the controller pci rather than pci-bridge
 because in the case of a root bus like pci.0 it seems to not be a
 bridge, but maybe the name pci-bridge is always appropriate, even
 when it's a root bus. Maybe someone with better pci/pcie knowledge can
 provide an opinion on this)
 I think pci is a little too generic - how about we call it  'pci-root'

Okay, so a separate pci-root device along with pci-bridge? What I
was really hoping was to have all PCI buses represented in a common way
in the config. How about a controller called pci with different types,
root and bridge? And since they use the same numbering space as pcie
buses, maybe the pcie controllers (including the root and the hubs and
???) would be different types of PCI controllers. That would make it
easier (i.e. *possible*) to avoid collisions in use of bus numbers.

Alex or mst, any advice/opinions on how to represent all the different
q35 devices that consume bus numbers in a succinct fashion?


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

Re: [libvirt] [PATCH 5/7] util: Add helper to get the scsi host name by iterating over sysfs

2013-04-05 Thread John Ferlan
On 03/25/2013 12:43 PM, Osier Yang wrote:
 The helper iterates over sysfs, to find out the matched scsi host
 name by comparing the wwnn,wwpn pair. It will be used by checkPool
 and refreshPool of storage scsi backend. New helper getAdapterName
 is introduced in storage_backend_scsi.c, which uses the new util
 helper virGetFCHostNameByWWN to get the fc_host adapter name.
 ---
  src/libvirt_private.syms   |   1 +
  src/storage/storage_backend_scsi.c |  49 ++---
  src/util/virutil.c | 109 
 +
  src/util/virutil.h |   9 ++-
  4 files changed, 159 insertions(+), 9 deletions(-)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 39c02ad..3df7632 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1854,6 +1854,7 @@ virFindFileInPath;
  virFormatIntDecimal;
  virGetDeviceID;
  virGetDeviceUnprivSGIO;
 +virGetFCHostNameByWWN;
  virGetGroupID;
  virGetGroupName;
  virGetHostname;
 diff --git a/src/storage/storage_backend_scsi.c 
 b/src/storage/storage_backend_scsi.c
 index 1bf6c0b..258c82e 100644
 --- a/src/storage/storage_backend_scsi.c
 +++ b/src/storage/storage_backend_scsi.c
 @@ -603,6 +603,8 @@ getHostNumber(const char *adapter_name,
   */
  if (STRPREFIX(host, scsi_host)) {
  host += strlen(scsi_host);
 +} else if (STRPREFIX(host, fc_host)) {
 +host += strlen(fc_host);

How is this related?  Or even possible?  The number is associated (at
least so far) with the SCSI name parameter which isn't used for FC.
Both callers below still only call here iff it's SCSI_HOST.

  } else if (STRPREFIX(host, host)) {
  host += strlen(host);
  } else {
 @@ -622,42 +624,74 @@ getHostNumber(const char *adapter_name,
  return 0;
  }
  
 +static char *
 +getAdapterName(virStoragePoolSourceAdapter adapter)
 +{
 +char *name = NULL;
 +
 +if (adapter.type != VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST)
 +return strdup(adapter.data.name);
 +
 +if (!(name = virGetFCHostNameByWWN(NULL,
 +   adapter.data.fchost.wwnn,
 +   adapter.data.fchost.wwpn))) {
 +virReportError(VIR_ERR_XML_ERROR,
 +   _(Failed to find SCSI host with wwnn='%s', 
 + wwpn='%s'), adapter.data.fchost.wwnn,
 +   adapter.data.fchost.wwpn);
 +return NULL;

superfluous since name = NULL... :-)

 +}
 +
 +return name;
 +}
 +
  static int
  virStorageBackendSCSICheckPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 virStoragePoolObjPtr pool,
 bool *isActive)
  {
 -char *path;
 +char *path = NULL;
 +char *name = NULL;
  unsigned int host;
 +int ret = -1;
  
  *isActive = false;
  
 -if (getHostNumber(pool-def-source.adapter.data.name, host)  0)
 +if (!(name = getAdapterName(pool-def-source.adapter)))
  return -1;
  
 +if (getHostNumber(name, host)  0)
 +goto cleanup;
 +
  if (virAsprintf(path, /sys/class/scsi_host/host%d, host)  0) {
  virReportOOMError();
 -return -1;
 +goto cleanup;
  }
  
  if (access(path, F_OK) == 0)
  *isActive = true;
  
 +ret = 0;
 +cleanup:
  VIR_FREE(path);
 -
 -return 0;
 +VIR_FREE(name);
 +return ret;
  }
  
  static int
  virStorageBackendSCSIRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
   virStoragePoolObjPtr pool)
  {
 -int ret = -1;
 +char *name = NULL;
  unsigned int host;
 +int ret = -1;
  
  pool-def-allocation = pool-def-capacity = pool-def-available = 0;
  
 -if (getHostNumber(pool-def-source.adapter.data.name, host)  0)
 +if (!(name = getAdapterName(pool-def-source.adapter)))
 +return -1;
 +
 +if (getHostNumber(name, host)  0)
  goto out;
  
  VIR_DEBUG(Scanning host%u, host);
 @@ -669,6 +703,7 @@ virStorageBackendSCSIRefreshPool(virConnectPtr conn 
 ATTRIBUTE_UNUSED,
  
  ret = 0;
  out:
 +VIR_FREE(name);
  return ret;
  }
  
 diff --git a/src/util/virutil.c b/src/util/virutil.c
 index 557225c..a8b9962 100644
 --- a/src/util/virutil.c
 +++ b/src/util/virutil.c
 @@ -26,6 +26,7 @@
  
  #include config.h
  
 +#include dirent.h
  #include stdio.h
  #include stdarg.h
  #include stdlib.h
 @@ -3570,6 +3571,105 @@ cleanup:
  VIR_FREE(operation_path);
  return ret;
  }
 +
 +/* virGetHostNameByWWN:
 + *
 + * Iterate over the sysfs tree to get SCSI host name (e.g. scsi_host5)
 + * by wwnn,wwpn pair.
 + */
 +char *
 +virGetFCHostNameByWWN(const char *sysfs_prefix,
 +  const char *wwnn,
 +  const char *wwpn)
 +{
 +const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH;
 +struct dirent *entry = NULL;
 +DIR *dir = NULL;
 +char *wwnn_path = NULL;
 + 

[libvirt] 1.4.0 memballoon bug?

2013-04-05 Thread Serge Hallyn
Hi,

When I run

virsh -c qemu:///system domxml-to-native qemu-argv /tmp/qatest.xml

from 1.4.0 with the qatest.xml below (which has no memballoon
device specified), I get an 'unspecified error'.  Some printf
debugging shows that virDomainDefParseXML is automatically
adding a virtio memballoon device, but that its
memballoon-info.type is 0, not the 1 or 8 which is required at
qemuBuildMemballoonDevStr().

This didn't happen at 1.2.0, but I'm not sure where the
error was introduced, as I don't see any suspicious changes around
any of the relevant functions.  So I was hoping to send a patch,
but for now I'm just asking for help :)  Anyone know what might
be going on?
 
thanks,
-serge

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


Re: [libvirt] new libvirt pci controller type and pcie/q35 (was Re: [PATCH 4/7] add pci-bridge controller type)

2013-04-05 Thread Alex Williamson
On Fri, 2013-04-05 at 14:42 -0400, Laine Stump wrote:
 On 04/05/2013 01:38 PM, Daniel P. Berrange wrote:
  On Fri, Apr 05, 2013 at 12:32:04PM -0400, Laine Stump wrote:
  On 04/03/2013 11:50 AM, Ján Tomko wrote:
  From: liguang lig.f...@cn.fujitsu.com
 
  add a new controller type, then one can
  define a pci-bridge controller like this:
  controller type='pci-bridge' index='0'/
  In the next patch we're prohibiting exactly this config (index='0')
  because the pre-existing pci bus on the pc-* machinetypes is already
  named pci.0. If we don't allow it, we shouldn't include it as an example
  in the commit log :-)
  NB, it isn't always named 'pci.0' - on many arches it is merely 'pci'.
 
 Yeah, I'm just using that as a convenient shorthand. The final decision
 on whether to use pci.0 or pci happens down in the qemuBuildCommandline().
 
 
  More on this - one of the things this points out is that there is no
  representation in the config of the pci.0 bus, it's just assumed to
  always be there. That is the case for pc-* machinetypes (and probably
  several others with PCI buses), but for q35, there is no pci.0 bus in
  the basic machine, only a pcie.0; if you want a pci.0 on q35 (which
  *will* be necessary in order to attach any pci devices, so I imagine we
  will always want one), you have to attach a pcie-pci bridge, which is
  the device i82801b11-bridge, to pcie.0.
  The reason I bring this up here, is I'm wondering:
 
  1) should we have some representation of the default pci.0 bus in the
  config, even though it is just always there for the pc machinetypes
  and there is no way to disable it, and nothing on the commandline that
  specifies its existence?
  Yep, we should be aiming for the XML to fully describe the machine
  hardware. So since we're adding the concept of PCI controllers/bridges
  etc to the XML, we should be auto-adding the default bus to the XML.
 
  2) For the q35 machinetype, should we just always add an
  i82801b11-bridge device and name it pci.0? Or should that need to be
  present in the xml?
  We've been burnt before auto-adding stuff that ought to have
  been optional. So I'd tend towards only having the minimal
  config that is required. If the users want this, let them
  explicitly ask for the bridge
 
  Also from the apps POV the QEMU device name is irrelevant. The
  XML config works off the PCI addresses. So there's no need
  to force/specialcase a i82801b11-bridge to use the name
  'pci.0'.
 
 
 Sure. I just mean pci bus 0 (hmm, but actually this does point out a
 problem with my logic - the same namespace (well, numbering space) is
 used for both pcie and pci buses, so on a q35 system, bus=0 is already
 taken by pcie.0; that means that the first pci bus would need to use a
 different bus number anyway, so it wouldn't be so easy to switch an
 existing domain from pc to q35 - every PCI device would need to have its
 bus number modified. I suppose that's reasonable to expect, though.

I would think you'd want to differentiate PCI from PCIe anyway.  PCI is
a bus and you have 32 slots per bus to fill.  PCIe is a point-to-point
link and you really only have slot 0 available.  Perhaps that puts them
in different number spaces already.

  3) Most important - depending on the answers to (1) and (2), should we
  maybe name this device pci, and use a different backend depending on
  index and machinetype? (or alternately explicitly specifiable with a
  driver subelement). To be specific, we would have:
 
 controller type='pci' index='0'/
 
  which on pc machinetypes would just be a placeholder in the config (and
  always inserted if it wasn't there, for machinetypes that have a pci
  bus). On the q35 machinetype, that same line would equate to adding an
  i82801b11-bridge device (with source defaulting to
  bus=pcie.0,addr=1e.0). This would serve several purposes:
 
  a) on pc machinetypes, it would be a visual aid indicating that pci.0
  exists, and that index='0' isn't available for a new pci controller.
 
  b) it would make switching a domain config from pc to q35 simpler, since
  pci.0 would always already be in place for attaching pci devices
  (including pci.1, pci.2, etc)
 
  c) it would make the config a true complete description of the machine
  being created.
 
  (I've suggested naming the controller pci rather than pci-bridge
  because in the case of a root bus like pci.0 it seems to not be a
  bridge, but maybe the name pci-bridge is always appropriate, even
  when it's a root bus. Maybe someone with better pci/pcie knowledge can
  provide an opinion on this)
  I think pci is a little too generic - how about we call it  'pci-root'
 
 Okay, so a separate pci-root device along with pci-bridge? What I
 was really hoping was to have all PCI buses represented in a common way
 in the config. How about a controller called pci with different types,
 root and bridge? And since they use the same numbering space as pcie
 buses, maybe the pcie controllers (including the 

  1   2   >