[libvirt] [PATCH] virsh: fix change-media bug on disk block type

2013-07-22 Thread Guannan Ren
Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=923053
When cdrom is block type, the virsh change-media failed to insert
source info because virsh uses source block='/dev/sdb'/ while
the correct name of the attribute for block disks is dev.
---
 tools/virsh-domain.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 606bcdf..8cafce4 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9866,8 +9866,10 @@ vshPrepareDiskXML(xmlNodePtr disk_node,
 
 if (source) {
 new_node = xmlNewNode(NULL, BAD_CAST source);
-xmlNewProp(new_node, (const xmlChar *)disk_type,
-   (const xmlChar *)source);
+if (STREQ(disk_type, block))
+xmlNewProp(new_node, BAD_CAST dev, BAD_CAST source);
+else
+xmlNewProp(new_node, BAD_CAST disk_type, BAD_CAST source);
 xmlAddChild(disk_node, new_node);
 } else if (type == VSH_PREPARE_DISK_XML_INSERT) {
 vshError(NULL, _(No source is specified for inserting 
media));
-- 
1.8.3.1

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


[libvirt] [test-API][PATCH V3] Modify repos/network/network_list.py and add network_list case to conf

2013-07-22 Thread hongming zhang
Modify the old network_list.py. The new network_list.py covers all
flags of listAllNetworks and the following api. and add network_list to
basic_network.conf.
virNetwork:
name()
isActive()
isPersistent()
virConnect:
listAllNetworks()
V1- V2
1.Change the flag in conf from digit to string
2.Remove the checking method using the result of virsh with flags
3.Add checking method via checking network autostart dir
4.Modify the basic_network.conf
V2 - V3
1.Remove check_bridge_ip method
2.Remove network.bridgeName() call
3.Fix a typo in log
---
 cases/basic_network.conf  |   35 +-
 repos/network/network_list.py |  260 -
 2 files changed, 130 insertions(+), 165 deletions(-)

diff --git a/cases/basic_network.conf b/cases/basic_network.conf
index 991ad99..91d7f21 100644
--- a/cases/basic_network.conf
+++ b/cases/basic_network.conf
@@ -14,10 +14,18 @@ network:define
 netmode
 nat
 
+network:network_list
+flags
+   inactive
+
 network:start
 networkname
 $defaultnetname
 
+network:network_list
+flags
+   active
+
 network:autostart
 networkname
$defaultnetname
@@ -28,6 +36,10 @@ network:destroy
 networkname
 $defaultnetname
 
+network:network_list
+flags
+   default
+
 network:undefine
 networkname
 $defaultnetname
@@ -48,6 +60,10 @@ network:create
 netmode
 nat
 
+network:network_list
+flags
+transient
+
 network:destroy
 networkname
 $defaultnetname
@@ -68,6 +84,10 @@ network:define
 netmode
 route
 
+network:network_list
+flags
+   persistent
+
 network:start
 networkname
 $defaultnetname
@@ -106,7 +126,6 @@ network:destroy
 networkname
 $defaultnetname
 
-
 network:define
 networkname
 $defaultnetname
@@ -127,12 +146,20 @@ network:start
 networkname
 $defaultnetname
 
+network:network_list
+flags
+   noautostart
+
 network:autostart
 networkname
 $defaultnetname
 autostart
 enable
 
+network:network_list
+flags
+   autostart
+
 network:destroy
 networkname
 $defaultnetname
@@ -141,7 +168,6 @@ network:undefine
 networkname
 $defaultnetname
 
-
 network:create
 networkname
 $defaultnetname
@@ -162,8 +188,3 @@ network:destroy
 networkname
 $defaultnetname
 
-
-
-
-
-
diff --git a/repos/network/network_list.py b/repos/network/network_list.py
index 7c34f69..b94b505 100644
--- a/repos/network/network_list.py
+++ b/repos/network/network_list.py
@@ -1,184 +1,128 @@
 #!/usr/bin/env python
 # To test virsh net-list command
 
-import os
-import sys
-import re
-import commands
-
 import libvirt
 from libvirt import libvirtError
 
 from src import sharedmod
 from utils import utils
 
-required_params = ('netlistopt',)
+required_params = ('flags',)
 optional_params = {}
 
-VIRSH_QUIET_NETLIST = virsh --quiet net-list %s|awk '{print $1}'
-VIRSH_NETLIST = virsh net-list %s
-GET_BRIDGE_IP = /sbin/ifconfig %s | grep 'inet addr:' | cut -d: -f2 | awk 
'{print $1}'
-CONFIG_DIR = /etc/libvirt/qemu/networks/
+LS_NETWORK_DIR = ls /etc/libvirt/qemu/networks/
+LS_AUTOSTART_NET = ls /etc/libvirt/qemu/networks/autostart/
 
-def get_option_list(params):
-return options we need to test
+def check_persistent_netxml(networkname):
 
-logger = params['logger']
-option_list=[]
-
-value = params['netlistopt']
-
-if value == 'all':
-option_list = [' ', '--all', '--inactive']
-elif value == '--all' or value == '--inactive':
-option_list.append(value)
-else:
-logger.error(value %s is not supported % value)
-return 1, option_list
-
-return 0, option_list
-
-def get_output(logger, command, flag):
-execute shell command
+Check if the network is persistent via checking network xml dir
+if the network is persistent, return True, or return False
 
-status, ret = commands.getstatusoutput(command)
-if not flag and status:
-logger.error(executing + \ +  command  + \ +  failed)
-logger.error(ret)
-return status, ret
-
-def check_all_option(conn, logger):
-check the output of virsh net-list with --all option
-
-all_network = []
-entries = os.listdir(CONFIG_DIR)
-logger.debug(%s in %s % (entries, CONFIG_DIR))
-status, network_names = get_output(logger, VIRSH_QUIET_NETLIST % '--all', 
0)
-if not status:
-all_network = network_names.split('\n')
-logger.info(all network is %s % all_network)
-else:
-return 1
-
-if all_network == ['']:
-return 0
 
-for entry in entries:
-if not entry.endswith('.xml'):
-continue
+(status, output) = utils.exec_cmd(LS_NETWORK_DIR, shell=True)
+network_list_dir = []
+if status:
+logger.error(Executing  + LS_NETWORK_DIR +  failed)
+logger.error(output)
+return False
+else:
+   

Re: [libvirt] [PATCH 1/4] util: Non-existent string array does not contain any string

2013-07-22 Thread Peter Krempa

On 07/19/13 19:00, Jiri Denemark wrote:

Make virStringArrayHasString return false when called on a non-existent
string array.
---
  src/util/virstring.c | 3 +++
  1 file changed, 3 insertions(+)



ACK.

Peter

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


Re: [libvirt] [PATCH 2/4] conf: Make error reporting in virDomainDefFindDevice optional

2013-07-22 Thread Peter Krempa

On 07/19/13 19:00, Jiri Denemark wrote:

---
  src/conf/domain_conf.c  | 11 ---
  src/conf/domain_conf.h  |  3 ++-
  src/qemu/qemu_process.c |  2 +-
  3 files changed, 11 insertions(+), 5 deletions(-)



ACK.

Peter

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


Re: [libvirt] [test-API][PATCH V3] Modify repos/network/network_list.py and add network_list case to conf

2013-07-22 Thread Guannan Ren

On 07/22/2013 03:53 PM, hongming zhang wrote:

Modify the old network_list.py. The new network_list.py covers all
flags of listAllNetworks and the following api. and add network_list to
basic_network.conf.
virNetwork:
name()
isActive()
isPersistent()
virConnect:
listAllNetworks()
V1- V2
1.Change the flag in conf from digit to string
2.Remove the checking method using the result of virsh with flags
3.Add checking method via checking network autostart dir
4.Modify the basic_network.conf
V2 - V3
1.Remove check_bridge_ip method
2.Remove network.bridgeName() call
3.Fix a typo in log
---
  cases/basic_network.conf  |   35 +-
  repos/network/network_list.py |  260 -
  2 files changed, 130 insertions(+), 165 deletions(-)

diff --git a/cases/basic_network.conf b/cases/basic_network.conf
index 991ad99..91d7f21 100644
--- a/cases/basic_network.conf
+++ b/cases/basic_network.conf
@@ -14,10 +14,18 @@ network:define
  netmode
  nat
  
+network:network_list

+flags
+   inactive
+
  network:start
  networkname
  $defaultnetname
  
+network:network_list

+flags
+   active
+
  network:autostart
  networkname
$defaultnetname
@@ -28,6 +36,10 @@ network:destroy
  networkname
  $defaultnetname
  
+network:network_list

+flags
+   default
+
  network:undefine
  networkname
  $defaultnetname
@@ -48,6 +60,10 @@ network:create
  netmode
  nat
  
+network:network_list

+flags
+transient
+
  network:destroy
  networkname
  $defaultnetname
@@ -68,6 +84,10 @@ network:define
  netmode
  route
  
+network:network_list

+flags
+   persistent
+
  network:start
  networkname
  $defaultnetname
@@ -106,7 +126,6 @@ network:destroy
  networkname
  $defaultnetname
  
-

  network:define
  networkname
  $defaultnetname
@@ -127,12 +146,20 @@ network:start
  networkname
  $defaultnetname
  
+network:network_list

+flags
+   noautostart
+
  network:autostart
  networkname
  $defaultnetname
  autostart
  enable
  
+network:network_list

+flags
+   autostart
+
  network:destroy
  networkname
  $defaultnetname
@@ -141,7 +168,6 @@ network:undefine
  networkname
  $defaultnetname
  
-

  network:create
  networkname
  $defaultnetname
@@ -162,8 +188,3 @@ network:destroy
  networkname
  $defaultnetname
  
-

-
-
-
-
diff --git a/repos/network/network_list.py b/repos/network/network_list.py
index 7c34f69..b94b505 100644
--- a/repos/network/network_list.py
+++ b/repos/network/network_list.py
@@ -1,184 +1,128 @@
  #!/usr/bin/env python
  # To test virsh net-list command
  
-import os

-import sys
-import re
-import commands
-
  import libvirt
  from libvirt import libvirtError
  
  from src import sharedmod

  from utils import utils
  
-required_params = ('netlistopt',)

+required_params = ('flags',)
  optional_params = {}
  
-VIRSH_QUIET_NETLIST = virsh --quiet net-list %s|awk '{print $1}'

-VIRSH_NETLIST = virsh net-list %s
-GET_BRIDGE_IP = /sbin/ifconfig %s | grep 'inet addr:' | cut -d: -f2 | awk '{print 
$1}'
-CONFIG_DIR = /etc/libvirt/qemu/networks/
+LS_NETWORK_DIR = ls /etc/libvirt/qemu/networks/
+LS_AUTOSTART_NET = ls /etc/libvirt/qemu/networks/autostart/
  
-def get_option_list(params):

-return options we need to test
+def check_persistent_netxml(networkname):
  
-logger = params['logger']
-option_list=[]
-
-value = params['netlistopt']
-
-if value == 'all':
-option_list = [' ', '--all', '--inactive']
-elif value == '--all' or value == '--inactive':
-option_list.append(value)
-else:
-logger.error(value %s is not supported % value)
-return 1, option_list
-
-return 0, option_list
-
-def get_output(logger, command, flag):
-execute shell command
+Check if the network is persistent via checking network xml dir
+if the network is persistent, return True, or return False
  
-status, ret = commands.getstatusoutput(command)
-if not flag and status:
-logger.error(executing + \ +  command  + \ +  failed)
-logger.error(ret)
-return status, ret
-
-def check_all_option(conn, logger):
-check the output of virsh net-list with --all option
-
-all_network = []
-entries = os.listdir(CONFIG_DIR)
-logger.debug(%s in %s % (entries, CONFIG_DIR))
-status, network_names = get_output(logger, VIRSH_QUIET_NETLIST % '--all', 
0)
-if not status:
-all_network = network_names.split('\n')
-logger.info(all network is %s % all_network)
-else:
-return 1
-
-if all_network == ['']:
-return 0
  
-for entry in entries:

-if not entry.endswith('.xml'):
-continue
+(status, output) = utils.exec_cmd(LS_NETWORK_DIR, shell=True)
+network_list_dir = []
+if 

Re: [libvirt] [PATCH 4/4] qemu: Unplug devices that disappeared when libvirtd was down

2013-07-22 Thread Peter Krempa

On 07/19/13 19:00, Jiri Denemark wrote:

In case libvirtd is asked to unplug a device but the device is actually
unplugged later when libvirtd is not running, we need to detect that and
remove such device when libvirtd starts again and reconnects to running
domains.
---
  src/qemu/qemu_domain.c  | 56 +
  src/qemu/qemu_domain.h  |  4 
  src/qemu/qemu_driver.c  |  6 ++
  src/qemu/qemu_process.c | 43 +
  4 files changed, 109 insertions(+)



...


diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 2f3b141e..9a959d6 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -171,6 +171,7 @@ struct _qemuDomainObjPrivate {

  virCond unplugFinished; /* signals that unpluggingDevice was unplugged */
  const char *unpluggingDevice; /* alias of the device that is being 
unplugged */
+char **qemuDevices; /* NULL-terminated list of devices aliases known to 
QEMU */


s/devices/device/ || s/devices/devices'/


  };

  typedef enum {


ACK.

Peter

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


Re: [libvirt] [PATCH 3/4] qemu: Introduce qemuMonitorGetDeviceAliases

2013-07-22 Thread Peter Krempa

On 07/19/13 19:00, Jiri Denemark wrote:

This API provides a NULL-terminated list of devices which are currently
attached to a QEMU domain.
---
  src/qemu/qemu_monitor.c  | 21 +++
  src/qemu/qemu_monitor.h  |  4 +++
  src/qemu/qemu_monitor_json.c | 38 +++
  src/qemu/qemu_monitor_json.h |  4 +++
  tests/qemumonitorjsontest.c  | 61 
  5 files changed, 128 insertions(+)



ACK.

Peter

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


Re: [libvirt] [PATCH 5/3] vmware: Fix bogus CPU arch copy

2013-07-22 Thread Peter Krempa

On 07/22/13 00:18, Jiri Denemark wrote:

---
  src/vmware/vmware_conf.c | 5 +
  1 file changed, 1 insertion(+), 4 deletions(-)



ACK.

Peter

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


Re: [libvirt] [RFC PATCH] qemu: Shorten SCSI hostdev alias to avoid QEMU failure

2013-07-22 Thread Daniel P. Berrange
On Fri, Jul 12, 2013 at 05:13:56PM +0200, Viktor Mihajlovski wrote:
 The alias for hostdevs of type SCSI can be too long for QEMU if
 larger LUNs are encountered. Here's a real life example:
 
 hostdev mode='subsystem' type='scsi' managed='no'
   source
 adapter name='scsi_host0'/
 address bus='0' target='19' unit='1088634913'/
   /source
   address type='drive' controller='0' bus='0' target='0' unit='0'/
 /hostdev
 
 this results in a too long drive id, resulting in QEMU yelling
 
 Property 'scsi-generic.drive' can't find value 
 'drive-hostdev-scsi_host0-0-19-1088634913'
 
 This commit changes the alias back to the default hostdev$(index)
 scheme.
 
 Signed-off-by: Viktor Mihajlovski mihaj...@linux.vnet.ibm.com
 ---
 
 Actually this is highlighting a larger issue. Apparently QEMU ids
 are limited to a length of 32 bytes. This means that SCSI based
 drives are also in danger to exceed this limit.
 We should consider to use a drive index for controller-attached
 disks for alias generation instead of the verbose
 drive-$bustype-$busaddress schema.

Urgh that sucks. I had no idea QEMU would impose such an arbitrary
length limitation for something like this.

 
  src/qemu/qemu_command.c|   10 +-
  .../qemuxml2argv-hostdev-scsi-boot.args|4 ++--
  .../qemuxml2argv-hostdev-scsi-lsi.args |4 ++--
  .../qemuxml2argv-hostdev-scsi-readonly.args|4 ++--
  .../qemuxml2argv-hostdev-scsi-virtio-scsi.args |4 ++--
  5 files changed, 9 insertions(+), 17 deletions(-)
 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index 879aed8..8c8bef2 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -818,16 +818,8 @@ qemuAssignDeviceHostdevAlias(virDomainDefPtr def, 
 virDomainHostdevDefPtr hostdev
  }
  }
  
 -if (hostdev-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
 -if (virAsprintf(hostdev-info-alias, hostdev-%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)
 -return -1;
 -} else if (virAsprintf(hostdev-info-alias, hostdev%d, idx)  0) {
 +if (virAsprintf(hostdev-info-alias, hostdev%d, idx)  0)
  return -1;
 -}
  
  return 0;
  }

ACK

There's no back compatibility issues, since we store the aliases for running
guests in the state XML. Thus this will only affect newly launched guests

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] cpu_x86: Use x86-specific CPU data structure

2013-07-22 Thread Peter Krempa

On 07/19/13 19:16, Jiri Denemark wrote:

---
  src/cpu/cpu.h |   2 +-
  src/cpu/cpu_x86.c | 271 ++
  2 files changed, 173 insertions(+), 100 deletions(-)



ACK, mostly mechanical.

Peter

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


Re: [libvirt] [PATCH v3 2/7] conf: Introduce new XML tag mode for disk source

2013-07-22 Thread Daniel P. Berrange
On Fri, Jul 19, 2013 at 08:32:28AM -0400, John Ferlan wrote:
 There are two ways to use a iSCSI LUN as disk source for qemu.
 
  * The LUN's path as it shows up on host, e.g.
/dev/disk/by-path/ip-$ip:3260-iscsi-$iqn-fc18:iscsi.iscsi0-lun-1
 
  * The libiscsi URI from the storage pool source element host attribute, e.g.
iscsi://demo.org:6000/iqn.1992-01.com.example/1
 
 For a volume type disk, if the specified pool is of iscsi
 type, we should support to use the LUN in either of above 2 ways.
 That's why to introduce a new XML tag mode for the disk source
 (libvirt should support iscsi pool with libiscsi, but it's another
 new feature, which should be done later).
 
 The mode can be either of host or direct. Use host to indicate
 use of the LUN with the path as it shows up on host. Use direct to
 indicate to use it with the source pool host URI (future patches may support
 to use network type libvirt storage too, e.g. Ceph)
 ---
  docs/formatdomain.html.in  | 11 -
  docs/schemas/domaincommon.rng  |  8 
  src/conf/domain_conf.c | 22 +-
  src/conf/domain_conf.h | 22 ++
  .../qemuxml2argv-disk-source-pool-mode.xml | 48 
 ++
  tests/qemuxml2xmltest.c|  1 +
  6 files changed, 110 insertions(+), 2 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml

ACK

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

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


Re: [libvirt] [PATCH v3 3/7] conf: Introduce virDomainDiskSourceIsBlockType

2013-07-22 Thread Daniel P. Berrange
On Fri, Jul 19, 2013 at 08:32:29AM -0400, John Ferlan wrote:
 Introduce a new helper to check if the disk source is of block type
 ---
  src/conf/domain_conf.c   | 32 
  src/conf/domain_conf.h   |  3 +++
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_command.c  |  5 ++---
  src/qemu/qemu_conf.c | 23 +--
  5 files changed, 43 insertions(+), 21 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 2/3] Replace union cpuData with virCPUData

2013-07-22 Thread Peter Krempa

On 07/19/13 19:16, Jiri Denemark wrote:

---
  src/cpu/cpu.c| 22 +--
  src/cpu/cpu.h| 51 ++--
  src/cpu/cpu_arm.c|  8 +++
  src/cpu/cpu_powerpc.c|  8 +++
  src/cpu/cpu_s390.c   |  8 +++
  src/cpu/cpu_x86.c| 30 +-
  src/qemu/qemu_capabilities.c |  2 +-
  src/qemu/qemu_command.c  |  4 ++--
  src/vmware/vmware_conf.c |  2 +-
  tests/cputest.c  |  4 ++--
  10 files changed, 70 insertions(+), 69 deletions(-)



ACK. Mechanical.

Peter

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


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

2013-07-22 Thread Daniel P. Berrange
On Fri, Jul 19, 2013 at 03:56:05PM +0200, Manuel VIVES wrote:
 ---
  src/libvirt_private.syms |1 +
  src/util/virstring.c |  129 
 ++
  src/util/virstring.h |6 +++
  3 files changed, 136 insertions(+)
 
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 57a1b50..65e85d4 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1901,6 +1901,7 @@ virStringListLength;
  virStringSplit;
  virStrncpy;
  virStrndup;
 +virStrReplace;
  virStrToDouble;
  virStrToLong_i;
  virStrToLong_l;
 diff --git a/src/util/virstring.c b/src/util/virstring.c
 index 1f4850e..81a3a4d 100644
 --- a/src/util/virstring.c
 +++ b/src/util/virstring.c
 @@ -613,3 +613,132 @@ size_t virStringListLength(char **strings)
  
  return i;
  }
 +
 +/*
 + virStrReplace(haystack, haystacksize, oldneedle, newneedle) --
 +  Search haystack and replace all occurences of oldneedle with newneedle.
 +  Resulting haystack contains no more than haystacksize characters 
 (including the '\0').
 +  If haystacksize is too small to make the replacements, do not modify 
 haystack at all.
 +
 + RETURN VALUES
 + virStrReplace() returns haystack on success and NULL on failure.
 + Failure means there was not enough room to replace all occurences of 
 oldneedle.
 + Success is returned otherwise, even if no replacement is made.
 +Methods found here: http://stackoverflow.com/a/12546318, author: Brandin

NACK, you can't copy code from stackoverflow.com into libvirt. The stackoverflow
user contributions are creative-commons-by-sa licensed, which is not compatible
with Libvirt LGPLv2 license.

From the stackoverflow.com page footer:

  site design / logo © 2013 stack exchange inc; user contributions licensed
   under cc-wiki with attribution required (Links to cc-by-sa license)

From gnu.org

  http://www.gnu.org/licenses/license-list.html#NonFreeDocumentationLicenses

  Creative Commons Attribution-Sharealike 2.0 license (a.k.a. CC BY-SA) 
(#ccbysa)

   This is a copyleft free license that is good for artistic and entertainment
   works, and educational works. Please don't use it for software or
   documentation, since it is incompatible with the GNU GPL and with the GNU
   FDL.

Please throw away this code  write a new implementation from scratch
*without referencing* this stackoverflow code at all.

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 v3 4/7] qemu: Translate the iscsi pool/volume disk source

2013-07-22 Thread Osier Yang

On 19/07/13 20:32, John Ferlan wrote:

The difference with already supported pool types (dir, fs, block)
is: there are two modes for iscsi pool (or network pools in future),
one can specify it either to use the volume target path (the path
showed up on host) with mode='host', or to use the remote URI qemu
supports (e.g. file=iscsi://example.org:6000/iqn.1992-01.com.example/1)
with mode='direct'.

For 'host' mode, it copies the volume target path into disk-src. For
'direct' mode, the corresponding info in the *one* pool source host def
is copied to disk-hosts[0].
---
  src/conf/domain_conf.c  |   8 
  src/conf/domain_conf.h  |   1 +
  src/qemu/qemu_command.c |  15 ++-
  src/qemu/qemu_conf.c| 101 +++-
  4 files changed, 123 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 55d..231edb5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18403,6 +18403,14 @@ virDomainDiskSourceIsBlockType(virDomainDiskDefPtr def)
   */
  if (def-type == VIR_DOMAIN_DISK_TYPE_VOLUME  def-srcpool 
  def-srcpool-voltype == VIR_STORAGE_VOL_BLOCK) {
+/* We don't think the volume accessed by remote URI is
+ * block type source, since we can't/shouldn't manage it
+ * (e.g. set sgio=filtered|unfiltered for it) in libvirt.
+ */
+ if (def-srcpool-pooltype == VIR_STORAGE_POOL_ISCSI 
+ def-srcpool-mode == VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT)
+ return false;
+
  return true;
  }
  return false;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4db981d..327f3f9 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -677,6 +677,7 @@ struct _virDomainDiskSourcePoolDef {
  char *pool; /* pool name */
  char *volume; /* volume name */
  int voltype; /* enum virStorageVolType, internal only */
+int pooltype; /* enum virStoragePoolType, internal only */
  int mode; /* enum virDomainDiskSourcePoolMode */
  };
  typedef virDomainDiskSourcePoolDef *virDomainDiskSourcePoolDefPtr;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5265f77..4e4ee9e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3214,7 +3214,20 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
   block type volume));
  goto error;
  }
-virBufferEscape(opt, ',', ,, file=%s,, disk-src);
+
+if (disk-srcpool-pooltype == VIR_STORAGE_POOL_ISCSI) {
+if (disk-srcpool-mode ==
+VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT) {
+if (qemuBuildISCSIString(conn, disk, opt)  0)
+goto error;
+virBufferAddChar(opt, ',');
+} else if (disk-srcpool-mode ==
+   VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST) {
+virBufferEscape(opt, ',', ,, file=%s,, disk-src);
+}
+} else {
+virBufferEscape(opt, ',', ,, file=%s,, disk-src);
+}
  break;
  case VIR_STORAGE_VOL_FILE:
  virBufferEscape(opt, ',', ,, file=%s,, disk-src);
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 332b9f2..6e6163f 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1125,12 +1125,75 @@ int qemuDriverAllocateID(virQEMUDriverPtr driver)
  return virAtomicIntInc(driver-nextvmid);
  }
  
+static int

+qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
+   virStoragePoolDefPtr pooldef)


nice abstraction. it's good other network pools' support in future.


+{
+int ret = -1;
+char **tokens = NULL;
+
+/* Only support one host */
+if (pooldef-source.nhost != 1) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Expected exactly 1 host for the storage pool));
+goto cleanup;
+}
+
+/* iscsi pool only supports one host */
+def-nhosts = 1;
+
+if (VIR_ALLOC_N(def-hosts, def-nhosts)  0)
+goto cleanup;
+
+if (VIR_STRDUP(def-hosts[0].name, pooldef-source.hosts[0].name)  0)
+goto cleanup;
+
+if (virAsprintf(def-hosts[0].port, %d,
+pooldef-source.hosts[0].port ?
+pooldef-source.hosts[0].port :
+3260)  0)
+goto cleanup;
+
+/* iscsi volume has name like unit:0:0:1 */
+if (!(tokens = virStringSplit(def-srcpool-volume, :, 0)))
+goto cleanup;
+
+if (virStringListLength(tokens) != 4) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected iscsi volume name '%s'),
+   def-srcpool-volume);
+goto cleanup;
+}
+
+/* iscsi pool has only one source device path */

Re: [libvirt] [PATCH 4/3] Remove arch parameter from cpuHasFeature()

2013-07-22 Thread Peter Krempa

On 07/22/13 00:18, Jiri Denemark wrote:

---
This patch should be squashed in 3/3.



ACK.

Peter

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


Re: [libvirt] [PATCH 3/3] cpu: Store arch in virCPUData

2013-07-22 Thread Peter Krempa

On 07/19/13 19:16, Jiri Denemark wrote:

---
  src/cpu/cpu.c| 11 +--
  src/cpu/cpu.h| 19 +++
  src/cpu/cpu_powerpc.c|  4 ++--
  src/cpu/cpu_x86.c| 34 --
  src/qemu/qemu_capabilities.c |  2 +-
  src/qemu/qemu_command.c  |  5 ++---
  src/vmware/vmware_conf.c |  3 +--
  tests/cputest.c  |  6 ++
  8 files changed, 44 insertions(+), 40 deletions(-)



ACK.

Peter

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


[libvirt] [PATCH] libxl: Correctly initialize vcpu bitmap

2013-07-22 Thread Stefan Bader
This fixes the basic setup but there is likely more to do if things
like manual CPU hirarchy (nodes, cores, threads) to be working.

Cross-posting to xen-devel to make sure I am doing things correctly.

-Stefan


From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001
From: Stefan Bader stefan.ba...@canonical.com
Date: Fri, 19 Jul 2013 15:20:00 +0200
Subject: [PATCH] libxl: Correctly initialize vcpu bitmap

The avai_vcpu bitmap has to be allocated before it can be used (using
the maximum allowed value for that). Then for each available VCPU the
bit in the mask has to be set (libxl_bitmap_set takes a bit position
as an argument, not the number of bits to set).

Without this, I would always only get one VCPU for guests created
through libvirt/libxl.

Signed-off-by: Stefan Bader stefan.ba...@canonical.com
---
 src/libxl/libxl_conf.c |   14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 4a0fba9..7592dd2 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -331,7 +331,8 @@ error:
 }
 
 static int
-libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
+libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
+  libxl_domain_config *d_config)
 {
 libxl_domain_build_info *b_info = d_config-b_info;
 int hvm = STREQ(def-os.type, hvm);
@@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, 
libxl_domain_config *d_config)
 libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
 else
 libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
+
 b_info-max_vcpus = def-maxvcpus;
-libxl_bitmap_set((b_info-avail_vcpus), def-vcpus);
+if (libxl_cpu_bitmap_alloc(driver-ctx, b_info-avail_vcpus,
+   def-maxvcpus))
+goto error;
+libxl_bitmap_set_none(b_info-avail_vcpus);
+for (i = 0; i  def-vcpus; i++)
+libxl_bitmap_set((b_info-avail_vcpus), i);
+
 if (def-clock.ntimers  0 
 def-clock.timers[0]-name == VIR_DOMAIN_TIMER_NAME_TSC) {
 switch (def-clock.timers[0]-mode) {
@@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
 if (libxlMakeDomCreateInfo(driver, def, d_config-c_info)  0)
 return -1;
 
-if (libxlMakeDomBuildInfo(def, d_config)  0) {
+if (libxlMakeDomBuildInfo(driver, def, d_config)  0) {
 return -1;
 }
 
-- 
1.7.9.5

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


Re: [libvirt] [PATCH v3 5/7] tests: Add various network and volume definitions

2013-07-22 Thread Osier Yang

On 19/07/13 20:32, John Ferlan wrote:

Although they produce no seclabel data, add some tests for coverage of
various network and volume disk definitions
---
  tests/securityselinuxlabeldata/netdisks.txt |  5 +++
  tests/securityselinuxlabeldata/netdisks.xml | 58 +
  tests/securityselinuxlabeldata/voldisks.txt |  5 +++
  tests/securityselinuxlabeldata/voldisks.xml | 45 ++
  tests/securityselinuxlabeltest.c|  2 +
  5 files changed, 115 insertions(+)
  create mode 100644 tests/securityselinuxlabeldata/netdisks.txt
  create mode 100644 tests/securityselinuxlabeldata/netdisks.xml
  create mode 100644 tests/securityselinuxlabeldata/voldisks.txt
  create mode 100644 tests/securityselinuxlabeldata/voldisks.xml

diff --git a/tests/securityselinuxlabeldata/netdisks.txt 
b/tests/securityselinuxlabeldata/netdisks.txt
new file mode 100644
index 000..b6bf95f
--- /dev/null
+++ b/tests/securityselinuxlabeldata/netdisks.txt
@@ -0,0 +1,5 @@
+/nbd.raw;
+/iscsi.raw;
+/rbd.raw;
+/sheepdog.raw;
+/gluster.raw;
diff --git a/tests/securityselinuxlabeldata/netdisks.xml 
b/tests/securityselinuxlabeldata/netdisks.xml
new file mode 100644
index 000..ab5e964
--- /dev/null
+++ b/tests/securityselinuxlabeldata/netdisks.xml
@@ -0,0 +1,58 @@
+domain type='kvm'
+  namevm1/name
+  uuidc7b3edbd-edaf-9455-926a-d65c16db1800/uuid
+  memory unit='KiB'219200/memory
+  os
+type arch='i686' machine='pc-1.0'hvm/type
+boot dev='cdrom'/
+  /os
+  devices
+  disk type='network' device='disk'
+driver name='qemu' type='raw'/
+source protocol='nbd' file=/nbd.raw
+  host name='example.org' port='6000'/
+/source
+  target dev='vda' bus='virtio'/
+/disk
+disk type='network' device='disk'
+  driver name='qemu' type='raw'/
+  source protocol='iscsi' name='iqn.1992-01.com.example/1' 
file=/iscsi.raw


i'm not clear with the security tests, but this xml looks incorrect.  
file is one
way to represent the disk source, it's exclusive with other ways (e.g. 
protocol/name
here) in semantics. similar for below. why do you use both file and 
other ways

for disk source represention together?


+host name='example.org' port='6000'/
+  /source
+  target dev='vdb' bus='virtio'/
+/disk
+disk type='network'
+  driver name=qemu type=raw/
+  source protocol=rbd name=image_name2 file=/rbd.raw
+  host name=hostname port=7000/
+  /source
+  target dev=hdb bus=ide/
+  auth username='myuser'
+secret type='ceph' usage='mypassid'/
+  /auth
+/disk
+disk type='network'
+  driver name=qemu type=raw/
+  source protocol=sheepdog name=image_name file=/sheepdog.raw
+  host name=hostname port=7000/
+  /source
+  target dev=hdb bus=ide/
+/disk
+disk type='network' device='disk'
+  driver name='qemu' type='raw'/
+  source protocol='gluster' name='Volume/Image' file='/gluster.raw'
+host name='example.org' port='6000' transport='tcp'/
+  /source
+  target dev='vda' bus='virtio'/
+/disk
+
+input type='mouse' bus='ps2'/
+graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'
+  listen type='address' address='0.0.0.0'/
+/graphics
+  /devices
+  seclabel model=selinux type=dynamic relabel=yes
+labelsystem_u:system_r:svirt_t:s0:c41,c264/label
+imagelabelsystem_u:object_r:svirt_image_t:s0:c41,c264/imagelabel
+  /seclabel
+/domain
diff --git a/tests/securityselinuxlabeldata/voldisks.txt 
b/tests/securityselinuxlabeldata/voldisks.txt
new file mode 100644
index 000..bd5d755
--- /dev/null
+++ b/tests/securityselinuxlabeldata/voldisks.txt
@@ -0,0 +1,5 @@
+/file.raw;
+/disk.raw;
+/host.raw;
+/direct.raw;
+/cdrom.raw;
diff --git a/tests/securityselinuxlabeldata/voldisks.xml 
b/tests/securityselinuxlabeldata/voldisks.xml
new file mode 100644
index 000..ae7e629
--- /dev/null
+++ b/tests/securityselinuxlabeldata/voldisks.xml
@@ -0,0 +1,45 @@
+domain type='kvm'
+  namevm1/name
+  uuidc7b3edbd-edaf-9455-926a-d65c16db1800/uuid
+  memory unit='KiB'219200/memory
+  os
+type arch='i686' machine='pc-1.0'hvm/type
+boot dev='cdrom'/
+  /os
+  devices
+disk type='volume' device='disk'
+  driver name='qemu' type='raw'/
+  source pool='dir-pool0' volume='dir-pool0-vol0' file='/file.raw'/
+  target dev='hda' bus='ide'/
+/disk
+disk type='volume' device='disk'
+  driver name='qemu' type='raw'/
+  source pool='dir-pool0' volume='dir-pool0-vol0' mode='host' 
file='/host.raw'/
+  target dev='hda' bus='ide'/
+/disk
+disk type='volume' device='disk'
+  driver name='qemu' type='raw'/
+  source pool='dir-pool0' volume='dir-pool0-vol0' mode='direct' 
file='/direct.raw'/
+  target dev='hda' bus='ide'/
+/disk
+disk type='volume' device='disk'
+  driver name='qemu' type='raw'/
+  source pool='blk-pool0' volume='blk-pool0-vol0' file='/plain.raw'/
+  

Re: [libvirt] [PATCH v3 6/7] conf: Ignore the volume type disk if its mode is direct

2013-07-22 Thread Osier Yang

On 19/07/13 20:32, John Ferlan wrote:

From: Osier Yang jy...@redhat.com

virDomainDiskDefForeachPath is not only used by the security
setting helpers, also used by cgroup setting helpers, so this
is to ignore the volume type disk with mode=direct for cgroup
setting.
---
  src/conf/domain_conf.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 231edb5..770b7cc 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17533,7 +17533,10 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
  size_t depth = 0;
  virStorageFileMetadata *tmp;
  
-if (!disk-src || disk-type == VIR_DOMAIN_DISK_TYPE_NETWORK)

+if (!disk-src || disk-type == VIR_DOMAIN_DISK_TYPE_NETWORK ||
+(disk-type == VIR_DOMAIN_DISK_TYPE_VOLUME 
+ disk-srcpool 
+ disk-srcpool-mode == VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT))
  return 0;
  
  if (iter(disk, disk-src, 0, opaque)  0)

ack

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


[libvirt] [PATCH] bridge driver: s/network_driver/virNetworkDriverState/

2013-07-22 Thread Roman Bogorodskiy
This is another cleanup before extracting platform-specific
parts from bridge_driver.

Rename struct network_driver to _virNetworkDriverState and
add appropriate typedefs: virNetworkDriverState and
virNetworkDriverStatePtr.

This will help us to avoid potential problems when moving
this struct to the .h file.
---
 src/network/bridge_driver.c | 110 ++--
 1 file changed, 56 insertions(+), 54 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index a7ff602..8b50659 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -70,7 +70,7 @@
 #define VIR_FROM_THIS VIR_FROM_NETWORK
 
 /* Main driver state */
-struct network_driver {
+struct _virNetworkDriverState {
 virMutex lock;
 
 virNetworkObjList networks;
@@ -84,45 +84,47 @@ struct network_driver {
 dnsmasqCapsPtr dnsmasqCaps;
 };
 
+typedef struct _virNetworkDriverState virNetworkDriverState;
+typedef virNetworkDriverState *virNetworkDriverStatePtr;
 
-static void networkDriverLock(struct network_driver *driver)
+static void networkDriverLock(virNetworkDriverStatePtr driver)
 {
 virMutexLock(driver-lock);
 }
-static void networkDriverUnlock(struct network_driver *driver)
+static void networkDriverUnlock(virNetworkDriverStatePtr driver)
 {
 virMutexUnlock(driver-lock);
 }
 
 static int networkStateCleanup(void);
 
-static int networkStartNetwork(struct network_driver *driver,
+static int networkStartNetwork(virNetworkDriverStatePtr driver,
virNetworkObjPtr network);
 
-static int networkShutdownNetwork(struct network_driver *driver,
+static int networkShutdownNetwork(virNetworkDriverStatePtr driver,
   virNetworkObjPtr network);
 
-static int networkStartNetworkVirtual(struct network_driver *driver,
+static int networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
  virNetworkObjPtr network);
 
-static int networkShutdownNetworkVirtual(struct network_driver *driver,
+static int networkShutdownNetworkVirtual(virNetworkDriverStatePtr driver,
  virNetworkObjPtr network);
 
-static int networkStartNetworkExternal(struct network_driver *driver,
+static int networkStartNetworkExternal(virNetworkDriverStatePtr driver,
  virNetworkObjPtr network);
 
-static int networkShutdownNetworkExternal(struct network_driver *driver,
+static int networkShutdownNetworkExternal(virNetworkDriverStatePtr driver,
 virNetworkObjPtr network);
 
-static void networkReloadIptablesRules(struct network_driver *driver);
-static void networkRefreshDaemons(struct network_driver *driver);
+static void networkReloadIptablesRules(virNetworkDriverStatePtr driver);
+static void networkRefreshDaemons(virNetworkDriverStatePtr driver);
 
 static int networkPlugBandwidth(virNetworkObjPtr net,
 virDomainNetDefPtr iface);
 static int networkUnplugBandwidth(virNetworkObjPtr net,
   virDomainNetDefPtr iface);
 
-static struct network_driver *driverState = NULL;
+static virNetworkDriverStatePtr driverState = NULL;
 
 static char *
 networkDnsmasqLeaseFileNameDefault(const char *netname)
@@ -169,7 +171,7 @@ networkRadvdConfigFileName(const char *netname)
 
 /* do needed cleanup steps and remove the network from the list */
 static int
-networkRemoveInactive(struct network_driver *driver,
+networkRemoveInactive(virNetworkDriverStatePtr driver,
   virNetworkObjPtr net)
 {
 char *leasefile = NULL;
@@ -256,7 +258,7 @@ networkBridgeDummyNicName(const char *brname)
 }
 
 static void
-networkFindActiveConfigs(struct network_driver *driver)
+networkFindActiveConfigs(virNetworkDriverStatePtr driver)
 {
 size_t i;
 
@@ -308,7 +310,7 @@ networkFindActiveConfigs(struct network_driver *driver)
 
 
 static void
-networkAutostartConfigs(struct network_driver *driver) {
+networkAutostartConfigs(virNetworkDriverStatePtr driver) {
 size_t i;
 
 for (i = 0; i  driver-networks.count; i++) {
@@ -327,7 +329,7 @@ networkAutostartConfigs(struct network_driver *driver) {
 static DBusHandlerResult
 firewalld_dbus_filter_bridge(DBusConnection *connection ATTRIBUTE_UNUSED,
  DBusMessage *message, void *user_data) {
-struct network_driver *_driverState = user_data;
+virNetworkDriverStatePtr _driverState = user_data;
 
 if (dbus_message_is_signal(message, DBUS_INTERFACE_DBUS,
NameOwnerChanged) ||
@@ -1025,7 +1027,7 @@ cleanup:
 }
 
 static int
-networkStartDhcpDaemon(struct network_driver *driver,
+networkStartDhcpDaemon(virNetworkDriverStatePtr driver,
virNetworkObjPtr network)
 {
 virCommandPtr cmd = NULL;
@@ -1112,7 +1114,7 @@ cleanup:
  *  Returns 0 on success, -1 on failure.
  */
 static int

Re: [libvirt] [PATCH v3 7/7] qemu: Translate the volume type disk source before cgroup setting

2013-07-22 Thread Osier Yang

On 19/07/13 20:32, John Ferlan wrote:

From: Osier Yang jy...@redhat.com

The translation must be done before both of cgroup and security
setting, otherwise since the disk source is not translated yet,
it might be skipped on cgroup and security setting.
---
  src/qemu/qemu_process.c | 13 -
  1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ef81536..d7deb0f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3627,6 +3627,14 @@ int qemuProcessStart(virConnectPtr conn,
  }
  hookData.nodemask = nodemask;
  
+/* volume type disk's source must be translated before

+ * cgroup and security setting.
+ */
+for (i = 0; i  vm-def-ndisks; i++) {
+if (qemuTranslateDiskSourcePool(conn, vm-def-disks[i])  0)
+goto cleanup;
+}
+
  VIR_DEBUG(Setting up domain cgroup (if required));
  if (qemuSetupCgroup(driver, vm, nodemask)  0)
  goto cleanup;
@@ -3671,11 +3679,6 @@ int qemuProcessStart(virConnectPtr conn,
  goto cleanup;
  }
  
-for (i = 0; i  vm-def-ndisks; i++) {

-if (qemuTranslateDiskSourcePool(conn, vm-def-disks[i])  0)
-goto cleanup;
-}
-
  VIR_DEBUG(Building emulator command line);
  if (!(cmd = qemuBuildCommandLine(conn, driver, vm-def, priv-monConfig,
   priv-monJSON, priv-qemuCaps,

ack, a bit strange to ack my own patch though. may need to wait for a
second ack from others.


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


Re: [libvirt] [PATCH 4/4] qemu: Unplug devices that disappeared when libvirtd was down

2013-07-22 Thread Jiri Denemark
On Mon, Jul 22, 2013 at 11:13:30 +0200, Peter Krempa wrote:
 On 07/19/13 19:00, Jiri Denemark wrote:
  In case libvirtd is asked to unplug a device but the device is actually
  unplugged later when libvirtd is not running, we need to detect that and
  remove such device when libvirtd starts again and reconnects to running
  domains.
  ---
src/qemu/qemu_domain.c  | 56 
  +
src/qemu/qemu_domain.h  |  4 
src/qemu/qemu_driver.c  |  6 ++
src/qemu/qemu_process.c | 43 +
4 files changed, 109 insertions(+)
 
 
 ...
 
  diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
  index 2f3b141e..9a959d6 100644
  --- a/src/qemu/qemu_domain.h
  +++ b/src/qemu/qemu_domain.h
  @@ -171,6 +171,7 @@ struct _qemuDomainObjPrivate {
 
virCond unplugFinished; /* signals that unpluggingDevice was 
  unplugged */
const char *unpluggingDevice; /* alias of the device that is being 
  unplugged */
  +char **qemuDevices; /* NULL-terminated list of devices aliases known 
  to QEMU */
 
 s/devices/device/ || s/devices/devices'/
 
};
 
typedef enum {
 
 ACK.

Oops, I pushed the series but forgot to do this change :-/ Anyway,
thanks for the reivew.

Jirka

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


Re: [libvirt] [PATCH] Split up platfrom specifics from bridge driver

2013-07-22 Thread Roman Bogorodskiy
  Eric Blake wrote:

 On 07/18/2013 03:23 AM, Daniel P. Berrange wrote:
  On Wed, Jul 17, 2013 at 05:41:56PM -0600, Eric Blake wrote:
  So, although I like the split, I can't help but wonder if your rebase
  should take the road of adjusting things to use a callback struct,
  rather than requiring matching implementations across multiple files.
  
  I think the callback struct approach is useful for the case where you
  have multiple possible implementations compiled in at once and we need
  to choose them dynamically. Here though, we're making the choice at
  compile time, so I think callback + dynamic dispatch is somewhat overkill.
  
  Following of the virthread approach of #include'ing .c file was my
  suggestion to Roman for how to structure this.
 
 Fair enough.  It just means that we don't have the compiler helping us
 remember to add both functions at once, so it raises the probability
 that someone will add a Linux-only function and forget to add the noop
 counterpart.  But as long as we detect it before a release (that's what
 release candidate testing is for, right?) we should be okay.
 
 Roman, I'll accept your code with the .c inclusion, so you don't have to
 do the extra work of a dynamic dispatch rewrite; now it's just waiting
 for a rebased patch.

That sounds good, thanks.

I have started with renaming of 'struct network_driver' (patch is
already on the list). When done with this patch, I'll do 'Iptables' -
'Firewall' rename and then finally will rebase this split patch.

Roman Bogorodskiy


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

Re: [libvirt] [PATCH] cpu: Let explicit features override model features

2013-07-22 Thread Peter Krempa

On 07/21/13 14:37, Jiri Denemark wrote:

Until now CPU features inherited from a specified CPU model could only
be overridden with 'disable' policy. With this patch, any explicitly
specified feature always overrides the same feature inherited from a CPU
model regardless on the specified policy.

The CPU in x86-exact-force-Haswell.xml would previously be incompatible
with x86-host-SandyBridge.xml CPU even though x86-host-SandyBridge.xml
provides all features required by x86-exact-force-Haswell.xml.
---
  src/cpu/cpu_x86.c |  5 +
  tests/cputest.c   |  1 +
  tests/cputestdata/x86-exact-force-Haswell.xml | 15 +++
  tests/cputestdata/x86-host-SandyBridge.xml|  6 ++
  4 files changed, 27 insertions(+)
  create mode 100644 tests/cputestdata/x86-exact-force-Haswell.xml
  create mode 100644 tests/cputestdata/x86-host-SandyBridge.xml



ACK.

Peter

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


Re: [libvirt] [PATCH 5/3] vmware: Fix bogus CPU arch copy

2013-07-22 Thread Jiri Denemark
On Mon, Jul 22, 2013 at 11:30:33 +0200, Peter Krempa wrote:
 On 07/22/13 00:18, Jiri Denemark wrote:
  ---
src/vmware/vmware_conf.c | 5 +
1 file changed, 1 insertion(+), 4 deletions(-)
 
 
 ACK.

Thanks, I pushed this series.

Jirka

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


Re: [libvirt] [PATCH] cpu: Let explicit features override model features

2013-07-22 Thread Jiri Denemark
On Mon, Jul 22, 2013 at 13:41:44 +0200, Peter Krempa wrote:
 On 07/21/13 14:37, Jiri Denemark wrote:
  Until now CPU features inherited from a specified CPU model could only
  be overridden with 'disable' policy. With this patch, any explicitly
  specified feature always overrides the same feature inherited from a CPU
  model regardless on the specified policy.
 
  The CPU in x86-exact-force-Haswell.xml would previously be incompatible
  with x86-host-SandyBridge.xml CPU even though x86-host-SandyBridge.xml
  provides all features required by x86-exact-force-Haswell.xml.
  ---
src/cpu/cpu_x86.c |  5 +
tests/cputest.c   |  1 +
tests/cputestdata/x86-exact-force-Haswell.xml | 15 +++
tests/cputestdata/x86-host-SandyBridge.xml|  6 ++
4 files changed, 27 insertions(+)
create mode 100644 tests/cputestdata/x86-exact-force-Haswell.xml
create mode 100644 tests/cputestdata/x86-host-SandyBridge.xml
 
 
 ACK.

Pushed, thanks.

Jirka

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


[libvirt] [PATCH] doc: Fix copy-paste-error in virNodeGetMemoryStats

2013-07-22 Thread Philipp Hahn
The description seems to be copied from virNodeGetCpuState.
Change wrong 'cpu' to 'memory'.

Signed-off-by: Philipp Hahn h...@univention.de
---
 src/libvirt.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index bc1694a..12f9c41 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -7521,7 +7521,7 @@ error:
  * @flags: extra flags; not used yet, so callers should always pass 0
  *
  * This function provides memory stats of the node.
- * If you want to get total cpu statistics of the node, you must specify
+ * If you want to get total memory statistics of the node, you must specify
  * VIR_NODE_MEMORY_STATS_ALL_CELLS to @cellNum.
  * The @params array will be filled with the values equal to the number of
  * stats suggested by @nparams
-- 
1.7.10.4

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


Re: [libvirt] [PATCH 2/2] Add API for calling systemd-machined's DBus API

2013-07-22 Thread Daniel P. Berrange
On Thu, Jul 18, 2013 at 05:11:45PM -0600, Eric Blake wrote:
 Ah, this hunk probably belongs in 1/2.  In fact, it fixes compilation,
 so I was able to run 'make check', but the test from 1/2 fails:
 
 TEST: virdbustest
   Failed to round-trip byte '0' to '200'
 !..Failed to round-trip byte '0' to '200'
 !.5   FAIL

This turned out to be caused by the use of the 'bool' type. This is
not the same size as dbus_bool_t which is defined to be same as an
int. So I changed the test to use a plain int


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] bridge driver: s/network_driver/virNetworkDriverState/

2013-07-22 Thread Michal Privoznik
On 22.07.2013 13:08, Roman Bogorodskiy wrote:
 This is another cleanup before extracting platform-specific
 parts from bridge_driver.
 
 Rename struct network_driver to _virNetworkDriverState and
 add appropriate typedefs: virNetworkDriverState and
 virNetworkDriverStatePtr.
 
 This will help us to avoid potential problems when moving
 this struct to the .h file.
 ---
  src/network/bridge_driver.c | 110 
 ++--
  1 file changed, 56 insertions(+), 54 deletions(-)

ACked and pushed.

Michal

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


Re: [libvirt] [PATCH] Make locking more debuggable from logs

2013-07-22 Thread Daniel P. Berrange
On Mon, Jul 22, 2013 at 03:44:04PM +0200, Martin Kletzander wrote:
 With this patch, there is new ./configure option '--enable-lock-debug'
 which controls whether we want to turn on debugging locks.  This
 feature is exposed as a ./configure option due to its huge overhead in
 speed/log size and is only meant to be used with this in mind.  It is
 designed in a way that even log from deadlocked daemon should provide
 enough info to find the deadlock itself.  Every matching Lock() call
 can be matched with its Unlock() call and with every Lock() called it
 is visible whether it failed or not.  Unlock() call follows the same
 output, even though unnecessary (the call cannot block).
 
 Lock logging is disabled while logging because that would either
 recurse or deadlock.
 
 Signed-off-by: Martin Kletzander mklet...@redhat.com

I'm really inclined to say that anyone wanting todo lock debugging
should just use systemtap / dtrace todo it, since it is better in
every way. You don't need any special compile options to enable
it, tracing scripts have little impact on operation of the program
being debugged, you can trivially filter data output so that it
only reports locking of specific objects, you can trace and
synchronize across processes and languages  kernel/userspace.
So I don't really think there is any compelling reason to include
lock debugging code in libvirt.

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

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


[libvirt] [PATCH] tests: Free test at the end of GetDeviceAliases JSON test

2013-07-22 Thread Jiri Denemark
Commit 58b147ad07c9432b53e66ca20aff74d812647c57 added a test for
qemuMonitorGetDeviceAliases but forgot to free the test object at the
end which causes all sort of weird errors and failures when new tests
are added after the GetDeviceAliases.
---
 tests/qemumonitorjsontest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 4061a0c..9e66059 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -938,6 +938,7 @@ testQemuMonitorJSONGetDeviceAliases(const void *data)
 
 cleanup:
 virStringFreeList(aliases);
+qemuMonitorTestFree(test);
 return ret;
 }
 
-- 
1.8.3.2

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


[libvirt] [PATCH 2/4] Move pool XML out of storagevolxml2argvdata

2013-07-22 Thread Ján Tomko
Reuse the pool definition from storagepoolxml2xmlin.
---
 tests/storagevolxml2argvdata/pool-dir.xml | 18 --
 tests/storagevolxml2argvtest.c|  2 +-
 2 files changed, 1 insertion(+), 19 deletions(-)
 delete mode 100644 tests/storagevolxml2argvdata/pool-dir.xml

diff --git a/tests/storagevolxml2argvdata/pool-dir.xml 
b/tests/storagevolxml2argvdata/pool-dir.xml
deleted file mode 100644
index e10ccb7..000
--- a/tests/storagevolxml2argvdata/pool-dir.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-pool type='dir'
-  namevirtimages/name
-  uuid70a7eb15-6c34-ee9c-bf57-69e8e5ff3fb2/uuid
-  capacity0/capacity
-  allocation0/allocation
-  available0/available
-  source
-  /source
-  target
-path///var/lib/libvirt/images///path
-permissions
-  mode0700/mode
-  owner-1/owner
-  group-1/group
-  labelsome_label_t/label
-/permissions
-  /target
-/pool
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 4f4bf7d..1e3ff9a 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -124,7 +124,7 @@ testCompareXMLToArgvHelper(const void *data)
 virAsprintf(inputvolxml, %s/storagevolxml2argvdata/%s.xml,
 abs_srcdir, info-inputvol)  0)
 goto cleanup;
-if (virAsprintf(poolxml, %s/storagevolxml2argvdata/%s.xml,
+if (virAsprintf(poolxml, %s/storagepoolxml2xmlin/%s.xml,
 abs_srcdir, info-pool)  0 ||
 virAsprintf(volxml, %s/storagevolxml2argvdata/%s.xml,
 abs_srcdir, info-vol)  0) {
-- 
1.8.1.5

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


[libvirt] [PATCH 4/4] Add inputpool to storagevolxml2argvtest

2013-07-22 Thread Ján Tomko
This allows testing the command line for cloning file-based
volumes into logical volumes and vice versa.
---
 .../storagevolxml2argvdata/logical-from-qcow2.argv |  2 +
 .../storagevolxml2argvdata/qcow2-from-logical.argv |  2 +
 tests/storagevolxml2argvtest.c | 90 +-
 3 files changed, 74 insertions(+), 20 deletions(-)
 create mode 100644 tests/storagevolxml2argvdata/logical-from-qcow2.argv
 create mode 100644 tests/storagevolxml2argvdata/qcow2-from-logical.argv

diff --git a/tests/storagevolxml2argvdata/logical-from-qcow2.argv 
b/tests/storagevolxml2argvdata/logical-from-qcow2.argv
new file mode 100644
index 000..7beded8
--- /dev/null
+++ b/tests/storagevolxml2argvdata/logical-from-qcow2.argv
@@ -0,0 +1,2 @@
+qemu-img convert -f qcow2 -O raw /var/lib/libvirt/images/OtherDemo.img \
+/dev/HostVG/Swap
diff --git a/tests/storagevolxml2argvdata/qcow2-from-logical.argv 
b/tests/storagevolxml2argvdata/qcow2-from-logical.argv
new file mode 100644
index 000..6a75815
--- /dev/null
+++ b/tests/storagevolxml2argvdata/qcow2-from-logical.argv
@@ -0,0 +1,2 @@
+qemu-img convert -f raw -O qcow2 -o encryption=on /dev/HostVG/Swap \
+/var/lib/libvirt/images/OtherDemo.img
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index b220994..3c338ce 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -11,10 +11,32 @@
 
 const char create_tool[] = qemu-img;
 
+/* createVol sets this on volume creation */
+static void
+testSetVolumeType(virStorageVolDefPtr vol,
+  virStoragePoolDefPtr pool)
+{
+if (!vol)
+return;
+
+switch (pool-type) {
+case VIR_STORAGE_POOL_DIR:
+case VIR_STORAGE_POOL_FS:
+case VIR_STORAGE_POOL_NETFS:
+vol-type = VIR_STORAGE_VOL_FILE;
+return;
+
+case VIR_STORAGE_POOL_LOGICAL:
+vol-type = VIR_STORAGE_VOL_BLOCK;
+return;
+}
+}
+
 static int
 testCompareXMLToArgvFiles(bool shouldFail,
   const char *poolxml,
   const char *volxml,
+  const char *inputpoolxml,
   const char *inputvolxml,
   const char *cmdline,
   unsigned int flags,
@@ -22,6 +44,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
 {
 char *volXmlData = NULL;
 char *poolXmlData = NULL;
+char *inputpoolXmlData = NULL;
 char *inputvolXmlData = NULL;
 char *expectedCmdline = NULL;
 char *actualCmdline = NULL;
@@ -34,6 +57,7 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
 virStorageVolDefPtr vol = NULL, inputvol = NULL;
 virStoragePoolDefPtr pool = NULL;
+virStoragePoolDefPtr inputpool = NULL;
 virStoragePoolObj poolobj = {.def = NULL };
 
 
@@ -53,13 +77,23 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
 poolobj.def = pool;
 
+if (inputpoolxml) {
+if (virtTestLoadFile(inputpoolxml, inputpoolXmlData)  0)
+goto cleanup;
+if (!(inputpool = virStoragePoolDefParseString(inputpoolXmlData)))
+goto cleanup;
+}
+
 if (!(vol = virStorageVolDefParseString(pool, volXmlData)))
 goto cleanup;
 
 if (inputvolxml 
-!(inputvol = virStorageVolDefParseString(pool, inputvolXmlData)))
+!(inputvol = virStorageVolDefParseString(inputpool, inputvolXmlData)))
 goto cleanup;
 
+testSetVolumeType(vol, pool);
+testSetVolumeType(inputvol, inputpool);
+
 cmd = virStorageBackendCreateQemuImgCmd(conn, poolobj, vol, inputvol,
 flags, create_tool, imgformat);
 if (!cmd) {
@@ -88,11 +122,13 @@ testCompareXMLToArgvFiles(bool shouldFail,
 
 cleanup:
 virStoragePoolDefFree(pool);
+virStoragePoolDefFree(inputpool);
 virStorageVolDefFree(vol);
 virStorageVolDefFree(inputvol);
 virCommandFree(cmd);
 VIR_FREE(actualCmdline);
 VIR_FREE(expectedCmdline);
+VIR_FREE(inputpoolXmlData);
 VIR_FREE(poolXmlData);
 VIR_FREE(volXmlData);
 VIR_FREE(inputvolXmlData);
@@ -104,6 +140,7 @@ struct testInfo {
 bool shouldFail;
 const char *pool;
 const char *vol;
+const char *inputpool;
 const char *inputvol;
 const char *cmdline;
 unsigned int flags;
@@ -116,6 +153,7 @@ testCompareXMLToArgvHelper(const void *data)
 int result = -1;
 const struct testInfo *info = data;
 char *poolxml = NULL;
+char *inputpoolxml = NULL;
 char *volxml = NULL;
 char *inputvolxml = NULL;
 char *cmdline = NULL;
@@ -124,6 +162,10 @@ testCompareXMLToArgvHelper(const void *data)
 virAsprintf(inputvolxml, %s/storagevolxml2xmlin/%s.xml,
 abs_srcdir, info-inputvol)  0)
 goto cleanup;
+if (info-inputpool 
+virAsprintf(inputpoolxml, %s/storagepoolxml2xmlin/%s.xml,
+abs_srcdir, info-inputpool)  0)
+goto cleanup;
 if (virAsprintf(poolxml, 

[libvirt] [PATCH 3/4] Move volume XMLs out of storagevolxml2argvdata

2013-07-22 Thread Ján Tomko
Reuse the XML files in storagevolxml2xmlin.

(This requires changing a few backing files to /dev/null,
since virStorageBackendCreateQemuImgCmd checks for its
presence)
---
 tests/storagevolxml2argvdata/vol-file.xml  | 20 --
 tests/storagevolxml2argvdata/vol-qcow2-1.1.xml | 32 --
 tests/storagevolxml2argvtest.c |  4 +--
 .../vol-qcow2-0.10-lazy.xml|  0
 tests/storagevolxml2xmlin/vol-qcow2-1.1.xml|  2 +-
 tests/storagevolxml2xmlin/vol-qcow2-lazy.xml   |  2 +-
 .../vol-qcow2-nobacking.xml|  0
 tests/storagevolxml2xmlin/vol-qcow2.xml|  2 +-
 .../vol-qcow2-0.10-lazy.xml}   |  8 +++---
 tests/storagevolxml2xmlout/vol-qcow2-1.1.xml   |  2 +-
 tests/storagevolxml2xmlout/vol-qcow2-lazy.xml  |  2 +-
 .../vol-qcow2-nobacking.xml}   | 16 ++-
 tests/storagevolxml2xmlout/vol-qcow2.xml   |  2 +-
 tests/storagevolxml2xmltest.c  |  2 ++
 14 files changed, 17 insertions(+), 77 deletions(-)
 delete mode 100644 tests/storagevolxml2argvdata/vol-file.xml
 delete mode 100644 tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
 rename tests/{storagevolxml2argvdata = 
storagevolxml2xmlin}/vol-qcow2-0.10-lazy.xml (100%)
 rename tests/{storagevolxml2argvdata = 
storagevolxml2xmlin}/vol-qcow2-nobacking.xml (100%)
 rename tests/{storagevolxml2argvdata/vol-qcow2-lazy.xml = 
storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml} (84%)
 rename tests/{storagevolxml2argvdata/vol-qcow2.xml = 
storagevolxml2xmlout/vol-qcow2-nobacking.xml} (55%)

diff --git a/tests/storagevolxml2argvdata/vol-file.xml 
b/tests/storagevolxml2argvdata/vol-file.xml
deleted file mode 100644
index d3f65f6..000
--- a/tests/storagevolxml2argvdata/vol-file.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-volume
-  namesparse.img/name
-  source/
-  capacity unit=TiB1/capacity
-  allocation unit=bytes0/allocation
-  target
-path/var/lib/libvirt/images/sparse.img/path
-permissions
-  mode0/mode
-  owner0744/owner
-  group0/group
-  labelvirt_image_t/label
-/permissions
-timestamps
-  atime1341933637.273190990/atime
-  mtime1341930622.047245868/mtime
-  ctime1341930622.047245868/ctime
-/timestamps
-  /target
-/volume
diff --git a/tests/storagevolxml2argvdata/vol-qcow2-1.1.xml 
b/tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
deleted file mode 100644
index 696e1e0..000
--- a/tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-volume
-  nameOtherDemo.img/name
-  key/var/lib/libvirt/images/OtherDemo.img/key
-  source
-  /source
-  capacity unit=G5/capacity
-  allocation294912/allocation
-  target
-path/var/lib/libvirt/images/OtherDemo.img/path
-format type='qcow2'/
-permissions
-  mode0644/mode
-  owner0/owner
-  group0/group
-  labelunconfined_u:object_r:virt_image_t:s0/label
-/permissions
-encryption format='qcow'
-  secret type='passphrase' uuid='e78d4b51-a2af-485f-b0f5-afca709a80f4'/
-/encryption
-features/
-  /target
-  backingStore
-path/dev/null/path
-format type='raw'/
-permissions
-  mode0644/mode
-  owner0/owner
-  group0/group
-  labelunconfined_u:object_r:virt_image_t:s0/label
-/permissions
-  /backingStore
-/volume
diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 1e3ff9a..b220994 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -121,12 +121,12 @@ testCompareXMLToArgvHelper(const void *data)
 char *cmdline = NULL;
 
 if (info-inputvol 
-virAsprintf(inputvolxml, %s/storagevolxml2argvdata/%s.xml,
+virAsprintf(inputvolxml, %s/storagevolxml2xmlin/%s.xml,
 abs_srcdir, info-inputvol)  0)
 goto cleanup;
 if (virAsprintf(poolxml, %s/storagepoolxml2xmlin/%s.xml,
 abs_srcdir, info-pool)  0 ||
-virAsprintf(volxml, %s/storagevolxml2argvdata/%s.xml,
+virAsprintf(volxml, %s/storagevolxml2xmlin/%s.xml,
 abs_srcdir, info-vol)  0) {
 goto cleanup;
 }
diff --git a/tests/storagevolxml2argvdata/vol-qcow2-0.10-lazy.xml 
b/tests/storagevolxml2xmlin/vol-qcow2-0.10-lazy.xml
similarity index 100%
rename from tests/storagevolxml2argvdata/vol-qcow2-0.10-lazy.xml
rename to tests/storagevolxml2xmlin/vol-qcow2-0.10-lazy.xml
diff --git a/tests/storagevolxml2xmlin/vol-qcow2-1.1.xml 
b/tests/storagevolxml2xmlin/vol-qcow2-1.1.xml
index e8df8b3..696e1e0 100644
--- a/tests/storagevolxml2xmlin/vol-qcow2-1.1.xml
+++ b/tests/storagevolxml2xmlin/vol-qcow2-1.1.xml
@@ -20,7 +20,7 @@
 features/
   /target
   backingStore
-path/var/lib/libvirt/images/BaseDemo.img/path
+path/dev/null/path
 format type='raw'/
 permissions
   mode0644/mode
diff --git a/tests/storagevolxml2xmlin/vol-qcow2-lazy.xml 
b/tests/storagevolxml2xmlin/vol-qcow2-lazy.xml

[libvirt] [PATCH 0/4] Test logical volume cloning in storagevolxml2argvtest

2013-07-22 Thread Ján Tomko
Ján Tomko (4):
  Use separate macros for failure/success in vol-to-argv test
  Move pool XML out of storagevolxml2argvdata
  Move volume XMLs out of storagevolxml2argvdata
  Add inputpool to storagevolxml2argvtest

 .../storagevolxml2argvdata/logical-from-qcow2.argv |   2 +
 tests/storagevolxml2argvdata/pool-dir.xml  |  18 ---
 .../storagevolxml2argvdata/qcow2-from-logical.argv |   2 +
 tests/storagevolxml2argvdata/vol-file.xml  |  20 
 tests/storagevolxml2argvdata/vol-qcow2-1.1.xml |  32 --
 tests/storagevolxml2argvtest.c | 128 -
 .../vol-qcow2-0.10-lazy.xml|   0
 tests/storagevolxml2xmlin/vol-qcow2-1.1.xml|   2 +-
 tests/storagevolxml2xmlin/vol-qcow2-lazy.xml   |   2 +-
 .../vol-qcow2-nobacking.xml|   0
 tests/storagevolxml2xmlin/vol-qcow2.xml|   2 +-
 .../vol-qcow2-0.10-lazy.xml}   |   8 +-
 tests/storagevolxml2xmlout/vol-qcow2-1.1.xml   |   2 +-
 tests/storagevolxml2xmlout/vol-qcow2-lazy.xml  |   2 +-
 .../vol-qcow2-nobacking.xml}   |  16 +--
 tests/storagevolxml2xmlout/vol-qcow2.xml   |   2 +-
 tests/storagevolxml2xmltest.c  |   2 +
 17 files changed, 120 insertions(+), 120 deletions(-)
 create mode 100644 tests/storagevolxml2argvdata/logical-from-qcow2.argv
 delete mode 100644 tests/storagevolxml2argvdata/pool-dir.xml
 create mode 100644 tests/storagevolxml2argvdata/qcow2-from-logical.argv
 delete mode 100644 tests/storagevolxml2argvdata/vol-file.xml
 delete mode 100644 tests/storagevolxml2argvdata/vol-qcow2-1.1.xml
 rename tests/{storagevolxml2argvdata = 
storagevolxml2xmlin}/vol-qcow2-0.10-lazy.xml (100%)
 rename tests/{storagevolxml2argvdata = 
storagevolxml2xmlin}/vol-qcow2-nobacking.xml (100%)
 rename tests/{storagevolxml2argvdata/vol-qcow2-lazy.xml = 
storagevolxml2xmlout/vol-qcow2-0.10-lazy.xml} (84%)
 rename tests/{storagevolxml2argvdata/vol-qcow2.xml = 
storagevolxml2xmlout/vol-qcow2-nobacking.xml} (55%)

-- 
1.8.1.5

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

[libvirt] [PATCH 1/4] Use separate macros for failure/success in vol-to-argv test

2013-07-22 Thread Ján Tomko
Reindent them to put the input volume on a separate line.
---
 tests/storagevolxml2argvtest.c | 64 +-
 1 file changed, 44 insertions(+), 20 deletions(-)

diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c
index 89c233f..4f4bf7d 100644
--- a/tests/storagevolxml2argvtest.c
+++ b/tests/storagevolxml2argvtest.c
@@ -161,7 +161,8 @@ mymain(void)
 int ret = 0;
 unsigned int flags = VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
 
-#define DO_TEST(shouldFail, pool, vol, inputvol, cmdline, flags, imgformat) \
+#define DO_TEST_FULL(shouldFail, pool, vol, inputvol, cmdline, flags, \
+ imgformat) \
 do {\
 struct testInfo info = { shouldFail, pool, vol, inputvol, cmdline, \
  flags, imgformat }; \
@@ -171,31 +172,54 @@ mymain(void)
}\
 while (0);
 
-DO_TEST(false, pool-dir, vol-qcow2, NULL, qcow2, 0, FMT_OPTIONS);
-DO_TEST(true, pool-dir, vol-qcow2, NULL, qcow2-prealloc, flags,
-FMT_OPTIONS);
-DO_TEST(false, pool-dir, vol-qcow2-nobacking, NULL,
+#define DO_TEST(pool, ...) \
+DO_TEST_FULL(false, pool, __VA_ARGS__)
+
+#define DO_TEST_FAIL(pool, ...)\
+DO_TEST_FULL(true, pool, __VA_ARGS__)
+
+DO_TEST(pool-dir, vol-qcow2,
+NULL,
+qcow2, 0, FMT_OPTIONS);
+DO_TEST_FAIL(pool-dir, vol-qcow2,
+ NULL,
+ qcow2-prealloc, flags, FMT_OPTIONS);
+DO_TEST(pool-dir, vol-qcow2-nobacking,
+NULL,
 qcow2-nobacking-prealloc, flags, FMT_OPTIONS);
-DO_TEST(false, pool-dir, vol-qcow2-nobacking, vol-file,
+DO_TEST(pool-dir, vol-qcow2-nobacking,
+vol-file,
 qcow2-nobacking-convert-prealloc, flags, FMT_OPTIONS);
-DO_TEST(true, pool-dir, vol-qcow2, vol-file,
-qcow2-convert-prealloc, flags, FMT_OPTIONS);
-DO_TEST(false, pool-dir, vol-qcow2, NULL, qcow2-flag, 0, FMT_FLAG);
-DO_TEST(false, pool-dir, vol-qcow2-nobacking, NULL,
+DO_TEST_FAIL(pool-dir, vol-qcow2,
+ vol-file,
+ qcow2-convert-prealloc, flags, FMT_OPTIONS);
+DO_TEST(pool-dir, vol-qcow2,
+NULL,
+qcow2-flag, 0, FMT_FLAG);
+DO_TEST(pool-dir, vol-qcow2-nobacking,
+NULL,
 qcow2-nobacking-flag, 0, FMT_FLAG);
-DO_TEST(false, pool-dir, vol-qcow2-nobacking, vol-file,
+DO_TEST(pool-dir, vol-qcow2-nobacking,
+vol-file,
 qcow2-nobacking-convert-flag, 0, FMT_FLAG);
-DO_TEST(false, pool-dir, vol-qcow2, NULL, qcow2-none, 0, FMT_NONE);
-DO_TEST(false, pool-dir, vol-qcow2-nobacking, NULL,
+DO_TEST(pool-dir, vol-qcow2,
+NULL,
+qcow2-none, 0, FMT_NONE);
+DO_TEST(pool-dir, vol-qcow2-nobacking,
+NULL,
 qcow2-nobacking-none, 0, FMT_NONE);
-DO_TEST(false, pool-dir, vol-qcow2-nobacking, vol-file,
+DO_TEST(pool-dir, vol-qcow2-nobacking,
+vol-file,
 qcow2-nobacking-convert-none, 0, FMT_NONE);
-DO_TEST(false, pool-dir, vol-qcow2-lazy, NULL, qcow2-lazy, 0,
-FMT_OPTIONS);
-DO_TEST(false, pool-dir, vol-qcow2-1.1, NULL, qcow2-1.1, 0,
-FMT_OPTIONS);
-DO_TEST(true, pool-dir, vol-qcow2-0.10-lazy, NULL, qcow2-0.10-lazy, 
0,
-FMT_OPTIONS);
+DO_TEST(pool-dir, vol-qcow2-lazy,
+NULL,
+qcow2-lazy, 0, FMT_OPTIONS);
+DO_TEST(pool-dir, vol-qcow2-1.1,
+NULL,
+qcow2-1.1, 0, FMT_OPTIONS);
+DO_TEST_FAIL(pool-dir, vol-qcow2-0.10-lazy,
+ NULL,
+ qcow2-0.10-lazy, 0, FMT_OPTIONS);
 
 return ret==0 ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
1.8.1.5

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


Re: [libvirt] [PATCH] doc: Fix copy-paste-error in virNodeGetMemoryStats

2013-07-22 Thread Ján Tomko
On 07/22/2013 01:58 PM, Philipp Hahn wrote:
 The description seems to be copied from virNodeGetCpuState.
 Change wrong 'cpu' to 'memory'.
 
 Signed-off-by: Philipp Hahn h...@univention.de
 ---
  src/libvirt.c |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 

ACK and pushed.

This has been present since that function was introduced in 0c5ce685.

Jan

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


Re: [libvirt] [PATCH] tests: Free test at the end of GetDeviceAliases JSON test

2013-07-22 Thread Jiri Denemark
On Mon, Jul 22, 2013 at 16:19:18 +0200, Michal Privoznik wrote:
 On 22.07.2013 15:57, Jiri Denemark wrote:
  Commit 58b147ad07c9432b53e66ca20aff74d812647c57 added a test for
  qemuMonitorGetDeviceAliases but forgot to free the test object at the
  end which causes all sort of weird errors and failures when new tests
  are added after the GetDeviceAliases.
  ---
   tests/qemumonitorjsontest.c | 1 +
   1 file changed, 1 insertion(+)
  
  diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
  index 4061a0c..9e66059 100644
  --- a/tests/qemumonitorjsontest.c
  +++ b/tests/qemumonitorjsontest.c
  @@ -938,6 +938,7 @@ testQemuMonitorJSONGetDeviceAliases(const void *data)
   
   cleanup:
   virStringFreeList(aliases);
  +qemuMonitorTestFree(test);
   return ret;
   }
   
  
 
 ACK

Pushed, thanks.

Jirka

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


[libvirt] [PATCH] Make locking more debuggable from logs

2013-07-22 Thread Martin Kletzander
With this patch, there is new ./configure option '--enable-lock-debug'
which controls whether we want to turn on debugging locks.  This
feature is exposed as a ./configure option due to its huge overhead in
speed/log size and is only meant to be used with this in mind.  It is
designed in a way that even log from deadlocked daemon should provide
enough info to find the deadlock itself.  Every matching Lock() call
can be matched with its Unlock() call and with every Lock() called it
is visible whether it failed or not.  Unlock() call follows the same
output, even though unnecessary (the call cannot block).

Lock logging is disabled while logging because that would either
recurse or deadlock.

Signed-off-by: Martin Kletzander mklet...@redhat.com
---
 configure.ac| 19 +++
 src/Makefile.am |  3 ++-
 src/libvirt_private.syms|  1 +
 src/util/virlog.c   |  8 +++
 src/util/virthread.h|  4 
 src/util/virthreadpthread.c | 58 -
 src/util/virutil.c  | 40 +++
 src/util/virutil.h  |  2 ++
 8 files changed, 133 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index b5af0d3..c63ffe7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -478,6 +478,24 @@ if test x$enable_debug = xyes; then
AC_DEFINE([ENABLE_DEBUG], [], [whether debugging is enabled])
 fi

+dnl --enable-lock-debug=(yes|no)
+AC_ARG_ENABLE([lock-debug],
+  [AC_HELP_STRING([--enable-lock-debug=@:@no|yes@:@],
+ [enable lock debugging (beware of huge overhead) 
@:@default=no@:@])],
+ [],[enable_lock_debug=no])
+AM_CONDITIONAL([ENABLE_LOCK_DEBUG], test x$enable_lock_debug = xyes)
+if test x$enable_lock_debug = xyes; then
+   if test $ac_cv_header_pthread_h != yes ; then
+  AC_MSG_ERROR([POSIX threads are needed to properly debug locking])
+   fi
+   if test x$enable_debug != xyes ; then
+  AC_MSG_ERROR([Cannot debug locking without enabling debugging itself])
+   fi
+
+   AC_DEFINE([ENABLE_LOCK_DEBUG], [], [whether lock debugging is enabled])
+   LOCK_DEBUG_LDFLAGS=-rdynamic
+fi
+AC_SUBST([LOCK_DEBUG_LDFLAGS])


 dnl
@@ -2601,6 +2619,7 @@ AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Miscellaneous])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Debug: $enable_debug])
+AC_MSG_NOTICE([   Lock debug: $enable_lock_debug])
 AC_MSG_NOTICE([  Use -Werror: $set_werror])
 AC_MSG_NOTICE([Warning Flags: $WARN_CFLAGS])
 AC_MSG_NOTICE([ Readline: $lv_use_readline])
diff --git a/src/Makefile.am b/src/Makefile.am
index 8fa8680..ef6aaa3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,8 @@ AM_CFLAGS =   $(LIBXML_CFLAGS)
\
$(WIN32_EXTRA_CFLAGS)   \
$(COVERAGE_CFLAGS)
 AM_LDFLAGS =   $(DRIVER_MODULE_LDFLAGS)\
-   $(COVERAGE_LDFLAGS)
+   $(COVERAGE_LDFLAGS) \
+   $(LOCK_DEBUG_LDFLAGS)

 EXTRA_DIST = $(conf_DATA) util/keymaps.csv

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7790ede..44b4a60 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2022,6 +2022,7 @@ virGetGroupID;
 virGetGroupList;
 virGetGroupName;
 virGetHostname;
+virGetLockFunc;
 virGetUnprivSGIOSysfsPath;
 virGetUserCacheDirectory;
 virGetUserConfigDirectory;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index d1fb0b3..8d1e943 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -150,14 +150,22 @@ virMutex virLogMutex;
 void
 virLogLock(void)
 {
+#ifdef ENABLE_LOCK_DEBUG
+virMutexLockNoLog(virLogMutex);
+#else
 virMutexLock(virLogMutex);
+#endif
 }


 void
 virLogUnlock(void)
 {
+#ifdef ENABLE_LOCK_DEBUG
+virMutexUnlockNoLog(virLogMutex);
+#else
 virMutexUnlock(virLogMutex);
+#endif
 }


diff --git a/src/util/virthread.h b/src/util/virthread.h
index 84d3bdc..6d86227 100644
--- a/src/util/virthread.h
+++ b/src/util/virthread.h
@@ -88,6 +88,10 @@ void virMutexDestroy(virMutexPtr m);
 void virMutexLock(virMutexPtr m);
 void virMutexUnlock(virMutexPtr m);

+# ifdef ENABLE_LOCK_DEBUG
+void virMutexLockNoLog(virMutexPtr m);
+void virMutexUnlockNoLog(virMutexPtr m);
+# endif


 int virCondInit(virCondPtr c) ATTRIBUTE_RETURN_CHECK;
diff --git a/src/util/virthreadpthread.c b/src/util/virthreadpthread.c
index ca841e4..95e20b5 100644
--- a/src/util/virthreadpthread.c
+++ b/src/util/virthreadpthread.c
@@ -29,6 +29,11 @@

 #include viralloc.h

+#ifdef ENABLE_LOCK_DEBUG
+# include virutil.h
+# include virlog.h
+#endif
+

 /* Nothing special required for pthreads */
 int virThreadInitialize(void)
@@ -81,7 +86,57 @@ void virMutexDestroy(virMutexPtr m)
 pthread_mutex_destroy(m-lock);
 }

-void virMutexLock(virMutexPtr m){
+#ifdef ENABLE_LOCK_DEBUG
+
+# define PRE_LOCK_PROC(mutex)

[libvirt] [PATCH] tests: PCI controller checks

2013-07-22 Thread Ján Tomko
Check if PCI bridges with duplicate indexes are rejected.
PCI root controllers with non-zero indexes or addresses should
also be rejected.
---
 .../qemuxml2argv-pci-bridge-duplicate-index.xml  | 16 
 tests/qemuxml2argvdata/qemuxml2argv-pci-root-address.xml | 16 
 .../qemuxml2argv-pci-root-nonzero-index.xml  | 14 ++
 tests/qemuxml2argvtest.c |  6 ++
 4 files changed, 52 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-pci-bridge-duplicate-index.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-root-address.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-pci-root-nonzero-index.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge-duplicate-index.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge-duplicate-index.xml
new file mode 100644
index 000..0aea45d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-bridge-duplicate-index.xml
@@ -0,0 +1,16 @@
+domain type='qemu'
+  namefdr-br/name
+  memory unit='KiB'2097152/memory
+  currentMemory unit='KiB'2097152/currentMemory
+  vcpu placement='static' cpuset='0-1'2/vcpu
+  os
+type arch='x86_64' machine='pc-1.2'hvm/type
+boot dev='hd'/
+  /os
+  devices
+emulator/usr/libexec/qemu-kvm/emulator
+controller type='pci' index='0' model='pci-root'/
+controller type='pci' index='1' model='pci-bridge'/
+controller type='pci' index='1' model='pci-bridge'/
+  /devices
+/domain
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-root-address.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-pci-root-address.xml
new file mode 100644
index 000..7b43246
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-root-address.xml
@@ -0,0 +1,16 @@
+domain type='qemu'
+  namefdr-br/name
+  memory unit='KiB'2097152/memory
+  currentMemory unit='KiB'2097152/currentMemory
+  vcpu placement='static' cpuset='0-1'2/vcpu
+  os
+type arch='x86_64' machine='pc-1.2'hvm/type
+boot dev='hd'/
+  /os
+  devices
+emulator/usr/libexec/qemu-kvm/emulator
+controller type='pci' index='0' model='pci-root'
+  address type='pci' domain='0' bus='0' slot='0' function='0'/
+/controller
+  /devices
+/domain
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-root-nonzero-index.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-pci-root-nonzero-index.xml
new file mode 100644
index 000..1a21d3b
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-root-nonzero-index.xml
@@ -0,0 +1,14 @@
+domain type='qemu'
+  namefdr-br/name
+  memory unit='KiB'2097152/memory
+  currentMemory unit='KiB'2097152/currentMemory
+  vcpu placement='static' cpuset='0-1'2/vcpu
+  os
+type arch='x86_64' machine='pc-1.2'hvm/type
+boot dev='hd'/
+  /os
+  devices
+emulator/usr/libexec/qemu-kvm/emulator
+controller type='pci' index='7' model='pci-root'/
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 0f96eef..75f1c4a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1018,6 +1018,12 @@ mymain(void)
 
 DO_TEST_PARSE_ERROR(pci-bridge-negative-index-invalid,
 QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
+DO_TEST_PARSE_ERROR(pci-bridge-duplicate-index,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
+DO_TEST_PARSE_ERROR(pci-root-nonzero-index,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
+DO_TEST_PARSE_ERROR(pci-root-address,
+QEMU_CAPS_DEVICE, QEMU_CAPS_DEVICE_PCI_BRIDGE);
 
 virObjectUnref(driver.config);
 virObjectUnref(driver.caps);
-- 
1.8.1.5

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


Re: [libvirt] [PATCH v3 5/7] tests: Add various network and volume definitions

2013-07-22 Thread John Ferlan
On 07/22/2013 07:06 AM, Osier Yang wrote:
 On 19/07/13 20:32, John Ferlan wrote:
 Although they produce no seclabel data, add some tests for coverage of
 various network and volume disk definitions
 ---
   tests/securityselinuxlabeldata/netdisks.txt |  5 +++
   tests/securityselinuxlabeldata/netdisks.xml | 58
 +
   tests/securityselinuxlabeldata/voldisks.txt |  5 +++
   tests/securityselinuxlabeldata/voldisks.xml | 45 ++
   tests/securityselinuxlabeltest.c|  2 +
   5 files changed, 115 insertions(+)
   create mode 100644 tests/securityselinuxlabeldata/netdisks.txt
   create mode 100644 tests/securityselinuxlabeldata/netdisks.xml
   create mode 100644 tests/securityselinuxlabeldata/voldisks.txt
   create mode 100644 tests/securityselinuxlabeldata/voldisks.xml

 diff --git a/tests/securityselinuxlabeldata/netdisks.txt
 b/tests/securityselinuxlabeldata/netdisks.txt
 new file mode 100644
 index 000..b6bf95f
 --- /dev/null
 +++ b/tests/securityselinuxlabeldata/netdisks.txt
 @@ -0,0 +1,5 @@
 +/nbd.raw;
 +/iscsi.raw;
 +/rbd.raw;
 +/sheepdog.raw;
 +/gluster.raw;
 diff --git a/tests/securityselinuxlabeldata/netdisks.xml
 b/tests/securityselinuxlabeldata/netdisks.xml
 new file mode 100644
 index 000..ab5e964
 --- /dev/null
 +++ b/tests/securityselinuxlabeldata/netdisks.xml
 @@ -0,0 +1,58 @@
 +domain type='kvm'
 +  namevm1/name
 +  uuidc7b3edbd-edaf-9455-926a-d65c16db1800/uuid
 +  memory unit='KiB'219200/memory
 +  os
 +type arch='i686' machine='pc-1.0'hvm/type
 +boot dev='cdrom'/
 +  /os
 +  devices
 +  disk type='network' device='disk'
 +driver name='qemu' type='raw'/
 +source protocol='nbd' file=/nbd.raw
 +  host name='example.org' port='6000'/
 +/source
 +  target dev='vda' bus='virtio'/
 +/disk
 +disk type='network' device='disk'
 +  driver name='qemu' type='raw'/
 +  source protocol='iscsi' name='iqn.1992-01.com.example/1'
 file=/iscsi.raw
 
 i'm not clear with the security tests, but this xml looks incorrect. 
 file is one
 way to represent the disk source, it's exclusive with other ways (e.g.
 protocol/name
 here) in semantics. similar for below. why do you use both file and
 other ways
 for disk source represention together?
 

Following syntax found in the following files

tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-*.xml

where '*' is {gluster, nbd, rbd, sheepdog,  iscsi}

I can hold off pushing this patch if desired.

The 'file' names are found in the 'netdisks.txt' file which are where
the seclabels get listed for other tests. For the network types there
are no seclabels.

John



 +host name='example.org' port='6000'/
 +  /source
 +  target dev='vdb' bus='virtio'/
 +/disk
 +disk type='network'
 +  driver name=qemu type=raw/
 +  source protocol=rbd name=image_name2 file=/rbd.raw
 +  host name=hostname port=7000/
 +  /source
 +  target dev=hdb bus=ide/
 +  auth username='myuser'
 +secret type='ceph' usage='mypassid'/
 +  /auth
 +/disk
 +disk type='network'
 +  driver name=qemu type=raw/
 +  source protocol=sheepdog name=image_name
 file=/sheepdog.raw
 +  host name=hostname port=7000/
 +  /source
 +  target dev=hdb bus=ide/
 +/disk
 +disk type='network' device='disk'
 +  driver name='qemu' type='raw'/
 +  source protocol='gluster' name='Volume/Image'
 file='/gluster.raw'
 +host name='example.org' port='6000' transport='tcp'/
 +  /source
 +  target dev='vda' bus='virtio'/
 +/disk
 +
 +input type='mouse' bus='ps2'/
 +graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'
 +  listen type='address' address='0.0.0.0'/
 +/graphics
 +  /devices
 +  seclabel model=selinux type=dynamic relabel=yes
 +labelsystem_u:system_r:svirt_t:s0:c41,c264/label
 +imagelabelsystem_u:object_r:svirt_image_t:s0:c41,c264/imagelabel
 +  /seclabel
 +/domain
 diff --git a/tests/securityselinuxlabeldata/voldisks.txt
 b/tests/securityselinuxlabeldata/voldisks.txt
 new file mode 100644
 index 000..bd5d755
 --- /dev/null
 +++ b/tests/securityselinuxlabeldata/voldisks.txt
 @@ -0,0 +1,5 @@
 +/file.raw;
 +/disk.raw;
 +/host.raw;
 +/direct.raw;
 +/cdrom.raw;
 diff --git a/tests/securityselinuxlabeldata/voldisks.xml
 b/tests/securityselinuxlabeldata/voldisks.xml
 new file mode 100644
 index 000..ae7e629
 --- /dev/null
 +++ b/tests/securityselinuxlabeldata/voldisks.xml
 @@ -0,0 +1,45 @@
 +domain type='kvm'
 +  namevm1/name
 +  uuidc7b3edbd-edaf-9455-926a-d65c16db1800/uuid
 +  memory unit='KiB'219200/memory
 +  os
 +type arch='i686' machine='pc-1.0'hvm/type
 +boot dev='cdrom'/
 +  /os
 +  devices
 +disk type='volume' device='disk'
 +  driver name='qemu' type='raw'/
 +  source pool='dir-pool0' volume='dir-pool0-vol0'
 file='/file.raw'/
 +  target dev='hda' bus='ide'/
 +/disk
 +disk type='volume' 

Re: [libvirt] [PATCH] tests: Free test at the end of GetDeviceAliases JSON test

2013-07-22 Thread Michal Privoznik
On 22.07.2013 15:57, Jiri Denemark wrote:
 Commit 58b147ad07c9432b53e66ca20aff74d812647c57 added a test for
 qemuMonitorGetDeviceAliases but forgot to free the test object at the
 end which causes all sort of weird errors and failures when new tests
 are added after the GetDeviceAliases.
 ---
  tests/qemumonitorjsontest.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
 index 4061a0c..9e66059 100644
 --- a/tests/qemumonitorjsontest.c
 +++ b/tests/qemumonitorjsontest.c
 @@ -938,6 +938,7 @@ testQemuMonitorJSONGetDeviceAliases(const void *data)
  
  cleanup:
  virStringFreeList(aliases);
 +qemuMonitorTestFree(test);
  return ret;
  }
  
 

ACK

Michal

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


Re: [libvirt] [PATCH 2/2] virSecurityManagerGenLabel: Skip seclabels without model

2013-07-22 Thread Eric Blake
On 07/20/2013 07:40 AM, Doug Goldstein wrote:
 On Wed, Jul 17, 2013 at 5:10 AM, Daniel P. Berrange berra...@redhat.com 
 wrote:
 On Mon, Jul 15, 2013 at 03:58:28PM +0200, Michal Privoznik wrote:
 While generating seclabels, we check the seclabel stack if required
 driver is in the stack. If not, an error is returned. However, it is
 possible for a seclabel to not have any model set (happens with LXC
 domains that have just seclabel type='none'). If that's the case,
 we should just skip the iteration instead of calling STREQ(NULL, ...)
 and SIGSEGV-ing subsequently.
 ---
  src/security/security_manager.c | 3 +++

 ACK to this one too. Even though we can fix the LXC driver in your
 first patch, adding this second patch is useful crash protection.

 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 :|

 
 Ok to push this into v1.1.0-maint as this fixes a crasher for users
 with this configuration? Should we also push the 1/2 patch?

Yes, go ahead and push both into v1.1.0-maint.

-- 
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] virsh: fix change-media bug on disk block type

2013-07-22 Thread Eric Blake
On 07/22/2013 01:40 AM, Guannan Ren wrote:
 Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=923053
 When cdrom is block type, the virsh change-media failed to insert
 source info because virsh uses source block='/dev/sdb'/ while
 the correct name of the attribute for block disks is dev.
 ---
  tools/virsh-domain.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

ACK.

 
 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
 index 606bcdf..8cafce4 100644
 --- a/tools/virsh-domain.c
 +++ b/tools/virsh-domain.c
 @@ -9866,8 +9866,10 @@ vshPrepareDiskXML(xmlNodePtr disk_node,
  
  if (source) {
  new_node = xmlNewNode(NULL, BAD_CAST source);
 -xmlNewProp(new_node, (const xmlChar *)disk_type,
 -   (const xmlChar *)source);
 +if (STREQ(disk_type, block))
 +xmlNewProp(new_node, BAD_CAST dev, BAD_CAST source);
 +else
 +xmlNewProp(new_node, BAD_CAST disk_type, BAD_CAST 
 source);
  xmlAddChild(disk_node, new_node);
  } else if (type == VSH_PREPARE_DISK_XML_INSERT) {
  vshError(NULL, _(No source is specified for inserting 
 media));
 

-- 
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] bridge driver: use more general function names

2013-07-22 Thread Roman Bogorodskiy
Continue preparation for extracting platform-specific
parts from bridge_driver: s/Iptables/Firewall/ for
firewall related function names.
---
 src/network/bridge_driver.c | 70 ++---
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 8b50659..0bb57ea 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -116,7 +116,7 @@ static int 
networkStartNetworkExternal(virNetworkDriverStatePtr driver,
 static int networkShutdownNetworkExternal(virNetworkDriverStatePtr driver,
 virNetworkObjPtr network);
 
-static void networkReloadIptablesRules(virNetworkDriverStatePtr driver);
+static void networkReloadFirewallRules(virNetworkDriverStatePtr driver);
 static void networkRefreshDaemons(virNetworkDriverStatePtr driver);
 
 static int networkPlugBandwidth(virNetworkObjPtr net,
@@ -337,7 +337,7 @@ firewalld_dbus_filter_bridge(DBusConnection *connection 
ATTRIBUTE_UNUSED,
Reloaded))
 {
 VIR_DEBUG(Reload in bridge_driver because of firewalld.);
-networkReloadIptablesRules(_driverState);
+networkReloadFirewallRules(_driverState);
 }
 
 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
@@ -428,7 +428,7 @@ networkStateInitialize(bool privileged,
 goto error;
 
 networkFindActiveConfigs(driverState);
-networkReloadIptablesRules(driverState);
+networkReloadFirewallRules(driverState);
 networkRefreshDaemons(driverState);
 networkAutostartConfigs(driverState);
 
@@ -490,7 +490,7 @@ networkStateReload(void) {
 virNetworkLoadAllConfigs(driverState-networks,
  driverState-networkConfigDir,
  driverState-networkAutostartDir);
-networkReloadIptablesRules(driverState);
+networkReloadFirewallRules(driverState);
 networkRefreshDaemons(driverState);
 networkAutostartConfigs(driverState);
 networkDriverUnlock(driverState);
@@ -1508,7 +1508,7 @@ networkRefreshDaemons(virNetworkDriverStatePtr driver)
 }
 
 static int
-networkAddMasqueradingIptablesRules(virNetworkObjPtr network,
+networkAddMasqueradingFirewallRules(virNetworkObjPtr network,
 virNetworkIpDefPtr ipdef)
 {
 int prefix = virNetworkIpDefPrefix(ipdef);
@@ -1650,7 +1650,7 @@ networkAddMasqueradingIptablesRules(virNetworkObjPtr 
network,
 }
 
 static void
-networkRemoveMasqueradingIptablesRules(virNetworkObjPtr network,
+networkRemoveMasqueradingFirewallRules(virNetworkObjPtr network,
virNetworkIpDefPtr ipdef)
 {
 int prefix = virNetworkIpDefPrefix(ipdef);
@@ -1688,7 +1688,7 @@ networkRemoveMasqueradingIptablesRules(virNetworkObjPtr 
network,
 }
 
 static int
-networkAddRoutingIptablesRules(virNetworkObjPtr network,
+networkAddRoutingFirewallRules(virNetworkObjPtr network,
virNetworkIpDefPtr ipdef)
 {
 int prefix = virNetworkIpDefPrefix(ipdef);
@@ -1735,7 +1735,7 @@ routeerr1:
 }
 
 static void
-networkRemoveRoutingIptablesRules(virNetworkObjPtr network,
+networkRemoveRoutingFirewallRules(virNetworkObjPtr network,
   virNetworkIpDefPtr ipdef)
 {
 int prefix = virNetworkIpDefPrefix(ipdef);
@@ -1857,7 +1857,7 @@ networkRemoveGeneralIp6tablesRules(virNetworkObjPtr 
network)
 }
 
 static int
-networkAddGeneralIptablesRules(virNetworkObjPtr network)
+networkAddGeneralFirewallRules(virNetworkObjPtr network)
 {
 size_t i;
 virNetworkIpDefPtr ipv4def;
@@ -1979,7 +1979,7 @@ err1:
 }
 
 static void
-networkRemoveGeneralIptablesRules(virNetworkObjPtr network)
+networkRemoveGeneralFirewallRules(virNetworkObjPtr network)
 {
 size_t i;
 virNetworkIpDefPtr ipv4def;
@@ -2009,7 +2009,7 @@ networkRemoveGeneralIptablesRules(virNetworkObjPtr 
network)
 }
 
 static int
-networkAddIpSpecificIptablesRules(virNetworkObjPtr network,
+networkAddIpSpecificFirewallRules(virNetworkObjPtr network,
   virNetworkIpDefPtr ipdef)
 {
 /* NB: in the case of IPv6, routing rules are added when the
@@ -2018,46 +2018,46 @@ networkAddIpSpecificIptablesRules(virNetworkObjPtr 
network,
 
 if (network-def-forward.type == VIR_NETWORK_FORWARD_NAT) {
 if (VIR_SOCKET_ADDR_IS_FAMILY(ipdef-address, AF_INET))
-return networkAddMasqueradingIptablesRules(network, ipdef);
+return networkAddMasqueradingFirewallRules(network, ipdef);
 else if (VIR_SOCKET_ADDR_IS_FAMILY(ipdef-address, AF_INET6))
-return networkAddRoutingIptablesRules(network, ipdef);
+return networkAddRoutingFirewallRules(network, ipdef);
 } else if (network-def-forward.type == VIR_NETWORK_FORWARD_ROUTE) {
-return networkAddRoutingIptablesRules(network, ipdef);
+return networkAddRoutingFirewallRules(network, ipdef);
 }
 return 

[libvirt] [PATCH] Add virDBusMessage(Encode,Decode) stubs

2013-07-22 Thread Roman Bogorodskiy
Commit 834c9c94 introduced virDBusMessageEncode and
virDBusMessageDecode functions, however corresponding stubs
were not added to !WITH_DBUS section, therefore 'make check'
started to fail when compiled w/out dbus support like that:

Expected symbol virDBusMessageDecode is not in ELF library
---
 src/util/virdbus.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/src/util/virdbus.c b/src/util/virdbus.c
index ee99f7f..6221bdc 100644
--- a/src/util/virdbus.c
+++ b/src/util/virdbus.c
@@ -1222,4 +1222,22 @@ int virDBusMessageRead(DBusMessage *msg ATTRIBUTE_UNUSED,
 return -1;
 }
 
+int virDBusMessageEncode(DBusMessage* msg ATTRIBUTE_UNUSED,
+ const char *types ATTRIBUTE_UNUSED,
+ ...)
+{
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   %s, _(DBus support not compiled into this binary));
+return -1;
+}
+
+int virDBusMessageDecode(DBusMessage* msg ATTRIBUTE_UNUSED,
+ const char *types ATTRIBUTE_UNUSED,
+ ...)
+{
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   %s, _(DBus support not compiled into this binary));
+return -1;
+}
+
 #endif /* ! WITH_DBUS */
-- 
1.8.1.4

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


Re: [libvirt] [Qemu-devel] [Question] why x2apic's set by default without host support(on Nehalem CPU).

2013-07-22 Thread Eduardo Habkost
On Mon, Jul 22, 2013 at 07:24:24PM +0800, Peter Huang(Peng) wrote:
 Hi, Everyone
 
 I have been encountered a problem recently.
 My box uses Nehalem E5520 CPU, and this model doesn't support x2apic feature.
 I created a VM on KVM, and uses cpu mode=pass-through, I can get the right cpu
 model from the VM, but I can also see that the CPU in the vm supports x2apic.
 
 This seems werid.
 From QEMU's CPU model definition, Nehalem also doesn't support x2apic.
 
 Can anyone explain it?
 

libvirt's host-passthrough uses -cpu host', and it -cpu host
enables every feature that can be enabled on the host. As KVM x2apic
emulation doesn't require host CPU support, it gets enabled.

If the behavior of -cpu host doesn't match libvirt expectations, we
need to clarify what are the requirements, and maybe have a try to be
close to host CPU mode as opposed to the current enable everything
that can be enabled mode.

-- 
Eduardo

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


Re: [libvirt] [PATCH v3 0/7] Support to use iscsi storage in domain conf

2013-07-22 Thread John Ferlan
On 07/19/2013 08:32 AM, John Ferlan wrote:
 An update to yesterday's posting:
 
 https://www.redhat.com/archives/libvir-list/2013-July/msg01213.html
 
 Changes in v3 over v2
  * Update patch 1 per code review
  * Use 'direct' instead of 'uri' and supporting documentaiton
  * In patch 4, use qemuAddISCSIPoolSourceHost() instead of
qemuAddDiskISCSIUri.  Also added a check in the function 
that (pooldef-source.nhost != 1) to make sure we at least
have a host defined in the pool and of course that there's
only one.
 
 
 John Ferlan (5):
   storage_iscsi: Reflect the default target port
   conf: Introduce new XML tag mode for disk source
   conf: Introduce virDomainDiskSourceIsBlockType
   qemu: Translate the iscsi pool/volume disk source
   tests: Add various network and volume definitions
 
 Osier Yang (2):
   conf: Ignore the volume type disk if its mode is direct
   qemu: Translate the volume type disk source before cgroup setting
 
  docs/formatdomain.html.in  |  11 +-
  docs/schemas/domaincommon.rng  |   8 ++
  src/conf/domain_conf.c |  67 ++-
  src/conf/domain_conf.h |  26 +
  src/libvirt_private.syms   |   1 +
  src/qemu/qemu_command.c|  20 +++-
  src/qemu/qemu_conf.c   | 124 
 +
  src/qemu/qemu_process.c|  13 ++-
  src/storage/storage_backend_iscsi.c|  19 ++--
  .../qemuxml2argv-disk-source-pool-mode.xml |  48 
  tests/qemuxml2xmltest.c|   1 +
  tests/securityselinuxlabeldata/netdisks.txt|   5 +
  tests/securityselinuxlabeldata/netdisks.xml|  58 ++
  tests/securityselinuxlabeldata/voldisks.txt|   5 +
  tests/securityselinuxlabeldata/voldisks.xml|  45 
  tests/securityselinuxlabeltest.c   |   2 +
  16 files changed, 414 insertions(+), 39 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-disk-source-pool-mode.xml
  create mode 100644 tests/securityselinuxlabeldata/netdisks.txt
  create mode 100644 tests/securityselinuxlabeldata/netdisks.xml
  create mode 100644 tests/securityselinuxlabeldata/voldisks.txt
  create mode 100644 tests/securityselinuxlabeldata/voldisks.xml
 

I pushed patches 1-4, 6,  7.  Will wait for more feedback on 5.

Thanks for the reviews.

John

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


Re: [libvirt] [Xen-devel] [PATCH] libxl: Correctly initialize vcpu bitmap

2013-07-22 Thread Konrad Rzeszutek Wilk
On Mon, Jul 22, 2013 at 12:51:05PM +0200, Stefan Bader wrote:
 This fixes the basic setup but there is likely more to do if things
 like manual CPU hirarchy (nodes, cores, threads) to be working.
 
 Cross-posting to xen-devel to make sure I am doing things correctly.
 
 -Stefan
 
 
 From 1ec5e7ea0d3498b9f61b83e8aed87cc3cae106de Mon Sep 17 00:00:00 2001
 From: Stefan Bader stefan.ba...@canonical.com
 Date: Fri, 19 Jul 2013 15:20:00 +0200
 Subject: [PATCH] libxl: Correctly initialize vcpu bitmap
 
 The avai_vcpu bitmap has to be allocated before it can be used (using

avail_vcpu ?

 the maximum allowed value for that). Then for each available VCPU the
 bit in the mask has to be set (libxl_bitmap_set takes a bit position
 as an argument, not the number of bits to set).
 
 Without this, I would always only get one VCPU for guests created
 through libvirt/libxl.
 
 Signed-off-by: Stefan Bader stefan.ba...@canonical.com

The libxl calling logic looks Ok to me. So from the libxl perspective
you can tack on Reviewed-by: Konrad Rzeszutek Wilk konrad.w...@oracle.com

 ---
  src/libxl/libxl_conf.c |   14 +++---
  1 file changed, 11 insertions(+), 3 deletions(-)
 
 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
 index 4a0fba9..7592dd2 100644
 --- a/src/libxl/libxl_conf.c
 +++ b/src/libxl/libxl_conf.c
 @@ -331,7 +331,8 @@ error:
  }
  
  static int
 -libxlMakeDomBuildInfo(virDomainDefPtr def, libxl_domain_config *d_config)
 +libxlMakeDomBuildInfo(libxlDriverPrivatePtr driver, virDomainDefPtr def,
 +  libxl_domain_config *d_config)
  {
  libxl_domain_build_info *b_info = d_config-b_info;
  int hvm = STREQ(def-os.type, hvm);
 @@ -343,8 +344,15 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, 
 libxl_domain_config *d_config)
  libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_HVM);
  else
  libxl_domain_build_info_init_type(b_info, LIBXL_DOMAIN_TYPE_PV);
 +
  b_info-max_vcpus = def-maxvcpus;
 -libxl_bitmap_set((b_info-avail_vcpus), def-vcpus);
 +if (libxl_cpu_bitmap_alloc(driver-ctx, b_info-avail_vcpus,
 +   def-maxvcpus))
 +goto error;
 +libxl_bitmap_set_none(b_info-avail_vcpus);
 +for (i = 0; i  def-vcpus; i++)
 +libxl_bitmap_set((b_info-avail_vcpus), i);
 +
  if (def-clock.ntimers  0 
  def-clock.timers[0]-name == VIR_DOMAIN_TIMER_NAME_TSC) {
  switch (def-clock.timers[0]-mode) {
 @@ -802,7 +810,7 @@ libxlBuildDomainConfig(libxlDriverPrivatePtr driver,
  if (libxlMakeDomCreateInfo(driver, def, d_config-c_info)  0)
  return -1;
  
 -if (libxlMakeDomBuildInfo(def, d_config)  0) {
 +if (libxlMakeDomBuildInfo(driver, def, d_config)  0) {
  return -1;
  }
  
 -- 
 1.7.9.5
 
 
 ___
 Xen-devel mailing list
 xen-de...@lists.xen.org
 http://lists.xen.org/xen-devel

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


[libvirt] [PATCH v5 1/5] qemu: Add source pool auth info to virDomainDiskDef for iSCSI

2013-07-22 Thread John Ferlan
During qemuTranslateDiskSourcePool() execution, if the srcpool has been
defined with authentication information, then for iSCSI pools copy the
authentication and host information to virDomainDiskDef.
---
 src/qemu/qemu_conf.c | 55 
 1 file changed, 55 insertions(+)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 6e6163f..3e7b78a 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1186,6 +1186,58 @@ cleanup:
 return ret;
 }
 
+static int
+qemuTranslateDiskSourcePoolAuth(virDomainDiskDefPtr def,
+virStoragePoolDefPtr pooldef)
+{
+int ret = -1;
+
+/* Only necessary when authentication set */
+if (pooldef-source.authType == VIR_STORAGE_POOL_AUTH_NONE) {
+ret = 0;
+goto cleanup;
+}
+
+/* Copy the authentication information from the storage pool
+ * into the virDomainDiskDef
+ */
+if (pooldef-source.authType == VIR_STORAGE_POOL_AUTH_CHAP) {
+if (VIR_STRDUP(def-auth.username,
+   pooldef-source.auth.chap.username)  0)
+goto cleanup;
+if (pooldef-source.auth.chap.secret.uuidUsable) {
+def-auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
+memcpy(def-auth.secret.uuid,
+   pooldef-source.auth.chap.secret.uuid,
+   VIR_UUID_BUFLEN);
+} else {
+if (VIR_STRDUP(def-auth.secret.usage,
+   pooldef-source.auth.chap.secret.usage)  0)
+goto cleanup;
+def-auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
+}
+} else if (pooldef-source.authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
+if (VIR_STRDUP(def-auth.username,
+   pooldef-source.auth.cephx.username)  0)
+goto cleanup;
+if (pooldef-source.auth.cephx.secret.uuidUsable) {
+def-auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_UUID;
+memcpy(def-auth.secret.uuid,
+   pooldef-source.auth.cephx.secret.uuid,
+   VIR_UUID_BUFLEN);
+} else {
+if (VIR_STRDUP(def-auth.secret.usage,
+   pooldef-source.auth.cephx.secret.usage)  0)
+goto cleanup;
+def-auth.secretType = VIR_DOMAIN_DISK_SECRET_TYPE_USAGE;
+}
+}
+ret = 0;
+
+cleanup:
+return ret;
+}
+
 int
 qemuTranslateDiskSourcePool(virConnectPtr conn,
 virDomainDiskDefPtr def)
@@ -1254,6 +1306,9 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
 if (!(def-src = virStorageVolGetPath(vol)))
 goto cleanup;
 }
+
+if (qemuTranslateDiskSourcePoolAuth(def, pooldef)  0)
+goto cleanup;
 } else {
 if (!(def-src = virStorageVolGetPath(vol)))
 goto cleanup;
-- 
1.8.1.4

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


[libvirt] [PATCH v5 5/5] Adjust 'ceph' authentication secret usage for rbd pool.

2013-07-22 Thread John Ferlan
Update virStorageBackendRBDOpenRADOSConn() to use the internal API to the
secret driver in order to get the secret value instead of the external
virSecretGetValue() path. Without the flag VIR_SECRET_GET_VALUE_INTERNAL_CALL
there is no way to get the value of private secret.

This also requires ensuring there is a connection which wasn't true for
for the refreshPool() path calls from storageDriverAutostart() prior to
adding support for the connection to a qemu driver. It seems calls to
virSecretLookupByUUIDString() and virSecretLookupByUsage() from the
refreshPool() path would have failed with no way to find the secret - that is
theoretically speaking since the 'conn' was NULL the failure would have been
failed to find the secret.
---
 src/storage/storage_backend_rbd.c | 21 +++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/storage/storage_backend_rbd.c 
b/src/storage/storage_backend_rbd.c
index badbdac..70121bf 100644
--- a/src/storage/storage_backend_rbd.c
+++ b/src/storage/storage_backend_rbd.c
@@ -23,6 +23,7 @@
 
 #include config.h
 
+#include datatypes.h
 #include virerror.h
 #include storage_backend_rbd.h
 #include storage_conf.h
@@ -71,6 +72,12 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
 goto cleanup;
 }
 
+if (!conn) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _('ceph' authentication requires connection));
+return -1;
+}
+
 if (pool-def-source.auth.cephx.secret.uuidUsable) {
 virUUIDFormat(pool-def-source.auth.cephx.secret.uuid, 
secretUuid);
 VIR_DEBUG(Looking up secret by UUID: %s, secretUuid);
@@ -88,7 +95,17 @@ static int 
virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDStatePtr *ptr,
 goto cleanup;
 }
 
-secret_value = virSecretGetValue(secret, secret_value_size, 0);
+secret_value = conn-secretDriver-secretGetValue(secret, 
secret_value_size, 0,
+  
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
+
+if (!secret_value) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(could not get the value of the secret 
+ for username %s),
+   pool-def-source.auth.cephx.username);
+goto cleanup;
+}
+
 base64_encode_alloc((char *)secret_value,
 secret_value_size, rados_key);
 memset(secret_value, 0, secret_value_size);
@@ -257,7 +274,7 @@ cleanup:
 return ret;
 }
 
-static int virStorageBackendRBDRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
+static int virStorageBackendRBDRefreshPool(virConnectPtr conn,
virStoragePoolObjPtr pool)
 {
 size_t max_size = 1024;
-- 
1.8.1.4

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


[libvirt] [PATCH v5 2/5] qemu: Create a common qemuGetSecretString

2013-07-22 Thread John Ferlan
Make the secret fetching code common for qemuBuildRBDString() and
qemuBuildDriveURIString() using the virDomainDiskDef.
---
 src/qemu/qemu_command.c | 157 +---
 1 file changed, 81 insertions(+), 76 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4a49d81..5bd8e87 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2457,6 +2457,61 @@ qemuSafeSerialParamValue(const char *value)
 return 0;
 }
 
+static char *
+qemuGetSecretString(virConnectPtr conn,
+const char *scheme,
+bool encoded,
+int diskSecretType,
+char *username,
+unsigned char *uuid, char *usage,
+virSecretUsageType secretUsageType)
+{
+size_t secret_size;
+virSecretPtr sec = NULL;
+char *secret = NULL;
+
+/* look up secret */
+switch (diskSecretType) {
+case VIR_DOMAIN_DISK_SECRET_TYPE_UUID:
+sec = virSecretLookupByUUID(conn, uuid);
+break;
+case VIR_DOMAIN_DISK_SECRET_TYPE_USAGE:
+sec = virSecretLookupByUsage(conn, secretUsageType, usage);
+break;
+}
+
+if (!sec) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(%s username '%s' specified but secret not found),
+   scheme, username);
+goto cleanup;
+}
+
+secret = (char *)conn-secretDriver-secretGetValue(sec, secret_size, 0,
+
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
+if (!secret) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(could not get value of the secret for username %s),
+   username);
+goto cleanup;
+}
+
+if (encoded) {
+char *base64 = NULL;
+
+base64_encode_alloc(secret, secret_size, base64);
+VIR_FREE(secret);
+if (!base64) {
+virReportOOMError();
+goto cleanup;
+}
+secret = base64;
+}
+
+cleanup:
+virObjectUnref(sec);
+return secret;
+}
 
 static int
 qemuBuildRBDString(virConnectPtr conn,
@@ -2465,9 +2520,7 @@ qemuBuildRBDString(virConnectPtr conn,
 {
 size_t i;
 int ret = 0;
-virSecretPtr sec = NULL;
 char *secret = NULL;
-size_t secret_size;
 
 if (strchr(disk-src, ':')) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -2478,47 +2531,23 @@ qemuBuildRBDString(virConnectPtr conn,
 
 virBufferEscape(opt, ',', ,, rbd:%s, disk-src);
 if (disk-auth.username) {
+
 virBufferEscape(opt, '\\', :, :id=%s, disk-auth.username);
-/* look up secret */
-switch (disk-auth.secretType) {
-case VIR_DOMAIN_DISK_SECRET_TYPE_UUID:
-sec = virSecretLookupByUUID(conn,
-disk-auth.secret.uuid);
-break;
-case VIR_DOMAIN_DISK_SECRET_TYPE_USAGE:
-sec = virSecretLookupByUsage(conn,
- VIR_SECRET_USAGE_TYPE_CEPH,
- disk-auth.secret.usage);
-break;
-}
+/* Get the secret string using the virDomainDiskDef 
+ * NOTE: qemu/librbd wants it base64 encoded
+ */
+if (!(secret = qemuGetSecretString(conn, rbd, true,
+   disk-auth.secretType,
+   disk-auth.username,
+   disk-auth.secret.uuid,
+   disk-auth.secret.usage,
+   VIR_SECRET_USAGE_TYPE_CEPH)))
+goto error;
 
-if (sec) {
-char *base64 = NULL;
 
-secret = (char *)conn-secretDriver-secretGetValue(sec, 
secret_size, 0,
-
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
-if (secret == NULL) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(could not get the value of the secret for 
username %s),
-   disk-auth.username);
-goto error;
-}
-/* qemu/librbd wants it base64 encoded */
-base64_encode_alloc(secret, secret_size, base64);
-if (!base64) {
-virReportOOMError();
-goto error;
-}
-virBufferEscape(opt, '\\', :,
-:key=%s:auth_supported=cephx\\;none,
-base64);
-VIR_FREE(base64);
-} else {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(%s username '%s' specified but secret not 
found),
-   rbd, disk-auth.username);
-goto error;
-}
+virBufferEscape(opt, '\\', :,
+

[libvirt] [PATCH v5 3/5] qemu_common: Create qemuBuildVolumeString() to process storage pool

2013-07-22 Thread John Ferlan
Split out into its own separate routine
---
 src/qemu/qemu_command.c | 108 
 1 file changed, 64 insertions(+), 44 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5bd8e87..ac275c3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3037,6 +3037,68 @@ qemuBuildNBDString(virConnectPtr conn, 
virDomainDiskDefPtr disk, virBufferPtr op
 return 0;
 }
 
+static int
+qemuBuildVolumeString(virConnectPtr conn,
+  virDomainDiskDefPtr disk,
+  virBufferPtr opt)
+{
+int ret = -1;
+
+switch (disk-srcpool-voltype) {
+case VIR_STORAGE_VOL_DIR:
+if (!disk-readonly) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(cannot create virtual FAT disks in read-write 
mode));
+goto cleanup;
+}
+if (disk-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
+virBufferEscape(opt, ',', ,, file=fat:floppy:%s,, disk-src);
+else
+virBufferEscape(opt, ',', ,, file=fat:%s,, disk-src);
+break;
+case VIR_STORAGE_VOL_BLOCK:
+if (disk-tray_status == VIR_DOMAIN_DISK_TRAY_OPEN) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(tray status 'open' is invalid for 
+ block type volume));
+goto cleanup;
+}
+if (disk-srcpool-pooltype == VIR_STORAGE_POOL_ISCSI) {
+if (disk-srcpool-mode ==
+VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT) {
+if (qemuBuildISCSIString(conn, disk, opt)  0)
+goto cleanup;
+virBufferAddChar(opt, ',');
+} else if (disk-srcpool-mode ==
+   VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST) {
+virBufferEscape(opt, ',', ,, file=%s,, disk-src);
+}
+} else {
+virBufferEscape(opt, ',', ,, file=%s,, disk-src);
+}
+break;
+case VIR_STORAGE_VOL_FILE:
+if (disk-auth.username) {
+if (qemuBuildISCSIString(conn, disk, opt)  0)
+goto cleanup;
+virBufferAddChar(opt, ',');
+} else {
+virBufferEscape(opt, ',', ,, file=%s,, disk-src);
+}
+break;
+case VIR_STORAGE_VOL_NETWORK:
+/* Keep the compiler quite, qemuTranslateDiskSourcePool already
+ * reported the unsupported error.
+ */
+break;
+}
+
+ret = 0;
+
+cleanup:
+return ret;
+}
+
 char *
 qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
   virDomainDiskDefPtr disk,
@@ -3191,50 +3253,8 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
 break;
 }
 } else if (disk-type == VIR_DOMAIN_DISK_TYPE_VOLUME) {
-switch (disk-srcpool-voltype) {
-case VIR_STORAGE_VOL_DIR:
-if (!disk-readonly) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(cannot create virtual FAT disks in 
read-write mode));
-goto error;
-}
-if (disk-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
-virBufferEscape(opt, ',', ,, file=fat:floppy:%s,,
-disk-src);
-else
-virBufferEscape(opt, ',', ,, file=fat:%s,, disk-src);
-break;
-case VIR_STORAGE_VOL_BLOCK:
-if (disk-tray_status == VIR_DOMAIN_DISK_TRAY_OPEN) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(tray status 'open' is invalid for 
- block type volume));
-goto error;
-}
-
-if (disk-srcpool-pooltype == VIR_STORAGE_POOL_ISCSI) {
-if (disk-srcpool-mode ==
-VIR_DOMAIN_DISK_SOURCE_POOL_MODE_DIRECT) {
-if (qemuBuildISCSIString(conn, disk, opt)  0)
-goto error;
-virBufferAddChar(opt, ',');
-} else if (disk-srcpool-mode ==
-   VIR_DOMAIN_DISK_SOURCE_POOL_MODE_HOST) {
-virBufferEscape(opt, ',', ,, file=%s,, disk-src);
-}
-} else {
-virBufferEscape(opt, ',', ,, file=%s,, disk-src);
-}
-break;
-case VIR_STORAGE_VOL_FILE:
-virBufferEscape(opt, ',', ,, file=%s,, disk-src);
-break;
-case VIR_STORAGE_VOL_NETWORK:
-/* Keep the compiler quite, qemuTranslateDiskSourcePool already
- * reported the unsupported error.
- */
-break;
-}
+if 

[libvirt] [PATCH v5 0/5] Support CHAP authentication for iscsi pool

2013-07-22 Thread John Ferlan
This is a reworking and reposting of the authentication patches originally
posted as part of my v3 reworking of Osier's original patches, see:

https://www.redhat.com/archives/libvir-list/2013-July/msg00894.html

Patch 7/7 was noted to be incorrect since the authentication was in the
wrong place in the backend driver, see v3:

https://www.redhat.com/archives/libvir-list/2013-July/msg00901.html

and followups from my v2 posting:

https://www.redhat.com/archives/libvir-list/2013-July/msg00910.html

NOTE:
Patch 4 (https://www.redhat.com/archives/libvir-list/2013-July/msg00960.html)
was scrapped.

Adjustments from previous patches
1. Using the same logic as Direct iSCSI, add the pool authentication info
   from the iSCSI pool to virDomainDiskDef's during qemuTranslateDiskSourcePool
2. Refactor the secret fetching code into one function for easier use
3. Refactor the volume building code into one function for easier use. This
   is where the magic to add the auth information to the disk occurs and now
   that it's part of the disk definition from the pool it will just 'be there'
4. Restore original intent to use startPool callback in order to authenticate
   the pool.  Added a check for NULL connection.  This just stops autostarting
   pools from getting authentication. This still needs to be fixed/resolved,
   but there just wasn't time in this release for that.
5. Split the rbd authentication code into it's own patch rather than being
   part of the iscsi patch 4.
 
John Ferlan (5):
  qemu: Add source pool auth info to virDomainDiskDef for iSCSI
  qemu: Create a common qemuGetSecretString
  qemu_common: Create qemuBuildVolumeString() to process storage pool
  storage: Support chap authentication for iscsi pool
  Adjust 'ceph' authentication secret usage for rbd pool.

 src/qemu/qemu_command.c | 265 
 src/qemu/qemu_conf.c|  55 
 src/storage/storage_backend_iscsi.c | 111 ++-
 src/storage/storage_backend_rbd.c   |  21 ++-
 4 files changed, 329 insertions(+), 123 deletions(-)

-- 
1.8.1.4

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


[libvirt] [PATCH v5 4/5] storage: Support chap authentication for iscsi pool

2013-07-22 Thread John Ferlan
Although the XML for CHAP authentication with plain password
was introduced long ago, the function was never implemented. This
patch replaces the login/password mechanism by following the
'ceph' (or RBD) model of using a 'username' with a 'secret' which
has the authentication information.

This patch performs the authentication during startPool() processing
of pools with an authType of VIR_STORAGE_POOL_AUTH_CHAP specified
for iSCSI pools.

There are two types of CHAP configurations supported for iSCSI
authentication:

  * Initiator Authentication
  Forward, one-way; The initiator is authenticated by the target.

  * Target Authentication
  Reverse, Bi-directional, mutual, two-way; The target is authenticated
  by the initiator; This method also requires Initiator Authentication

This only supports the Initiator Authentication. (I don't have any
enterprise iSCSI env for testing, only have a iSCSI target setup with
tgtd, which doesn't support Target Authentication).

Discovery authentication is not supported by tgt yet too. So this only
setup the session authentication by executing 3 iscsiadm commands, E.g:

% iscsiadm -m node --target iqn.2013-05.test:iscsi.foo --name \
  node.session.auth.authmethod -v CHAP --op update

% iscsiadm -m node --target iqn.2013-05.test:iscsi.foo --name \
  node.session.auth.username -v Jim --op update

% iscsiadm -m node --target iqn.2013-05.test:iscsi.foo --name \
  node.session.auth.password -v Jimsecret --op update
---
 src/storage/storage_backend_iscsi.c | 111 +++-
 1 file changed, 110 insertions(+), 1 deletion(-)

diff --git a/src/storage/storage_backend_iscsi.c 
b/src/storage/storage_backend_iscsi.c
index 54bcd14..388d6ed 100644
--- a/src/storage/storage_backend_iscsi.c
+++ b/src/storage/storage_backend_iscsi.c
@@ -32,6 +32,8 @@
 #include unistd.h
 #include sys/stat.h
 
+#include datatypes.h
+#include driver.h
 #include virerror.h
 #include storage_backend_scsi.h
 #include storage_backend_iscsi.h
@@ -39,6 +41,7 @@
 #include virlog.h
 #include virfile.h
 #include vircommand.h
+#include virobject.h
 #include virrandom.h
 #include virstring.h
 
@@ -658,9 +661,112 @@ virStorageBackendISCSICheckPool(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 return ret;
 }
 
+static int
+virStorageBackendISCSINodeUpdate(const char *portal,
+ const char *target,
+ const char *name,
+ const char *value)
+{
+ virCommandPtr cmd = NULL;
+ int status;
+ int ret = -1;
+
+ cmd = virCommandNewArgList(ISCSIADM,
+--mode, node,
+--portal, portal,
+--target, target,
+--op, update,
+--name, name,
+--value, value,
+NULL);
+
+if (virCommandRun(cmd, status)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Failed to update '%s' of node mode for target '%s'),
+   name, target);
+goto cleanup;
+}
+
+ret = 0;
+cleanup:
+virCommandFree(cmd);
+return ret;
+}
 
 static int
-virStorageBackendISCSIStartPool(virConnectPtr conn ATTRIBUTE_UNUSED,
+virStorageBackendISCSISetAuth(const char *portal,
+  virConnectPtr conn,
+  virStoragePoolDefPtr def)
+{
+virSecretPtr secret = NULL;
+unsigned char *secret_value = NULL;
+virStoragePoolAuthChap chap;
+int ret = -1;
+
+if (def-source.authType == VIR_STORAGE_POOL_AUTH_NONE)
+return 0;
+
+if (def-source.authType != VIR_STORAGE_POOL_AUTH_CHAP) {
+virReportError(VIR_ERR_XML_ERROR, %s,
+   _(iscsi pool only supports 'chap' auth type));
+return -1;
+}
+
+if (!conn) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(iscsi 'chap' authentication requires connection));
+return -1;
+}
+
+chap = def-source.auth.chap;
+if (chap.secret.uuidUsable)
+secret = virSecretLookupByUUID(conn, chap.secret.uuid);
+else
+secret = virSecretLookupByUsage(conn, VIR_SECRET_USAGE_TYPE_ISCSI,
+chap.secret.usage);
+
+if (secret) {
+size_t secret_size;
+secret_value =
+conn-secretDriver-secretGetValue(secret, secret_size, 0,
+   
VIR_SECRET_GET_VALUE_INTERNAL_CALL);
+if (!secret_value) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(could not get the value of the secret 
+ for username %s), chap.username);
+goto cleanup;
+}
+} else {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(username '%s' specified but secret not found),
+