[libvirt] PATCH: pci-subsystem: ixgbe: SR-IOV: kernel way to order driver's virtfn -entries is odd causing libvirt failures.

2013-10-24 Thread Niilona
Hi.

As Bjorn Helgaas recommend, this might be the item to discuss in the wider area.
---

There is a behavior effecting virtfn -entries in sysfs, when amount of
them increases over 10.
Run VM's through LIBVIRT - QEMU/KVM, this causes :
- MAC address setting by LIBVIRT disordered ie. setting targeted to wrong VF.
- VLAN setting by LIBVIRT overall failed

Basics of this are in /libvirt-x.x.x/src/util/virpci.c ; in function below,
which don't order virtfn entries correctly.

/*
 * Returns virtual functions of a physical function
 */
int
virPCIGetVirtualFunctions(const char *sysfs_path,
  virPCIDeviceAddressPtr **virtual_functions,
  unsigned int *num_virtual_functions)
{

But I let you to decide which is best way to fix this, as if every
application reads virtfn entries from PF's directory, they all need
to sort entries in alphabet. order to avoid this
influence.
So personally I did get over this by adding pre-zeroes to names to
have them in sorted order in PF's directory.



Tested :
- kernel 3.8.0-21
- libvirt 1.0.2  libvirt 1.1.3
- ixgbe 3.11.33-k, ixgbe 3.17-3  ixgbe 3.18.7

After applying this MAC/VLAN seen to work and VM's get contacted using
MAC's  VLAN's, which been checked using tcpdump.

P.S. Tested with 3.8.0-21, but patch constructed against
https://github.com/torvalds/linux.git;, so there is possibilty this
works in latest kernel, but haven't checked it.
At least ordering scheme seen in iov.c in same form as before.

-

From fac886b86099dca1937730026da24c34857c4077 Mon Sep 17 00:00:00 2001
From: Niilo Minkkinen niilo.minkki...@tieto.com
Date: Wed, 23 Oct 2013 14:50:07 +0300
Subject: [PATCH 1/1] Fixes ordering of virtfn -entries on drivers with more
 than 10 entries ( virtfn0...virtfn9 ).

This effects on drivers like Intel 82599 ixgbe, which have max 31
VF's (Virtual Function) on
one PF (Physical Function).
Currently, ordering is diffused, which in case causes MAC/VLAN
-settings on libvirt based
to PCI -addressing failed.

Signed-off-by: Niilo Minkkinen niilo.minkki...@tieto.com
Signed-off-by: Tommy Varre tommy.va...@tieto.com
---
 drivers/pci/iov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 21a7182..fbd1209 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id,
int reset)
mutex_unlock(iov-dev-sriov-lock);

rc = pci_bus_add_device(virtfn);
-   sprintf(buf, virtfn%u, id);
+   sprintf(buf, virtfn%02u, id);
rc = sysfs_create_link(dev-dev.kobj, virtfn-dev.kobj, buf);
if (rc)
goto failed1;
@@ -149,7 +149,7 @@ static void virtfn_remove(struct pci_dev *dev, int
id, int reset)
__pci_reset_function(virtfn);
}

-   sprintf(buf, virtfn%u, id);
+   sprintf(buf, virtfn%02u, id);
sysfs_remove_link(dev-dev.kobj, buf);
/*
 * pci_stop_dev() could have been called for this virtfn already,
-- 
1.8.1.2

-

What you think ?

Niilo Minkkinen
niilo.minkki...@tieto.com

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


[libvirt] [PATCH] virsh domxml-from-native to treat SCSI as the bus type for pseries by default

2013-10-24 Thread Shivaprasad G Bhat
From: Shivaprasad G Bhat sb...@linux.vnet.ibm.com

The bus type IDE being enum Zero, the bus type on pseries system appears as IDE 
for all the disk types. Pseries platform needs this to appear as SCSI instead 
of IDE.

Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com
---
 src/qemu/qemu_command.c |   21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index abb62e9..728409f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9995,6 +9995,7 @@ error:
 static virDomainDiskDefPtr
 qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
  const char *val,
+virDomainDefPtr dom,
  int nvirtiodisk,
  bool old_style_ceph_args)
 {
@@ -10018,7 +10019,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
 if (VIR_ALLOC(def)  0)
 goto cleanup;
 
-def-bus = VIR_DOMAIN_DISK_BUS_IDE;
+if (((dom-os.arch == VIR_ARCH_PPC64) 
+ dom-os.machine  STREQ(dom-os.machine, pseries)))
+def-bus = VIR_DOMAIN_DISK_BUS_SCSI;
+else
+   def-bus = VIR_DOMAIN_DISK_BUS_IDE;
 def-device = VIR_DOMAIN_DISK_DEVICE_DISK;
 def-type = VIR_DOMAIN_DISK_TYPE_FILE;
 
@@ -11332,8 +11337,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
 disk-type = VIR_DOMAIN_DISK_TYPE_FILE;
 if (STREQ(arg, -cdrom)) {
 disk-device = VIR_DOMAIN_DISK_DEVICE_CDROM;
-if (VIR_STRDUP(disk-dst, hdc)  0)
-goto error;
+   if (((def-os.arch == VIR_ARCH_PPC64) 
+ def-os.machine  STREQ(def-os.machine, pseries))) {
+disk-bus = VIR_DOMAIN_DISK_BUS_SCSI;
+   if (VIR_STRDUP(disk-dst, sdc)  0)
+   goto error;
+   } else if (VIR_STRDUP(disk-dst, hdc)  0)
+   goto error;
 disk-readonly = true;
 } else {
 if (STRPREFIX(arg, -fd)) {
@@ -11345,6 +11355,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
 disk-bus = VIR_DOMAIN_DISK_BUS_IDE;
 else
 disk-bus = VIR_DOMAIN_DISK_BUS_SCSI;
+   if (((def-os.arch == VIR_ARCH_PPC64) 
+   def-os.machine  STREQ(def-os.machine, pseries)))
+   disk-bus = VIR_DOMAIN_DISK_BUS_SCSI;
 }
 if (VIR_STRDUP(disk-dst, arg + 1)  0)
 goto error;
@@ -11636,7 +11649,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
 }
 } else if (STREQ(arg, -drive)) {
 WANT_VALUE();
-if (!(disk = qemuParseCommandLineDisk(xmlopt, val,
+if (!(disk = qemuParseCommandLineDisk(xmlopt, val, def,
   nvirtiodisk,
   ceph_args != NULL)))
 goto error;

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


[libvirt] [PATCHv2 0/2] virsh: hide 'attach-disk --shareable'

2013-10-24 Thread Eric Blake
As promised here:
https://www.redhat.com/archives/libvir-list/2013-October/msg01047.html

Eric Blake (2):
  virsh: allow alias to expand to opt=value pair
  virsh: undocument --shareable (--mode already covers it)

 tests/virshtest.c|  1 +
 tools/virsh-domain.c | 11 --
 tools/virsh.c| 58 
 tools/virsh.pod  |  4 ++--
 4 files changed, 57 insertions(+), 17 deletions(-)

-- 
1.8.3.1

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


[libvirt] [PATCHv2 2/2] virsh: undocument --shareable (--mode already covers it)

2013-10-24 Thread Eric Blake
Commit e962a57 added 'attach-disk --shareable', even though we
already had 'attach-disk --mode=shareable'.  Worse, if the user
types 'attach-disk --mode=readonly --shareable', we create
non-sensical XML.  The best solution is just to undocument the
duplicate spelling, by having it fall back to the preferred
spelling.

* tools/virsh-domain.c (cmdAttachDisk): Let alias handling fix our
mistake in exposing a second spelling for an existing option.
* tools/virsh.pod: Fix documentation.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 tools/virsh-domain.c | 11 ---
 tools/virsh.pod  |  4 ++--
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 5aabccd..59e3d8d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -295,6 +295,10 @@ static const vshCmdOptDef opts_attach_disk[] = {
  .type = VSH_OT_STRING,
  .help = N_(target device type)
 },
+{.name = shareable,
+ .type = VSH_OT_ALIAS,
+ .help = mode=shareable
+},
 {.name = mode,
  .type = VSH_OT_STRING,
  .help = N_(mode of device reading and writing)
@@ -311,10 +315,6 @@ static const vshCmdOptDef opts_attach_disk[] = {
  .type = VSH_OT_STRING,
  .help = N_(wwn of disk device)
 },
-{.name = shareable,
- .type = VSH_OT_BOOL,
- .help = N_(shareable between domains)
-},
 {.name = rawio,
  .type = VSH_OT_BOOL,
  .help = N_(needs rawio capability)
@@ -602,9 +602,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 if (wwn)
 virBufferAsprintf(buf,   wwn%s/wwn\n, wwn);

-if (vshCommandOptBool(cmd, shareable))
-virBufferAddLit(buf,   shareable/\n);
-
 if (straddr) {
 if (str2DiskAddress(straddr, diskAddr) != 0) {
 vshError(ctl, _(Invalid address.));
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 7af5503..302f811 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1923,7 +1923,7 @@ expected.
 [[[I--live] [I--config] | [I--current]] | [I--persistent]]
 [I--driver driver] [I--subdriver subdriver] [I--cache cache]
 [I--type type] [I--mode mode] [I--config] [I--sourcetype soucetype]
-[I--serial serial] [I--wwn wwn] [I--shareable] [I--rawio]
+[I--serial serial] [I--wwn wwn] [I--rawio]
 [I--address address] [I--multifunction] [I--print-xml]

 Attach a new disk device to the domain.
@@ -1945,7 +1945,6 @@ Isourcetype can indicate the type of source (block|file)
 Icache can be one of default, none, writethrough, writeback,
 directsync or unsafe.
 Iserial is the serial of disk device. Iwwn is the wwn of disk device.
-Ishareable indicates the disk device is shareable between domains.
 Irawio indicates the disk needs rawio capability.
 Iaddress is the address of disk device in the form of 
pci:domain.bus.slot.function,
 scsi:controller.bus.unit or ide:controller.bus.unit.
@@ -1964,6 +1963,7 @@ on the hypervisor driver.

 For compatibility purposes, I--persistent behaves like I--config for
 an offline domain, and like I--live I--config for a running domain.
+Likewise, I--shareable is an alias for I--mode shareable.

 =item Battach-interface Idomain Itype Isource
 [[[I--live] [I--config] | [I--current]] | [I--persistent]]
-- 
1.8.3.1

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


[libvirt] [PATCHv2 1/2] virsh: allow alias to expand to opt=value pair

2013-10-24 Thread Eric Blake
We want to treat 'attach-disk --shareable' as an undocumented
alias for 'attach-disk --mode=shareable'.  By improving our
alias handling, we can allow all such --bool - --opt=value
replacements, and guarantee up front that the alias is not
mixed with its replacement.

* tools/virsh.c (vshCmddefOptParse, vshCmddefGetOption): Add
support for expanding bool alias to --opt=value.
(opts_echo): Add another alias to test it.
* tests/virshtest.c (mymain): Test it.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 tests/virshtest.c |  1 +
 tools/virsh.c | 58 +++
 2 files changed, 51 insertions(+), 8 deletions(-)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 8367248..6510208 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -393,6 +393,7 @@ mymain(void)
 DO_TEST(32, hello\n, echo --string hello);
 DO_TEST(33, hello\n, echo, --str, hello);
 DO_TEST(34, hello\n, echo --str hello);
+DO_TEST(35, hello\n, echo --hi);

 # undef DO_TEST

diff --git a/tools/virsh.c b/tools/virsh.c
index 8425f53..bad78c9 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -885,6 +885,10 @@ static const vshCmdOptDef opts_echo[] = {
  .type = VSH_OT_ALIAS,
  .help = string
 },
+{.name = hi,
+ .type = VSH_OT_ALIAS,
+ .help = string=hello
+},
 {.name = string,
  .type = VSH_OT_ARGV,
  .help = N_(arguments to echo)
@@ -1011,12 +1015,25 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t 
*opts_need_arg,
 }
 if (opt-type == VSH_OT_ALIAS) {
 size_t j;
+char *name = (char *)opt-help; /* cast away const */
+char *p;
+
 if (opt-flags || !opt-help)
 return -1; /* alias options are tracked by the original name */
+if ((p = strchr(name, '=')) 
+VIR_STRNDUP(name, name, p - name)  0)
+return -1;
 for (j = i + 1; cmd-opts[j].name; j++) {
-if (STREQ(opt-help, cmd-opts[j].name))
+if (STREQ(name, cmd-opts[j].name) 
+cmd-opts[j].type != VSH_OT_ALIAS)
 break;
 }
+if (name != opt-help) {
+VIR_FREE(name);
+/* If alias comes with value, replacement must not be bool */
+if (cmd-opts[j].type == VSH_OT_BOOL)
+return -1;
+}
 if (!cmd-opts[j].name)
 return -1; /* alias option must map to a later option name */
 continue;
@@ -1049,9 +1066,11 @@ static vshCmdOptDef helpopt = {
 };
 static const vshCmdOptDef *
 vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
-   uint32_t *opts_seen, int *opt_index)
+   uint32_t *opts_seen, int *opt_index, char **optstr)
 {
 size_t i;
+const vshCmdOptDef *ret = NULL;
+char *alias = NULL;

 if (STREQ(name, helpopt.name)) {
 return helpopt;
@@ -1062,16 +1081,36 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef 
*cmd, const char *name,

 if (STREQ(opt-name, name)) {
 if (opt-type == VSH_OT_ALIAS) {
-name = opt-help;
+char *value;
+
+/* Two types of replacements:
+   opt-help = string: straight replacement of name
+   opt-help = string=value: treat boolean flag as
+   alias of option and its default value */
+sa_assert(!alias);
+if (VIR_STRDUP(alias, opt-help)  0)
+goto cleanup;
+name = alias;
+if ((value = strchr(name, '='))) {
+*value = '\0';
+if (*optstr) {
+vshError(ctl, _(invalid '=' after option --%s),
+ opt-name);
+goto cleanup;
+}
+if (VIR_STRDUP(*optstr, value + 1)  0)
+goto cleanup;
+}
 continue;
 }
 if ((*opts_seen  (1  i))  opt-type != VSH_OT_ARGV) {
 vshError(ctl, _(option --%s already seen), name);
-return NULL;
+goto cleanup;
 }
 *opts_seen |= 1  i;
 *opt_index = i;
-return opt;
+ret = opt;
+goto cleanup;
 }
 }

@@ -1079,7 +1118,9 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, 
const char *name,
 vshError(ctl, _(command '%s' doesn't support option --%s),
  cmd-name, name);
 }
-return NULL;
+cleanup:
+VIR_FREE(alias);
+return ret;
 }

 static const vshCmdOptDef *
@@ -1845,7 +1886,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
 }
 /* Special case 'help' to ignore all spurious options */
 if 

Re: [libvirt] [PATCH] virsh domxml-from-native to treat SCSI as the bus type for pseries by default

2013-10-24 Thread Li Zhang

On 2013年10月24日 15:07, Shivaprasad G Bhat wrote:

From: Shivaprasad G Bhat sb...@linux.vnet.ibm.com

The bus type IDE being enum Zero, the bus type on pseries system appears as IDE 
for all the disk types. Pseries platform needs this to appear as SCSI instead 
of IDE.

Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com
---
  src/qemu/qemu_command.c |   21 +
  1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index abb62e9..728409f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9995,6 +9995,7 @@ error:
  static virDomainDiskDefPtr
  qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
   const char *val,
+virDomainDefPtr dom,
   int nvirtiodisk,
   bool old_style_ceph_args)
  {
@@ -10018,7 +10019,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
  if (VIR_ALLOC(def)  0)
  goto cleanup;
  
-def-bus = VIR_DOMAIN_DISK_BUS_IDE;

+if (((dom-os.arch == VIR_ARCH_PPC64) 
+ dom-os.machine  STREQ(dom-os.machine, pseries)))
+def-bus = VIR_DOMAIN_DISK_BUS_SCSI;
+else
+   def-bus = VIR_DOMAIN_DISK_BUS_IDE;

The indent should be 4 spaces.

  def-device = VIR_DOMAIN_DISK_DEVICE_DISK;
  def-type = VIR_DOMAIN_DISK_TYPE_FILE;
  
@@ -11332,8 +11337,13 @@ qemuParseCommandLine(virCapsPtr qemuCaps,

  disk-type = VIR_DOMAIN_DISK_TYPE_FILE;
  if (STREQ(arg, -cdrom)) {
  disk-device = VIR_DOMAIN_DISK_DEVICE_CDROM;
-if (VIR_STRDUP(disk-dst, hdc)  0)
-goto error;
+   if (((def-os.arch == VIR_ARCH_PPC64) 
+ def-os.machine  STREQ(def-os.machine, pseries))) {
+disk-bus = VIR_DOMAIN_DISK_BUS_SCSI;

Please pay attention of the indent.

+   if (VIR_STRDUP(disk-dst, sdc)  0)
+   goto error;
+   } else if (VIR_STRDUP(disk-dst, hdc)  0)
+   goto error;
  disk-readonly = true;
  } else {
  if (STRPREFIX(arg, -fd)) {
@@ -11345,6 +11355,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
  disk-bus = VIR_DOMAIN_DISK_BUS_IDE;
  else
  disk-bus = VIR_DOMAIN_DISK_BUS_SCSI;
+   if (((def-os.arch == VIR_ARCH_PPC64) 
+   def-os.machine  STREQ(def-os.machine, pseries)))
+   disk-bus = VIR_DOMAIN_DISK_BUS_SCSI;

Here too.

  }
  if (VIR_STRDUP(disk-dst, arg + 1)  0)
  goto error;
@@ -11636,7 +11649,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
  }
  } else if (STREQ(arg, -drive)) {
  WANT_VALUE();
-if (!(disk = qemuParseCommandLineDisk(xmlopt, val,
+if (!(disk = qemuParseCommandLineDisk(xmlopt, val, def,
nvirtiodisk,
ceph_args != NULL)))
  goto error;

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


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

Re: [libvirt] [PATCH] virsh domxml-from-native to treat SCSI as the bus type for pseries by default

2013-10-24 Thread Eric Blake
On 10/24/2013 08:07 AM, Shivaprasad G Bhat wrote:
 From: Shivaprasad G Bhat sb...@linux.vnet.ibm.com
 
 The bus type IDE being enum Zero, the bus type on pseries system appears as 
 IDE for all the disk types. Pseries platform needs this to appear as SCSI 
 instead of IDE.
 
 Signed-off-by: Shivaprasad G Bhat sb...@linux.vnet.ibm.com
 ---
  src/qemu/qemu_command.c |   21 +
  1 file changed, 17 insertions(+), 4 deletions(-)
 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index abb62e9..728409f 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -9995,6 +9995,7 @@ error:
  static virDomainDiskDefPtr
  qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
   const char *val,
 +  virDomainDefPtr dom,

TAB damage.  Please run 'make syntax-check' and fix that.

   int nvirtiodisk,
   bool old_style_ceph_args)
  {
 @@ -10018,7 +10019,11 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr 
 xmlopt,
  if (VIR_ALLOC(def)  0)
  goto cleanup;
  
 -def-bus = VIR_DOMAIN_DISK_BUS_IDE;
 +if (((dom-os.arch == VIR_ARCH_PPC64) 
 + dom-os.machine  STREQ(dom-os.machine, pseries)))
 +def-bus = VIR_DOMAIN_DISK_BUS_SCSI;
 +else
 + def-bus = VIR_DOMAIN_DISK_BUS_IDE;

I'm wondering if we should reuse our post-XML-parse callbacks here,
rather than open-coding a machine check.  In other words, since we
already have code that knows how to do per-machine fixups to a domain
definition, we should be reusing those instead of open-coding duplicate
checks.  (Actually, domxml-from-native needs a LOT of TLC, there's much
more wrong with it, even on non-pseries machines, than what you are
trying to patch).

-- 
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] failed to write to disk on vm with lvm pool

2013-10-24 Thread Vasiliy Tolstov
Hi all. Today i can't mkfs.ext3 inside virual machine while install it
(ubuntu 13.04).

Why this happening? On other node i see that
virSecurityDACSetOwnership sets perms on /dev/vg/xxx and /dev/dm-xxx,
but in this host this not happening.

Libvirt logs:
2013-10-24 07:50:15.639+: 3700: info : virNetDevProbeVnetHdr:94 :
Enabling IFF_VNET_HDR
2013-10-24 07:50:15.782+: 3700: info :
virSecurityDACSetOwnership:271 : Setting DAC user and group on
'/dev/vg/402' to '108:102'
2013-10-24 07:50:15.783+: 3700: info :
virSecurityDACSetOwnership:271 : Setting DAC user and group on
'/srv/ubuntu/13.04/kernel' to '108:102'
2013-10-24 07:50:15.783+: 3700: info :
virSecurityDACSetOwnership:271 : Setting DAC user and group on
'/srv/ubuntu/13.04/initrd' to '108:102'
2013-10-24 07:50:16.386+: 3700: warning : virCgroupMoveTask:887 :
no vm cgroup in controller 3
2013-10-24 07:50:16.386+: 3700: warning : virCgroupMoveTask:887 :
no vm cgroup in controller 4
2013-10-24 07:50:16.386+: 3700: warning : virCgroupMoveTask:887 :
no vm cgroup in controller 6

domainxml disk:
disk type='block' device='disk'
  driver name='qemu' type='raw' cache='none' io='native'
ioeventfd='on' event_idx='off'/
  source dev='/dev/vg/402'/
  target dev='vda' bus='virtio'/
  alias name='virtio-disk0'/
  address type='pci' domain='0x' bus='0x00' slot='0x04'
function='0x0'/
/disk

pool xml
pool type='logical'
  namedefault/name
  uuid2a135e38-dd92-1b4d-bd82-3aafd369d207/uuid
  capacity unit='bytes'3000454086656/capacity
  allocation unit='bytes'386547056640/allocation
  available unit='bytes'2613907030016/available
  source
device path='/dev/bcache0'/
namevg/name
format type='lvm2'/
  /source
  target
path/dev/vg/path
permissions
  mode0711/mode
  owner-1/owner
  group-1/group
/permissions
  /target
/pool

qemu.log:

2013-10-24 07:50:15.777+: starting up
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
QEMU_AUDIO_DRV=none /usr/bin/qemu-system-x86_64 -name 402 -S -M pc-1.0
-enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -uuid
0ee50ad7-8c2b-57e9-5bee-571d77c1 -no-user-config -nodefaults
-chardev 
socket,id=charmonitor,path=/var/lib/libvirt/qemu/402.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc
-no-reboot -no-shutdown -kernel /srv/ubuntu/13.04/kernel -initrd
/srv/ubuntu/13.04/initrd -append ks=file:///ks.cfg -device
piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device
virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 -drive
file=/dev/vg/402,if=none,id=drive-virtio-disk0,format=raw,cache=none,aio=native
-device 
virtio-blk-pci,ioeventfd=on,event_idx=off,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
-drive if=none,id=drive-ide0-1-0,readonly=on,format=raw -device
ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev
tap,fd=22,id=hostnet0,vhost=on,vhostfd=23 -device
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:00:01:55,bus=pci.0,addr=0x3
-chardev pty,id=charserial0 -device
isa-serial,chardev=charserial0,id=serial0 -chardev
spicevmc,id=charchannel0,name=vdagent -device
virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0
-chardev 
socket,id=charchannel1,path=/var/lib/libvirt/qemu/402.agent,server,nowait
-device 
virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,id=channel1,name=org.mighost.agent.0
-vnc 0.0.0.0:0,password -vga std -device
virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
char device redirected to /dev/pts/0 (label charserial0)


-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru
jabber: v...@selfip.ru

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


Re: [libvirt] PATCH: pci-subsystem: ixgbe: SR-IOV: kernel way to order driver's virtfn -entries is odd causing libvirt failures.

2013-10-24 Thread Daniel P. Berrange
On Thu, Oct 24, 2013 at 09:52:31AM +0300, Niilona wrote:
 Hi.
 
 As Bjorn Helgaas recommend, this might be the item to discuss in the wider 
 area.
 ---
 
 There is a behavior effecting virtfn -entries in sysfs, when amount of
 them increases over 10.
 Run VM's through LIBVIRT - QEMU/KVM, this causes :
 - MAC address setting by LIBVIRT disordered ie. setting targeted to wrong VF.
 - VLAN setting by LIBVIRT overall failed
 
 Basics of this are in /libvirt-x.x.x/src/util/virpci.c ; in function below,
 which don't order virtfn entries correctly.
 
 /*
  * Returns virtual functions of a physical function
  */
 int
 virPCIGetVirtualFunctions(const char *sysfs_path,
   virPCIDeviceAddressPtr **virtual_functions,
   unsigned int *num_virtual_functions)
 {
 
 But I let you to decide which is best way to fix this, as if every
 application reads virtfn entries from PF's directory, they all need
 to sort entries in alphabet. order to avoid this
 influence.
 So personally I did get over this by adding pre-zeroes to names to
 have them in sorted order in PF's directory.

Libvirt has to work correctly with all existing released kernels,
so we have to fix libvirt to deal with ordering correctly. Thus
changing the kernel naming here doesn't really help. We need to
fix libvirt to deal with this.

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 0/3] Add complete blkiotune support for per-device with blkio cgroup

2013-10-24 Thread Guan Qiang
From: Guan Qiang hzguanqi...@corp.netease.com

The patches add a complete blkiotune support per-device with blkio cgroup 
for both lxc or qemu driver, by extending the existed 
'domainSetBlkioParameters' 
and 'domainGetBlkioParameters' interface. 
Beside device weight, read/write bps and iops throttle can be set per-device
with these patches.
Virsh command 'blkiotune' is extended to support the above function too.

Guan Qiang (3):
  qemu: add blkiotune support for device iops and bps throttle setting
  lxc: add blkiotune support for per device
  blkiotune: add virsh support for blkiotune interface

 docs/formatdomain.html.in  |8 +
 docs/schemas/domaincommon.rng  |   28 +-
 include/libvirt/libvirt.h.in   |   40 ++
 src/conf/domain_conf.c |  115 ++-
 src/conf/domain_conf.h |   16 +-
 src/libvirt_private.syms   |4 +-
 src/lxc/lxc_cgroup.c   |9 +-
 src/lxc/lxc_driver.c   |  743 +++-
 src/qemu/qemu_cgroup.c |   10 +-
 src/qemu/qemu_driver.c |  579 +--
 src/util/vircgroup.c   |   79 ++-
 src/util/vircgroup.h   |8 +-
 .../qemuxml2argv-blkiotune-device.xml  |4 +
 tools/virsh-domain.c   |   64 ++
 tools/virsh.pod|   32 +-
 15 files changed, 1614 insertions(+), 125 deletions(-)

-- 
1.7.9.5

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


[libvirt] [PATCH 2/3] lxc: add blkiotune support for per device

2013-10-24 Thread Guan Qiang
From: Guan Qiang hzguanqi...@corp.netease.com

This add per-device weight, iops and bps throttle to blkiotune.
By extending the existed 'domainSetBlkioParameters' interface,
blkiotune for per-device can be set with blkio cgroup.
---
 src/lxc/lxc_driver.c |  743 +-
 1 file changed, 731 insertions(+), 12 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 61a90ca..56277a7 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1546,6 +1546,22 @@ static int lxcStateCleanup(void)
 }
 
 
+/* Which features are supported by this driver? */
+static int
+lxcConnectSupportsFeature(virConnectPtr conn, int feature)
+{
+if (virConnectSupportsFeatureEnsureACL(conn)  0)
+return -1;
+
+switch (feature) {
+case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
+return 1;
+default:
+return 0;
+}
+}
+
+
 static int lxcConnectGetVersion(virConnectPtr conn, unsigned long *version)
 {
 struct utsname ver;
@@ -1911,6 +1927,191 @@ lxcDomainGetSchedulerParameters(virDomainPtr domain,
 }
 
 
+/* deviceIoTuneStr in the form of 
/device/path,ioTuneValue,/device/path,ioTuneValue or
+ * for example, /dev/disk/by-path/pci-:00:1f.2-scsi-0:0:0:0,800
+ * deviceIoTuneFiled represents the ioTune type to tune, including device 
weight,
+ * device read bps, device write bps, device read iops and device write iops.
+ */
+static int
+lxcDomainParseDeviceIoTuneInfoStr(char *deviceIoTuneStr,
+  const char *deviceIoTuneFiled,
+  virBlkioDeviceIoTuneInfoPtr *dio, size_t 
*size)
+{
+char *temp;
+int ndevices = 0;
+int nsep = 0;
+size_t i, j, k;
+virBlkioDeviceIoTuneInfoPtr result = NULL;
+
+if (STREQ(deviceIoTuneStr, ))
+return 0;
+
+temp = deviceIoTuneStr;
+while (temp) {
+temp = strchr(temp, ',');
+if (temp) {
+temp++;
+nsep++;
+}
+}
+
+/* A valid string must have even number of fields, hence an odd
+ * number of commas.  */
+if (!(nsep  1))
+goto error;
+
+ndevices = (nsep + 1) / 2;
+
+if (VIR_ALLOC_N(result, ndevices)  0)
+return -1;
+
+for (i = 0; i  ndevices; i++)
+memset(result[i], 0, sizeof(result[i]));
+
+i = 0;
+temp = deviceIoTuneStr;
+while (temp) {
+char *p = temp;
+
+/* device path */
+p = strchr(p, ',');
+if (!p)
+goto error;
+
+if (VIR_STRNDUP(result[i].path, temp, p - temp)  0)
+goto cleanup;
+
+/* device ioTune value */
+temp = p + 1;
+
+if (STREQ(deviceIoTuneFiled, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
+if (virStrToLong_ui(temp, p, 10, result[i].weight)  0)
+goto error;
+} else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_READ_BPS)) {
+if (virStrToLong_ull(temp, p, 10, result[i].read_bps)  0)
+goto error;
+} else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_WRITE_BPS)) {
+if (virStrToLong_ull(temp, p, 10, result[i].write_bps)  0)
+goto error;
+} else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_READ_IOPS)) {
+if (virStrToLong_ull(temp, p, 10, result[i].read_iops)  0)
+goto error;
+} else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_WRITE_IOPS)) {
+if (virStrToLong_ull(temp, p, 10, result[i].write_iops)  0)
+goto error;
+}
+
+i++;
+
+if (*p == '\0')
+break;
+else if (*p != ',')
+goto error;
+temp = p + 1;
+}
+
+if (!i)
+VIR_FREE(result);
+
+for (j = 0; j  i; j++) {
+bool found = false;
+virBlkioDeviceIoTuneInfoPtr old, new;
+
+new = result[j];
+for (k = 0; k  *size; k++) {
+old = (*dio)[k];
+if (STREQ(new-path, old-path)) {
+found = true;
+if (STREQ(deviceIoTuneFiled, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT))
+old-weight = new-weight;
+else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_READ_BPS))
+old-read_bps = new-read_bps;
+else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_WRITE_BPS))
+old-write_bps = new-write_bps;
+else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_READ_IOPS))
+old-read_iops = new-read_iops;
+else if (STREQ(deviceIoTuneFiled, 
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_WRITE_IOPS))
+old-write_iops = new-write_iops;
+break;
+}
+}
+if (!found) {
+if (!new-weight  !new-read_bps  !new-write_bps 
+

[libvirt] [PATCH 3/3] blkiotune: add virsh support for blkiotune interface

2013-10-24 Thread Guan Qiang
From: Guan Qiang hzguanqi...@corp.netease.com

This adds four parameters --device-read-bps, --device-write-bps, 
--device-read-iops
and --device-write-iops to virsh command blkiotune for setting/getting
blkiotune.throttle.{read/write}_{iops/bps}_device.
---
 tools/virsh-domain.c |   64 ++
 tools/virsh.pod  |   32 +++--
 2 files changed, 94 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 5aabccd..4f4197f 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1253,6 +1253,22 @@ static const vshCmdOptDef opts_blkiotune[] = {
  .type = VSH_OT_STRING,
  .help = N_(per-device IO Weights, in the form of 
/path/to/device,weight,...)
 },
+{.name = device-read-bps,
+ .type = VSH_OT_STRING,
+ .help = N_(per-device read throughput limit in bytes per second, in the 
form of /path/to/device,read_bps,...)
+},
+{.name = device-write-bps,
+ .type = VSH_OT_STRING,
+ .help = N_(per-device write throughput limit in bytes per second, in the 
form of /path/to/device,write_bps,...)
+},
+{.name = device-read-iops,
+ .type = VSH_OT_STRING,
+ .help = N_(per-device read I/O operations limit per second, in the form 
of /path/to/device,read_iops,...)
+},
+{.name = device-write-iops,
+ .type = VSH_OT_STRING,
+ .help = N_(per-device write I/O operations limit per second, in the form 
of /path/to/device,write_iops,...)
+},
 {.name = config,
  .type = VSH_OT_BOOL,
  .help = N_(affect next boot)
@@ -1273,6 +1289,10 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
 {
 virDomainPtr dom;
 const char *device_weight = NULL;
+const char *device_read_bps = NULL;
+const char *device_write_bps = NULL;
+const char *device_read_iops = NULL;
+const char *device_write_iops = NULL;
 int weight = 0;
 int nparams = 0;
 int maxparams = 0;
@@ -1320,6 +1340,50 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
 goto save_error;
 }
 
+rv = vshCommandOptString(cmd, device-read-bps, device_read_bps);
+if (rv  0) {
+vshError(ctl, %s, _(Unable to parse string parameter));
+goto cleanup;
+} else if (rv  0) {
+if (virTypedParamsAddString(params, nparams, maxparams,
+VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_READ_BPS,
+device_read_bps)  0)
+goto save_error;
+}
+
+rv = vshCommandOptString(cmd, device-write-bps, device_write_bps);
+if (rv  0) {
+vshError(ctl, %s, _(Unable to parse string parameter));
+goto cleanup;
+} else if (rv  0) {
+if (virTypedParamsAddString(params, nparams, maxparams,
+VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_WRITE_BPS,
+device_write_bps)  0)
+goto save_error;
+}
+
+rv = vshCommandOptString(cmd, device-read-iops, device_read_iops);
+if (rv  0) {
+vshError(ctl, %s, _(Unable to parse string parameter));
+goto cleanup;
+} else if (rv  0) {
+if (virTypedParamsAddString(params, nparams, maxparams,
+VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_READ_IOPS,
+device_read_iops)  0)
+goto save_error;
+}
+
+rv = vshCommandOptString(cmd, device-write-iops, device_write_iops);
+if (rv  0) {
+vshError(ctl, %s, _(Unable to parse string parameter));
+goto cleanup;
+} else if (rv  0) {
+if (virTypedParamsAddString(params, nparams, maxparams,
+
VIR_DOMAIN_BLKIO_THROTTLE_DEVICE_WRITE_IOPS,
+device_write_iops)  0)
+goto save_error;
+}
+
 if (nparams == 0) {
 /* get the number of blkio parameters */
 if (virDomainGetBlkioParameters(dom, NULL, nparams, flags) != 0) {
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 7af5503..afe1bda 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1625,8 +1625,12 @@ The guaranteed minimum memory allocation for the guest.
 Specifying -1 as a value for these limits is interpreted as unlimited.
 
 =item Bblkiotune Idomain [I--weight Bweight]
-[I--device-weights Bdevice-weights] [[I--config]
-[I--live] | [I--current]]
+[I--device-weights Bdevice-weights]
+[I--device-read-bps Bdevice-read-bps]
+[I--device-write-bps Bdevice-write-bps]
+[I--device-read-iops Bdevice-read-iops]
+[I--device-write-iops Bdevice-write-iops]
+[[I--config] [I--live] | [I--current]]
 
 Display or set the blkio parameters. QEMU/KVM supports I--weight.
 I--weight is in range [100, 1000]. After kernel 2.6.39, the value
@@ -1639,6 +1643,30 @@ or the value 0 to remove that device from per-device 
listings.
 Only the devices listed in the string are modified;
 any existing per-device weights for other devices 

[libvirt] [PATCH] virsh: fix doc typos

2013-10-24 Thread Eric Blake
Reported in https://bugzilla.redhat.com/show_bug.cgi?id=1022872

* tools/virsh.pod: s/COMMMANDS/COMMANDS/

Signed-off-by: Eric Blake ebl...@redhat.com
---

Pushing as trivial.

 tools/virsh.pod | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 7af5503..68e6e86 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2823,7 +2823,7 @@ Bblockresize for live resizing.

 =back

-=head1 SECRET COMMMANDS
+=head1 SECRET COMMANDS

 The following commands manipulate secrets (e.g. passwords, passphrases and
 encryption keys).  Libvirt can store secrets independently from their use, and
@@ -2870,7 +2870,7 @@ I--no-private to list the non-private ones.

 =back

-=head1 SNAPSHOT COMMMANDS
+=head1 SNAPSHOT COMMANDS

 The following commands manipulate domain snapshots.  Snapshots take the
 disk, memory, and device state of a domain at a point-of-time, and save it
@@ -3170,7 +3170,7 @@ the data contents from that point in time.

 =back

-=head1 NWFILTER COMMMANDS
+=head1 NWFILTER COMMANDS

 The following commands manipulate network filters. Network filters allow
 filtering of the network traffic coming from and going to virtual machines.
-- 
1.8.3.1

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


Re: [libvirt] [PATCH] Quick fix for config-demo.py

2013-10-24 Thread Christophe Fergeau
On Tue, Oct 22, 2013 at 03:50:36PM -0700, Ian Main wrote:
 I guess this must have been changed and the demo not updated.  Fix the
 demo so it uses the right value.

ACK (this was broken in c6b98f67d4b794ae1a91bf9fdff3445f1135bc85 , I tried
to update to update the demo but somehow failed at it ;)

Christophe


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

Re: [libvirt] [PATCH] Quick fix for config-demo.py

2013-10-24 Thread Michal Privoznik
On 22.10.2013 23:50, Ian Main wrote:
 I guess this must have been changed and the demo not updated.  Fix the
 demo so it uses the right value.
 
 Signed-off-by: Ian Main im...@redhat.com
 ---
  examples/config-demo.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/examples/config-demo.py b/examples/config-demo.py
 index 367d99a..c28d8b9 100644
 --- a/examples/config-demo.py
 +++ b/examples/config-demo.py
 @@ -28,7 +28,7 @@ disk.set_type(LibvirtGConfig.DomainDiskType.FILE)
  disk.set_guest_device_type(LibvirtGConfig.DomainDiskGuestDeviceType.DISK)
  disk.set_source(/tmp/foo/bar)
  disk.set_driver_name(qemu)
 -disk.set_driver_format(LibvirtGConfig.DriverType.QCOW2)
 +disk.set_driver_format(LibvirtGConfig.DomainDiskFormat.QCOW2)
  disk.set_target_bus(LibvirtGConfig.DomainDiskBus.IDE)
  disk.set_target_dev(hda)
  domain.add_device(disk)
 

While having one list for two or more joint projects makes sense, I
think it pushes some more requirements for submitting patches. For
instance, I filter -glib patches into a separate folder (based on -glib
appearing in the subject). So can you please run:

  git config format.subjectprefix libvirt-glib][PATCH

within your libvirt-glib git tree, so you don't have to worry about
using the correct prefix again? Thanks!

Michal

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


Re: [libvirt] [libvirt-glib PATCH v2] Add filterref and filterref parameter support.

2013-10-24 Thread Christophe Fergeau
On Tue, Oct 22, 2013 at 03:48:36PM -0700, Ian Main wrote:
 This patch adds support for setting filterref's on interfaces.  Also
 supported are parameters to the filterref's.
 
 V2:
 
 - alphabetical orderized (don't look it up!) Makefile.am
 - s/set_filter/set_name/ s/get_filter/get_name/
 - remove trailing whitespace.
 - fix missing line.
 - add return_val_if_fail check.
 - moved qcow fix in demo to a new patch.
 - fixed new_from_xml().
 
 Signed-off-by: Ian Main im...@redhat.com
 ---
  examples/config-demo.py|   7 +
  libvirt-gconfig/Makefile.am|   4 +
  ...-gconfig-domain-interface-filterref-parameter.c | 101 +
  ...-gconfig-domain-interface-filterref-parameter.h |  75 ++
  .../libvirt-gconfig-domain-interface-filterref.c   | 157 
 +
  .../libvirt-gconfig-domain-interface-filterref.h   |  76 ++
  libvirt-gconfig/libvirt-gconfig-domain-interface.c |  41 ++
  libvirt-gconfig/libvirt-gconfig-domain-interface.h |   5 +
  libvirt-gconfig/libvirt-gconfig.h  |   2 +
  libvirt-gconfig/libvirt-gconfig.sym|  18 +++
  10 files changed, 486 insertions(+)
  create mode 100644 
 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c
  create mode 100644 
 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.h
  create mode 100644 
 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.c
  create mode 100644 
 libvirt-gconfig/libvirt-gconfig-domain-interface-filterref.h
 
 diff --git a/examples/config-demo.py b/examples/config-demo.py
 index 09b9e89..367d99a 100644
 --- a/examples/config-demo.py
 +++ b/examples/config-demo.py
 @@ -35,6 +35,13 @@ domain.add_device(disk)
  
  interface = LibvirtGConfig.DomainInterfaceNetwork.new()
  interface.set_source(default)
 +filterref = LibvirtGConfig.DomainInterfaceFilterref.new()
 +filterref.set_name(clean-traffic)
 +parameter = LibvirtGConfig.DomainInterfaceFilterrefParameter.new()
 +parameter.set_name(IP)
 +parameter.set_value(205.23.12.40)
 +filterref.add_parameter(parameter)
 +interface.set_filterref(filterref)
  domain.add_device(interface)
  
  interface = LibvirtGConfig.DomainInterfaceUser.new()
 diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
 index 35dc978..0793da1 100644
 --- a/libvirt-gconfig/Makefile.am
 +++ b/libvirt-gconfig/Makefile.am
 @@ -47,6 +47,8 @@ GCONFIG_HEADER_FILES = \
   libvirt-gconfig-domain-input.h \
   libvirt-gconfig-domain-interface.h \
   libvirt-gconfig-domain-interface-bridge.h \
 + libvirt-gconfig-domain-interface-filterref.h \
 + libvirt-gconfig-domain-interface-filterref-parameter.h \
   libvirt-gconfig-domain-interface-network.h \
   libvirt-gconfig-domain-interface-user.h \
   libvirt-gconfig-domain-memballoon.h \
 @@ -129,6 +131,8 @@ GCONFIG_SOURCE_FILES = \
   libvirt-gconfig-domain-input.c \
   libvirt-gconfig-domain-interface.c \
   libvirt-gconfig-domain-interface-bridge.c \
 + libvirt-gconfig-domain-interface-filterref.c \
 + libvirt-gconfig-domain-interface-filterref-parameter.c \
   libvirt-gconfig-domain-interface-network.c \
   libvirt-gconfig-domain-interface-user.c \
   libvirt-gconfig-domain-memballoon.c \
 diff --git 
 a/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c 
 b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c
 new file mode 100644
 index 000..e697e86
 --- /dev/null
 +++ b/libvirt-gconfig/libvirt-gconfig-domain-interface-filterref-parameter.c
 @@ -0,0 +1,101 @@
 +/*
 + * libvirt-gconfig-domain-interface-filterref-parameter.c:
 + * libvirt filterref parameters
 + *
 + * Copyright (C) 2013 Red Hat, Inc.
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library. If not, see
 + * http://www.gnu.org/licenses/.
 + *
 + * Authors: Ian Main im...@redhat.com
 + *  Daniel P. Berrange berra...@redhat.com
 + */
 +
 +#include config.h
 +
 +#include libvirt-gconfig/libvirt-gconfig.h
 +#include libvirt-gconfig/libvirt-gconfig-private.h
 +
 +#define 

Re: [libvirt] [PATCHv2 1/2] virsh: allow alias to expand to opt=value pair

2013-10-24 Thread Chen Hanxiao


 -Original Message-
 From: Eric Blake [mailto:ebl...@redhat.com]
 Sent: Thursday, October 24, 2013 3:22 PM
 To: libvir-list@redhat.com
 Cc: chenhanx...@cn.fujitsu.com
 Subject: [PATCHv2 1/2] virsh: allow alias to expand to opt=value pair
 
 We want to treat 'attach-disk --shareable' as an undocumented
 alias for 'attach-disk --mode=shareable'.  By improving our
 alias handling, we can allow all such --bool - --opt=value
 replacements, and guarantee up front that the alias is not
 mixed with its replacement.
 
 * tools/virsh.c (vshCmddefOptParse, vshCmddefGetOption): Add
 support for expanding bool alias to --opt=value.
 (opts_echo): Add another alias to test it.
 * tests/virshtest.c (mymain): Test it.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  tests/virshtest.c |  1 +
  tools/virsh.c | 58
 +++
  2 files changed, 51 insertions(+), 8 deletions(-)
 

ACK

Thanks!


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


[libvirt] [PATCH] libxl: Fix possible invalid read

2013-10-24 Thread Martin Kletzander
According to the following valgrind output, there seems to be a
invalid limit for the iterator (captured on Fedora 19):

==3945== Invalid read of size 1
==3945==at 0x1E1FA410: libxlVmStart (libxl_driver.c:475)
==3945==by 0x1E1FAD9A: libxlDomainCreateWithFlags (libxl_driver.c:2633)
==3945==by 0x5187D46: virDomainCreate (libvirt.c:9439)
==3945==by 0x13BAA6: remoteDispatchDomainCreateHelper 
(remote_dispatch.h:2910)
==3945==by 0x51DE5B9: virNetServerProgramDispatch 
(virnetserverprogram.c:435)
==3945==by 0x51D93E7: virNetServerHandleJob (virnetserver.c:165)
==3945==by 0x50F5BF4: virThreadPoolWorker (virthreadpool.c:144)
==3945==by 0x50F5670: virThreadHelper (virthreadpthread.c:161)
==3945==by 0x8046C52: start_thread (pthread_create.c:308)
==3945==by 0x8758E1C: clone (clone.S:113)
==3945==  Address 0x23424d81 is 0 bytes after a block of size 1 alloc'd
==3945==at 0x4A08121: calloc (in 
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==3945==by 0x50B1F8C: virAllocN (viralloc.c:189)
==3945==by 0x1E1FA3CA: libxlVmStart (libxl_driver.c:468)
==3945==by 0x1E1FAD9A: libxlDomainCreateWithFlags (libxl_driver.c:2633)
==3945==by 0x5187D46: virDomainCreate (libvirt.c:9439)
==3945==by 0x13BAA6: remoteDispatchDomainCreateHelper 
(remote_dispatch.h:2910)
==3945==by 0x51DE5B9: virNetServerProgramDispatch 
(virnetserverprogram.c:435)
==3945==by 0x51D93E7: virNetServerHandleJob (virnetserver.c:165)
==3945==by 0x50F5BF4: virThreadPoolWorker (virthreadpool.c:144)
==3945==by 0x50F5670: virThreadHelper (virthreadpthread.c:161)
==3945==by 0x8046C52: start_thread (pthread_create.c:308)
==3945==by 0x8758E1C: clone (clone.S:113)
==3945==

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1013045
Signed-off-by: Martin Kletzander mklet...@redhat.com
---
 src/libxl/libxl_driver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e2a6d44..4928695 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -454,6 +454,7 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, 
virDomainObjPtr vm)
 size_t cpumaplen;
 int vcpu;
 size_t i;
+size_t limit;
 int ret = -1;

 if (libxlDoNodeGetInfo(driver, nodeinfo)  0)
@@ -470,7 +471,8 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, 
virDomainObjPtr vm)

 cpumask = (uint8_t*) def-cputune.vcpupin[vcpu]-cpumask;

-for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; ++i) {
+limit = MIN(VIR_DOMAIN_CPUMASK_LEN, cpumaplen);
+for (i = 0; i  limit; ++i) {
 if (cpumask[i])
 VIR_USE_CPU(cpumap, i);
 }
-- 
1.8.4

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


Re: [libvirt] failed to write to disk on vm with lvm pool

2013-10-24 Thread Vasiliy Tolstov
2013/10/24 Vasiliy Tolstov v.tols...@selfip.ru:
 Hi all. Today i can't mkfs.ext3 inside virual machine while install it
 (ubuntu 13.04).

 Why this happening? On other node i see that
 virSecurityDACSetOwnership sets perms on /dev/vg/xxx and /dev/dm-xxx,
 but in this host this not happening.


Ps. i'm using libvirt 1.0.2 and QEMU emulator version 1.4.0 (Debian
1.4.0+dfsg-1expubuntu4), Copyright (c) 2003-2008 Fabrice Bellard


-- 
Vasiliy Tolstov,
e-mail: v.tols...@selfip.ru
jabber: v...@selfip.ru

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


Re: [libvirt] RHBZ 1013045: Crash on xen domain startup

2013-10-24 Thread Martin Kletzander
On Wed, Oct 23, 2013 at 10:46:14AM -0700, Jeremy Fitzhardinge wrote:
 Hi all,
 
 I posted this bug (https://bugzilla.redhat.com/show_bug.cgi?id=1013045)
 to the Redhat Bugzilla a while ago, and the only response has been to
 post a note to this list about the bug.
 
 Summary below, but it looks like a pretty clear use-after-free or
 something. The full details are attached to the bug report.
 

From the looks of the BZ, I think the probnlem found by valgrind (not
the one in libxl) is a different than the one which causes the
'invalid free()', but anyway, I posted a patch [1] which might help
(read: fixes a problem found out thanks to the valgrind output), but I
have no way to test it.  If you do, I would appreciate you trying
whether the issue gets fixed for you with that patch.

Thank you,
Martin

[1] https://www.redhat.com/archives/libvir-list/2013-October/msg01075.html

 Thanks,
 
 J
 
 
 --
 Description of problem:
 When starting a Xen domain with libvirt + libxl, it crashes after
 creating the domain.  The domain is left in a paused state, and works
 fine if manually unpaused with xl unpause. virt-manager never shows the
 domain as running.
 
 [...]
 
 Steps to Reproduce:
 1. Open virt-manager
 2. Connect to localhost (xen)
 3. Start a domain
 
 Actual results:
 Domain is created in a paused state, virt-manager shows errors about
 losing connection to the daemon. Logs show libvirtd crashed.
 
 Expected results:
 Domain creation.
 
 Additional info:
 Sep 27 09:08:30 saboo libvirtd[24880]: *** Error in
 `/usr/sbin/libvirtd': free(): invalid next size (fast):
 0x7f82c8003210 ***
 Sep 27 09:08:30 saboo libvirtd[24880]: === Backtrace: =
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libc.so.6(+0x365b27d0e8)[0x7f82f5a7a0e8]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(virFree+0x1a)[0x7f82f8f07d5a]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /usr/lib64/libvirt/connection-driver/libvirt_driver_libxl.so(+0x14b6c)[0x7f82e032bb6c]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /usr/lib64/libvirt/connection-driver/libvirt_driver_libxl.so(+0x154d4)[0x7f82e032c4d4]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(virDomainCreate+0xf7)[0x7f82f8fdb6b7]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /usr/sbin/libvirtd(+0x350c7)[0x7f82f9a1a0c7]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(virNetServerProgramDispatch+0x3ba)[0x7f82f90314aa]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(+0x3a33f822d8)[0x7f82f902c2d8]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(+0x3a33ea0c15)[0x7f82f8f4ac15]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(+0x3a33ea0691)[0x7f82f8f4a691]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libpthread.so.0(+0x365ba07c53)[0x7f82f61ccc53]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libc.so.6(clone+0x6d)[0x7f82f5af2d3d]
 
 
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [PATCH] Avoid Coverity DEADCODE warning

2013-10-24 Thread John Ferlan
Ping

On 10/18/2013 06:59 AM, John Ferlan wrote:
 Commit '922b7fda' resulted in two DEADCODE warnings from Coverity in
 remoteDispatchAuthPolkit and virAccessDriverPolkitFormatProcess.
 Commit '604ae657' modified the daemon.c code to remove the deadcode
 issue, but did not do so for viracessdriverpolkit.c. This just mimics
 the same changes
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/access/viraccessdriverpolkit.c | 27 +--
  1 file changed, 13 insertions(+), 14 deletions(-)
 
 diff --git a/src/access/viraccessdriverpolkit.c 
 b/src/access/viraccessdriverpolkit.c
 index ff82583..b9907ba 100644
 --- a/src/access/viraccessdriverpolkit.c
 +++ b/src/access/viraccessdriverpolkit.c
 @@ -76,8 +76,9 @@ virAccessDriverPolkitFormatProcess(const char *actionid)
  const char *callerTime = NULL;
  const char *callerUid = NULL;
  char *ret = NULL;
 -bool supportsuid = false;
 -static bool polkitInsecureWarned;
 +#ifndef PKCHECK_SUPPORTS_UID
 +static bool polkitInsecureWarned = false;
 +#endif
  
  if (!identity) {
  virAccessError(VIR_ERR_ACCESS_DENIED,
 @@ -109,19 +110,17 @@ virAccessDriverPolkitFormatProcess(const char *actionid)
  }
  
  #ifdef PKCHECK_SUPPORTS_UID
 -supportsuid = true;
 -#endif
 -if (supportsuid) {
 -if (virAsprintf(ret, %s,%s,%s, callerPid, callerTime, callerUid) 
  0)
 -goto cleanup;
 -} else {
 -if (!polkitInsecureWarned) {
 -VIR_WARN(No support for caller UID with pkcheck. This 
 deployment is known to be insecure.);
 -polkitInsecureWarned = true;
 -}
 -if (virAsprintf(ret, %s,%s, callerPid, callerTime)  0)
 -goto cleanup;
 +if (virAsprintf(ret, %s,%s,%s, callerPid, callerTime, callerUid)  0)
 +goto cleanup;
 +#else
 +if (!polkitInsecureWarned) {
 +VIR_WARN(No support for caller UID with pkcheck. 
 + This deployment is known to be insecure.);
 +polkitInsecureWarned = true;
  }
 +if (virAsprintf(ret, %s,%s, callerPid, callerTime)  0)
 +goto cleanup;
 +#endif
  
  cleanup:
  virObjectUnref(identity);
 

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


Re: [libvirt] [PATCH]lxc: improve readability of lxcContainer[Send|Waitfor]Continue

2013-10-24 Thread Chen Hanxiao


  Subject: Re: [libvirt] [PATCH]lxc: improve readability of
  lxcContainer[Send|Waitfor]Continue
 
  On 16.10.2013 08:27, Chen Hanxiao wrote:
   From: Chen Hanxiao chenhanx...@cn.fujitsu.com
 
  I think this can be achieved even without this hack. We already can
  produce a stack trace on VIR_DEBUG() [1]. And if you don't want to keep
  only some debug messages, apply filters.
 
 
 If we only config debug option for output values, we got:
 604+: 12010: debug : lxcContainerWaitForContinue:392 : Wait continue
on
 fd 21
 
 If we config filter option as 1:+lxc, we got:
 2013-10-22 02:24:30.365+: 13579: debug :
 lxcContainerWaitForContinue:392
 : Wait continue on fd 12
 /usr/libexec/libvirt_lxc(virLogMessage+0x97)[0x7f2e1bdfa387]
 /usr/libexec/libvirt_lxc(lxcContainerWaitForContinue+0x4b)[0x7f2e1bd7346b]
 /usr/libexec/libvirt_lxc(+0x3197b)[0x7f2e1bd7b97b]
 /usr/libexec/libvirt_lxc(main+0xcdf)[0x7f2e1bd70e4f]
 /lib64/libc.so.6(__libc_start_main+0xf5)[0x7f2e19761b75]
 /usr/libexec/libvirt_lxc(+0x27065)[0x7f2e1bd71065]
 
 We still can't see who is the caller, and we got too many logs.
 Additionally, filters with long name like ' lxcContainerWaitForContinue'
 will not take effect.
 
 With this patch, we got:
 17931: debug : lxcContainerWaitForContinue:394 : virLXCControllerRun wait
 continue on fd 12
 
 I think we still need this patch.
 
 Thanks!
 

Hi
Any comments?

Thanks!


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


Re: [libvirt] [PATCH] libxl: Fix possible invalid read

2013-10-24 Thread Daniel P. Berrange
On Thu, Oct 24, 2013 at 10:50:02AM +0100, Martin Kletzander wrote:
 According to the following valgrind output, there seems to be a
 invalid limit for the iterator (captured on Fedora 19):
 
 ==3945== Invalid read of size 1
 ==3945==at 0x1E1FA410: libxlVmStart (libxl_driver.c:475)
 ==3945==by 0x1E1FAD9A: libxlDomainCreateWithFlags (libxl_driver.c:2633)
 ==3945==by 0x5187D46: virDomainCreate (libvirt.c:9439)
 ==3945==by 0x13BAA6: remoteDispatchDomainCreateHelper 
 (remote_dispatch.h:2910)
 ==3945==by 0x51DE5B9: virNetServerProgramDispatch 
 (virnetserverprogram.c:435)
 ==3945==by 0x51D93E7: virNetServerHandleJob (virnetserver.c:165)
 ==3945==by 0x50F5BF4: virThreadPoolWorker (virthreadpool.c:144)
 ==3945==by 0x50F5670: virThreadHelper (virthreadpthread.c:161)
 ==3945==by 0x8046C52: start_thread (pthread_create.c:308)
 ==3945==by 0x8758E1C: clone (clone.S:113)
 ==3945==  Address 0x23424d81 is 0 bytes after a block of size 1 alloc'd
 ==3945==at 0x4A08121: calloc (in 
 /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==3945==by 0x50B1F8C: virAllocN (viralloc.c:189)
 ==3945==by 0x1E1FA3CA: libxlVmStart (libxl_driver.c:468)
 ==3945==by 0x1E1FAD9A: libxlDomainCreateWithFlags (libxl_driver.c:2633)
 ==3945==by 0x5187D46: virDomainCreate (libvirt.c:9439)
 ==3945==by 0x13BAA6: remoteDispatchDomainCreateHelper 
 (remote_dispatch.h:2910)
 ==3945==by 0x51DE5B9: virNetServerProgramDispatch 
 (virnetserverprogram.c:435)
 ==3945==by 0x51D93E7: virNetServerHandleJob (virnetserver.c:165)
 ==3945==by 0x50F5BF4: virThreadPoolWorker (virthreadpool.c:144)
 ==3945==by 0x50F5670: virThreadHelper (virthreadpthread.c:161)
 ==3945==by 0x8046C52: start_thread (pthread_create.c:308)
 ==3945==by 0x8758E1C: clone (clone.S:113)
 ==3945==
 
 Related: https://bugzilla.redhat.com/show_bug.cgi?id=1013045
 Signed-off-by: Martin Kletzander mklet...@redhat.com

 diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
 index e2a6d44..4928695 100644
 --- a/src/libxl/libxl_driver.c
 +++ b/src/libxl/libxl_driver.c
 @@ -454,6 +454,7 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr 
 driver, virDomainObjPtr vm)
  size_t cpumaplen;
  int vcpu;
  size_t i;
 +size_t limit;
  int ret = -1;
 
  if (libxlDoNodeGetInfo(driver, nodeinfo)  0)
 @@ -470,7 +471,8 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr 
 driver, virDomainObjPtr vm)
 
  cpumask = (uint8_t*) def-cputune.vcpupin[vcpu]-cpumask;
 
 -for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; ++i) {
 +limit = MIN(VIR_DOMAIN_CPUMASK_LEN, cpumaplen);
 +for (i = 0; i  limit; ++i) {
  if (cpumask[i])
  VIR_USE_CPU(cpumap, i);
  }

Hmm, what is strange about that bug is that the crash is in free() wrt
memory corruption, but valgrind only reports bogus reads. Such a crash
in free() usually implies a bogus write. The VIR_USE_CPU macro does
do such a write though, so the patch looks sane - valgrind must have
just not seen it

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] [PATCHv2 2/2] virsh: undocument --shareable (--mode already covers it)

2013-10-24 Thread Chen Hanxiao


 -Original Message-
 From: Eric Blake [mailto:ebl...@redhat.com]
 Sent: Thursday, October 24, 2013 3:22 PM
 To: libvir-list@redhat.com
 Cc: chenhanx...@cn.fujitsu.com
 Subject: [PATCHv2 2/2] virsh: undocument --shareable (--mode already covers
 it)
 
 Commit e962a57 added 'attach-disk --shareable', even though we
 already had 'attach-disk --mode=shareable'.  Worse, if the user
 types 'attach-disk --mode=readonly --shareable', we create
 non-sensical XML.  The best solution is just to undocument the
 duplicate spelling, by having it fall back to the preferred
 spelling.
 
 * tools/virsh-domain.c (cmdAttachDisk): Let alias handling fix our
 mistake in exposing a second spelling for an existing option.
 * tools/virsh.pod: Fix documentation.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  tools/virsh-domain.c | 11 ---

ACK

Thanks!


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


Re: [libvirt] [PATCHv2 0/2] virsh: hide 'attach-disk --shareable'

2013-10-24 Thread Peter Krempa
On 10/24/13 08:21, Eric Blake wrote:
 As promised here:
 https://www.redhat.com/archives/libvir-list/2013-October/msg01047.html
 
 Eric Blake (2):
   virsh: allow alias to expand to opt=value pair
   virsh: undocument --shareable (--mode already covers it)
 
  tests/virshtest.c|  1 +
  tools/virsh-domain.c | 11 --
  tools/virsh.c| 58 
 
  tools/virsh.pod  |  4 ++--
  4 files changed, 57 insertions(+), 17 deletions(-)
 

ACK series. Hopefully we won't need much hacks like this.

Peter



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] libxl: Fix possible invalid read

2013-10-24 Thread Martin Kletzander
On Thu, Oct 24, 2013 at 10:57:37AM +0100, Daniel P. Berrange wrote:
 On Thu, Oct 24, 2013 at 10:50:02AM +0100, Martin Kletzander wrote:
  According to the following valgrind output, there seems to be a
  invalid limit for the iterator (captured on Fedora 19):
  
  ==3945== Invalid read of size 1
  ==3945==at 0x1E1FA410: libxlVmStart (libxl_driver.c:475)
  ==3945==by 0x1E1FAD9A: libxlDomainCreateWithFlags (libxl_driver.c:2633)
  ==3945==by 0x5187D46: virDomainCreate (libvirt.c:9439)
  ==3945==by 0x13BAA6: remoteDispatchDomainCreateHelper 
  (remote_dispatch.h:2910)
  ==3945==by 0x51DE5B9: virNetServerProgramDispatch 
  (virnetserverprogram.c:435)
  ==3945==by 0x51D93E7: virNetServerHandleJob (virnetserver.c:165)
  ==3945==by 0x50F5BF4: virThreadPoolWorker (virthreadpool.c:144)
  ==3945==by 0x50F5670: virThreadHelper (virthreadpthread.c:161)
  ==3945==by 0x8046C52: start_thread (pthread_create.c:308)
  ==3945==by 0x8758E1C: clone (clone.S:113)
  ==3945==  Address 0x23424d81 is 0 bytes after a block of size 1 alloc'd
  ==3945==at 0x4A08121: calloc (in 
  /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==3945==by 0x50B1F8C: virAllocN (viralloc.c:189)
  ==3945==by 0x1E1FA3CA: libxlVmStart (libxl_driver.c:468)
  ==3945==by 0x1E1FAD9A: libxlDomainCreateWithFlags (libxl_driver.c:2633)
  ==3945==by 0x5187D46: virDomainCreate (libvirt.c:9439)
  ==3945==by 0x13BAA6: remoteDispatchDomainCreateHelper 
  (remote_dispatch.h:2910)
  ==3945==by 0x51DE5B9: virNetServerProgramDispatch 
  (virnetserverprogram.c:435)
  ==3945==by 0x51D93E7: virNetServerHandleJob (virnetserver.c:165)
  ==3945==by 0x50F5BF4: virThreadPoolWorker (virthreadpool.c:144)
  ==3945==by 0x50F5670: virThreadHelper (virthreadpthread.c:161)
  ==3945==by 0x8046C52: start_thread (pthread_create.c:308)
  ==3945==by 0x8758E1C: clone (clone.S:113)
  ==3945==
  
  Related: https://bugzilla.redhat.com/show_bug.cgi?id=1013045
  Signed-off-by: Martin Kletzander mklet...@redhat.com
 
  diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
  index e2a6d44..4928695 100644
  --- a/src/libxl/libxl_driver.c
  +++ b/src/libxl/libxl_driver.c
  @@ -454,6 +454,7 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr 
  driver, virDomainObjPtr vm)
   size_t cpumaplen;
   int vcpu;
   size_t i;
  +size_t limit;
   int ret = -1;
  
   if (libxlDoNodeGetInfo(driver, nodeinfo)  0)
  @@ -470,7 +471,8 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr 
  driver, virDomainObjPtr vm)
  
   cpumask = (uint8_t*) def-cputune.vcpupin[vcpu]-cpumask;
  
  -for (i = 0; i  VIR_DOMAIN_CPUMASK_LEN; ++i) {
  +limit = MIN(VIR_DOMAIN_CPUMASK_LEN, cpumaplen);
  +for (i = 0; i  limit; ++i) {
   if (cpumask[i])
   VIR_USE_CPU(cpumap, i);
   }
 
 Hmm, what is strange about that bug is that the crash is in free() wrt
 memory corruption, but valgrind only reports bogus reads. Such a crash
 in free() usually implies a bogus write. The VIR_USE_CPU macro does
 do such a write though, so the patch looks sane - valgrind must have
 just not seen it
 

It points to another problem in libxl which I don't have set up to use
(and have nowhere to try it), but I can hardly suspect that issue
would corrupt libvirt's memory.

 ACK
 

Thanks, pushed.

Martin

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


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

Re: [libvirt] [PATCH] Avoid Coverity DEADCODE warning

2013-10-24 Thread Eric Blake
On 10/18/2013 11:59 AM, John Ferlan wrote:
 Commit '922b7fda' resulted in two DEADCODE warnings from Coverity in
 remoteDispatchAuthPolkit and virAccessDriverPolkitFormatProcess.
 Commit '604ae657' modified the daemon.c code to remove the deadcode
 issue, but did not do so for viracessdriverpolkit.c. This just mimics
 the same changes
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/access/viraccessdriverpolkit.c | 27 +--
  1 file changed, 13 insertions(+), 14 deletions(-)


 +#ifndef PKCHECK_SUPPORTS_UID
 +static bool polkitInsecureWarned = false;

Since this variable is static, C guarantees this already starts life as
false, without needing the explicit initializer.  But up to you if you
want to reduce typing.

ACK.

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



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

Re: [libvirt] [PATCHv2 0/2] virsh: hide 'attach-disk --shareable'

2013-10-24 Thread Eric Blake
On 10/24/2013 11:05 AM, Peter Krempa wrote:
 On 10/24/13 08:21, Eric Blake wrote:
 As promised here:
 https://www.redhat.com/archives/libvir-list/2013-October/msg01047.html

 Eric Blake (2):
   virsh: allow alias to expand to opt=value pair
   virsh: undocument --shareable (--mode already covers it)

  tests/virshtest.c|  1 +
  tools/virsh-domain.c | 11 --
  tools/virsh.c| 58 
 
  tools/virsh.pod  |  4 ++--
  4 files changed, 57 insertions(+), 17 deletions(-)

 
 ACK series. Hopefully we won't need much hacks like this.

Thanks; pushed.

-- 
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] Avoid Coverity DEADCODE warning

2013-10-24 Thread Martin Kletzander
On Fri, Oct 18, 2013 at 06:59:51AM -0400, John Ferlan wrote:
 Commit '922b7fda' resulted in two DEADCODE warnings from Coverity in
 remoteDispatchAuthPolkit and virAccessDriverPolkitFormatProcess.
 Commit '604ae657' modified the daemon.c code to remove the deadcode
 issue, but did not do so for viracessdriverpolkit.c. This just mimics
 the same changes
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/access/viraccessdriverpolkit.c | 27 +--
  1 file changed, 13 insertions(+), 14 deletions(-)
 

ACK,

Martin


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

Re: [libvirt] [PATCH] Avoid Coverity DEADCODE warning

2013-10-24 Thread John Ferlan
Thanks for the reviews - pushed now.

John

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


Re: [libvirt] [PATCHv2 0/8] Introduce paravirtual spinlock support

2013-10-24 Thread Peter Krempa
On 10/17/13 14:10, Peter Krempa wrote:
 Version 2 fixes stuff pointed out in Dan's review
 Jiri Denemark (2):
   cpu: Export few x86-specific APIs
   qemu: Add monitor APIs to fetch CPUID data from QEMU
 
 Peter Krempa (6):
   cpu_x86: Refactor storage of CPUID data to add support for KVM
 features
   cpu: x86: Parse the CPU feature map only once
   cpu: x86: Add internal CPUID features support and KVM feature bits
   conf: Refactor storing and usage of feature flags
   qemu: Add support for paravirtual spinlocks in the guest
   qemu: process: Validate specific CPUID flags of a guest

Could somebody please have a look at this series?

Thanks

Peter




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]lxc: improve readability of lxcContainer[Send|Waitfor]Continue

2013-10-24 Thread Martin Kletzander
On Thu, Oct 24, 2013 at 05:55:59PM +0800, Chen Hanxiao wrote:
 
 
   Subject: Re: [libvirt] [PATCH]lxc: improve readability of
   lxcContainer[Send|Waitfor]Continue
  
   On 16.10.2013 08:27, Chen Hanxiao wrote:
From: Chen Hanxiao chenhanx...@cn.fujitsu.com
  
   I think this can be achieved even without this hack. We already can
   produce a stack trace on VIR_DEBUG() [1]. And if you don't want to keep
   only some debug messages, apply filters.
  
  
  If we only config debug option for output values, we got:
  604+: 12010: debug : lxcContainerWaitForContinue:392 : Wait continue
 on
  fd 21
  
  If we config filter option as 1:+lxc, we got:
  2013-10-22 02:24:30.365+: 13579: debug :
  lxcContainerWaitForContinue:392
  : Wait continue on fd 12
  /usr/libexec/libvirt_lxc(virLogMessage+0x97)[0x7f2e1bdfa387]
  /usr/libexec/libvirt_lxc(lxcContainerWaitForContinue+0x4b)[0x7f2e1bd7346b]
  /usr/libexec/libvirt_lxc(+0x3197b)[0x7f2e1bd7b97b]
  /usr/libexec/libvirt_lxc(main+0xcdf)[0x7f2e1bd70e4f]
  /lib64/libc.so.6(__libc_start_main+0xf5)[0x7f2e19761b75]
  /usr/libexec/libvirt_lxc(+0x27065)[0x7f2e1bd71065]
  

You can convert those using addr2line.

  We still can't see who is the caller, and we got too many logs.
  Additionally, filters with long name like ' lxcContainerWaitForContinue'
  will not take effect.
  
  With this patch, we got:
  17931: debug : lxcContainerWaitForContinue:394 : virLXCControllerRun wait
  continue on fd 12
  
  I think we still need this patch.
  

I don't, though.  This adds unnecessary code.

Sorry,
Martin


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

Re: [libvirt] [Qemu-devel] [PATCH 14/17] add new RanState RAN_STATE_FLIPPING_MIGRATE

2013-10-24 Thread Paolo Bonzini
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Il 22/10/2013 09:10, Eric Blake ha scritto:
 http://wiki.qemu.org/Planning/1.7 Soft freeze has already
 happened, so it's up to the maintainers whether there is still time
 to be adding this feature in 1.7 - but yes, that would affect the
 tag you list in your docs.

No, this is a 1.8 feature at this point.

Paolo
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSaSqeAAoJEBvWZb6bTYby7sAP+gPF35M0+8YW/ujlDjXqezYw
gjtpSjKJSLx5mF4l9cA9SrQQFSkikfT/5QUZnMfjCXzWobH2y07FdUIfYR+Y5vB0
Op7Ywf01qLOgX1/qZaikZVDLYmduir1qk6Dxp85epGoVJpCC9natLkT3bPIAkB4S
Mvl2oDEnOQD5b5W5gVe80UvLIMOYW1CtJD87u6OiOm4pMVtpOp8xz02ToRO6xSSx
/PjMYY07kWlOGrMkPw/BUX92crxEfzarzhd4OrIfVhEr5l0H9axY2WJKxdMsXREI
TRL77GhqFHKz8O8uAh0G5Y1MKoX3/6mxIA1qSoMyTlDI4+qWVZwt5pJjmJjiGW58
HmsigFdBfvPqDwLCrnIrQd1aRS5oHzL++AncctlbXqayDo4IT+0lM29RBHM1obwO
GlxePNzbiKljvAyJfvIoJlUkfFvXHLZ1a94+AWXiZCcb+gRUcMw7hxmnPmyMr92X
bYkY/ZEtd8FLj+4weFAwWnrAosyp0UC4qF9y9zk9WXjUqz52KPWwVP3M10ElxjQs
XBHGmlf3+eQu1mPYf1yWO57nwHSNisnCktQ9aSiupkYJl2rBwu/qizSyfRlEV+uW
pJ++Uia29527JcYtVVM2u0FcaM5i+ZWVcD/4KVy6lFFQBK7Rt9wmhcAgfd06ynkV
1G+niTsF24mzfoVxcvPD
=BgUk
-END PGP SIGNATURE-

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


Re: [libvirt] [Qemu-devel] [PATCH 14/17] add new RanState RAN_STATE_FLIPPING_MIGRATE

2013-10-24 Thread Paolo Bonzini
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Il 22/10/2013 04:51, Eric Blake ha scritto:
 
 Last time we added a new user-visible runstate, it broke migration
 with older libvirt versions that weren't prepared to see the new
 state (hmm, I need to check if libvirt has fixed that in the
 meantime; adding a cc...).  Paolo's advice at the time was that it
 is okay to require a new libvirt when using a new qemu, and that
 libvirt should be taught to treat all unknown RunState as if they
 were 'running'; although for this particular addition it might be
 nicer to have libvirt lump 'inmigrate' and 'flipping-migrate' to
 the same usage.

This is not a problem in this case, because the new runstate will only
appear after enabling a new migration capability.  Only new libvirt
will be able to enable the capability and thus reach the new runstate.

Poalo
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.22 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSaSu2AAoJEBvWZb6bTYbycoUP/RDsMA/62ukPU1stvKhoOPLK
+Zi9OOSd8tIAAkHD0rDS5pQePklZ2AqKmOpJujRHhavGA/kKcMhL+79dK22UJSWn
fQPgxiivylZcFWbhF97H9eW27Vmw5la1Ob2onq2g+KY/AvL5yrEpBrN60XipHtrd
uPM2yWlERSlKcQj0nrTv5Oz3p2k9jWQrGzWX16cC+nFAaR9K/D+afOyl/3ZvixKw
ekiIIxStoJQGCogU/rJp1nJcenJfKSOofNKPU8xKkpexK4pw+W1u9GZMaAgzXLRO
Q6p3R6raIRT42Hf820ASHsWeHYak2gYmZ+5FaKGPyjAL/iwKyr4FRp7uGXobN9sD
ziMX5gaXreVdBh8CIOqDrOGa7BNoEkId2sJrrjwmmD418uZNOGK/xdcPa+mFlc8Q
GkJ4y844OckkyLhqQnuVtCVtxGlNCU3Y/XHfTKELdTm1m1jdTdoNnBGFXD1IyTxU
9yPYfQRAeRy7yPEXqQw0qc7ZUj/fhqPPzijwpPrvmFvzAouUZjlpE6QoriiBGzRx
Csq+uwpJ2bsWOC5BGvxhrhNE4F9yhWGkotxod6gvULkOLkm/4Cg5/8aNSeYzInsm
UtJ5+oZD6jzOVW5brkFosoUvWzr6vJEvwoh7DVz5sVkAH/u93WR8jlG+NsTw5fTY
+hthfn5l153w5JDikLyV
=q1Ww
-END PGP SIGNATURE-

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


Re: [libvirt] [RFC] net-dhcp-leases: Query: Reg: Leases API Script

2013-10-24 Thread Nehal J Wani
I tried writing the helper program, didn't send v5, since I have some doubts.
The program works. Problems listed below.

diff --git a/src/Makefile.am b/src/Makefile.am
index 21b9caf..ef88132 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -825,6 +825,9 @@ STORAGE_HELPER_DISK_SOURCES =
 \
 UTIL_IO_HELPER_SOURCES =   \
util/iohelper.c

+UTIL_IO_LEASES_SOURCES =   \
+   util/leaseshelper.c
+
 # Network filters
 NWFILTER_DRIVER_SOURCES =  \
nwfilter/nwfilter_driver.h nwfilter/nwfilter_driver.c   \
@@ -2384,6 +2387,23 @@ libvirt_iohelper_CFLAGS = \
$(NULL)
 endif WITH_LIBVIRTD

+if WITH_LIBVIRTD
+libexec_PROGRAMS += libvirt_leaseshelper
+libvirt_leaseshelper_SOURCES = $(UTIL_IO_LEASES_SOURCES)
+libvirt_leaseshelper_LDFLAGS = \
+   $(NULL)
+libvirt_leaseshelper_LDADD =   \
+   libvirt_util.la \
+   ../gnulib/lib/libgnu.la
+if WITH_DTRACE_PROBES
+libvirt_leaseshelper_LDADD += libvirt_probes.lo
+endif WITH_DTRACE_PROBES
+
+libvirt_leaseshelper_CFLAGS = \
+   $(PIE_CFLAGS) \
+   $(NULL)
+endif WITH_LIBVIRTD
+
 if WITH_STORAGE_DISK
 if WITH_LIBVIRTD
 libexec_PROGRAMS += libvirt_parthelper
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3ce3130..182a426 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -1058,6 +1058,8 @@
networkBuildDhcpDaemonCommandLine(virNetworkObjPtr network,

 cmd = virCommandNew(dnsmasqCapsGetBinaryPath(caps));
 virCommandAddArgFormat(cmd, --conf-file=%s, configfile);
+virCommandAddArgFormat(cmd, --dhcp-script=%s,
/home/Wani/libvirt/src/libvirt_leaseshelper);
+//virCommandAddArgFormat(cmd, --dhcp-script=%s,
/var/lib/libvirt/dnsmasq/dhcp-script);
 *cmdout = cmd;
 ret = 0;
 cleanup:


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

#include config.h

#include stdio.h
#include stdlib.h

#include virutil.h
#include virfile.h
#include virbuffer.h
#include virstring.h
#include virerror.h
#include viralloc.h

/**
 * VIR_NETWORK_DHCP_LEASE_FIELDS:
 *
 * Macro providing the maximum number of fields in an entry in
 * the leases file
 */
#define VIR_NETWORK_DHCP_LEASE_FIELDS 7
/**
 * VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX:
 *
 * Macro providing the upper limit on the size of leases file
 */
#define VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX 2097152

/*
 * Use this when passing possibly-NULL strings to printf-a-likes.
 */
# define NULL_STR(s) ((s) ? (s) : *)

int
main(int argc, char **argv) {
/* Doesn't hurt to check */
if (argc  4)
return -1;

const char *action = argv[1];
const char *interface = NULL_STR(getenv(DNSMASQ_INTERFACE));
const char *expirytime = NULL_STR(getenv(DNSMASQ_LEASE_EXPIRES));
const char *mac = argv[2];
const char *ip = argv[3];
const char *iaid = NULL_STR(getenv(DNSMASQ_IAID));
const char *hostname = NULL_STR(getenv(DNSMASQ_SUPPLIED_HOSTNAME));
const char *clientid = NULL_STR(getenv(DNSMASQ_CLIENT_ID));
const char *lease_file = /var/lib/libvirt/dnsmasq/dnsmasq-ip-mac.status;
const char *leases_str = NULL;
char *lease_entries = NULL;
char *lease_entry = NULL;
char **lease_fields = NULL;
bool delete = false;
bool add = false;
int rv = -1;
int lease_file_len = 0;
virBuffer buf_new_lease = VIR_BUFFER_INITIALIZER;
virBuffer buf_all_leases = VIR_BUFFER_INITIALIZER;
FILE *fp = NULL;

if (getenv(DNSMASQ_IAID)) {
mac = NULL_STR(getenv(DNSMASQ_MAC));
clientid = argv[2];
}

/* Make sure the file exists. If not, 'touch' it */
fp = fopen(lease_file, a+);
fclose(fp);

/* Read entire contents */
if ((lease_file_len = virFileReadAll(lease_file,
VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX,
lease_entries))  0) {
goto cleanup;
}


if (STREQ(action, add) || STREQ(action, old) || STREQ(action, del)) {
if (mac || STREQ(action, del)) {
/* Delete the corresponding lease */

[libvirt] [PATCH] virnetsocket: fix getsockopt on FreeBSD

2013-10-24 Thread Ryota Ozaki
aa0f099 introduced a strict error checking for getsockopt and it
revealed that getting a peer credential of a socket on FreeBSD
didn't work. Libvirtd hits the error:
  error : virNetSocketGetUNIXIdentity:1198 : Failed to get valid
  client socket identity groups

SOL_SOCKET (0x) was used as a level of getsockopt for
LOCAL_PEERCRED, however, it was wrong. 0 is correct as well as
Mac OS X.

So for LOCAL_PEERCRED our options are SOL_LOCAL (if defined) or
0 on Mac OS X and FreeBSD. According to the fact, the patch
simplifies the code by removing ifdef __APPLE__.

I tested the patch on FreeBSD 8.4, 9.2 and 10.0-BETA1.

Signed-off-by: Ryota Ozaki ozaki.ry...@gmail.com
---
 src/rpc/virnetsocket.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 3eb5708..04bf25a 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -1152,18 +1152,17 @@ cleanup:
 /* VIR_SOL_PEERCRED - the value needed to let getsockopt() work with
  * LOCAL_PEERCRED
  */
-# ifdef __APPLE__
-#  ifdef SOL_LOCAL
-#   define VIR_SOL_PEERCRED SOL_LOCAL
-#  else
-/* Prior to Mac OS X 10.7, SOL_LOCAL was not defined and users were
- * expected to supply 0 as the second value for getsockopt() when using
- * LOCAL_PEERCRED
- */
-#   define VIR_SOL_PEERCRED 0
-#  endif
+
+/* Mac OS X 10.8 provides SOL_LOCAL for LOCAL_PEERCRED */
+# ifdef SOL_LOCAL
+#  define VIR_SOL_PEERCRED SOL_LOCAL
 # else
-#  define VIR_SOL_PEERCRED SOL_SOCKET
+/* FreeBSD and Mac OS X prior to 10.7, SOL_LOCAL is not defined and
+ * users are expected to supply 0 as the second value for getsockopt()
+ * when using LOCAL_PEERCRED. NB SOL_SOCKET cannot be used instead
+ * of SOL_LOCAL
+ */
+#  define VIR_SOL_PEERCRED 0
 # endif
 
 int virNetSocketGetUNIXIdentity(virNetSocketPtr sock,
-- 
1.8.4

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


Re: [libvirt] RHBZ 1013045: Crash on xen domain startup

2013-10-24 Thread Jeremy Fitzhardinge

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

On 10/24/2013 02:52 AM, Martin Kletzander wrote:
 On Wed, Oct 23, 2013 at 10:46:14AM -0700, Jeremy Fitzhardinge wrote:
 Hi all,

 I posted this bug (https://bugzilla.redhat.com/show_bug.cgi?id=1013045)
 to the Redhat Bugzilla a while ago, and the only response has been to
 post a note to this list about the bug.

 Summary below, but it looks like a pretty clear use-after-free or
 something. The full details are attached to the bug report.


 From the looks of the BZ, I think the probnlem found by valgrind (not
 the one in libxl) is a different than the one which causes the
 'invalid free()', but anyway, I posted a patch [1] which might help
 (read: fixes a problem found out thanks to the valgrind output), but I
 have no way to test it.  If you do, I would appreciate you trying
 whether the issue gets fixed for you with that patch.

Thanks, I'll give it a try when I get the chance. I agree that none of
the Valgrind messages really point to why I'm getting invalid frees, or
why valgrind itself is crashing. The invalid memory accesses are all
reads, so while not good, don't explain the symptom.

I think SVN Valgrind has more Xen support in it, so I'm going to try that.

J



 Thank you,
 Martin

 [1] https://www.redhat.com/archives/libvir-list/2013-October/msg01075.html

 Thanks,

 J


 --
 Description of problem:
 When starting a Xen domain with libvirt + libxl, it crashes after
 creating the domain.  The domain is left in a paused state, and works
 fine if manually unpaused with xl unpause. virt-manager never shows the
 domain as running.

 [...]

 Steps to Reproduce:
 1. Open virt-manager
 2. Connect to localhost (xen)
 3. Start a domain

 Actual results:
 Domain is created in a paused state, virt-manager shows errors about
 losing connection to the daemon. Logs show libvirtd crashed.

 Expected results:
 Domain creation.

 Additional info:
 Sep 27 09:08:30 saboo libvirtd[24880]: *** Error in
 `/usr/sbin/libvirtd': free(): invalid next size (fast):
 0x7f82c8003210 ***
 Sep 27 09:08:30 saboo libvirtd[24880]: === Backtrace: =
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libc.so.6(+0x365b27d0e8)[0x7f82f5a7a0e8]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(virFree+0x1a)[0x7f82f8f07d5a]
 Sep 27 09:08:30 saboo libvirtd[24880]:

/usr/lib64/libvirt/connection-driver/libvirt_driver_libxl.so(+0x14b6c)[0x7f82e032bb6c]
 Sep 27 09:08:30 saboo libvirtd[24880]:

/usr/lib64/libvirt/connection-driver/libvirt_driver_libxl.so(+0x154d4)[0x7f82e032c4d4]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(virDomainCreate+0xf7)[0x7f82f8fdb6b7]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /usr/sbin/libvirtd(+0x350c7)[0x7f82f9a1a0c7]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(virNetServerProgramDispatch+0x3ba)[0x7f82f90314aa]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(+0x3a33f822d8)[0x7f82f902c2d8]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(+0x3a33ea0c15)[0x7f82f8f4ac15]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libvirt.so.0(+0x3a33ea0691)[0x7f82f8f4a691]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libpthread.so.0(+0x365ba07c53)[0x7f82f61ccc53]
 Sep 27 09:08:30 saboo libvirtd[24880]:
 /lib64/libc.so.6(clone+0x6d)[0x7f82f5af2d3d]



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

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.15 (GNU/Linux)

iQEkBAEBCgAGBQJSaU6eAAoJEAUkni6MUg7HY2MIOwdamON9ggteRT+FVO6cPISE
FEmP/75Hu06SqdcnNw8agwha4ZYBG5JpdrUgWcpudbg4A2XUVsrRXWLJOukaF8t7
d5OgZ9lKOU9Hv0o3+kDK+Yh6KWu9NwnvxoTtX+Ft+z+9vwARtL1JBIfuIcXegT9m
eV0A0M+mI3x0cp2PwnQepzJwxA3IOh9PtbP+3K+ydm/sU3Tiv/Qn9HEpgkR4AEOk
S6xTrJ2pPwi6/+/Tan7ya4Xcsyma2YTg0mu2dYkQighsSTp6yqI/fE2DFzsV6aJC
SDkdqlmxDzm1+bM5ybt8Afukvp1/wZJLR0Hk4TqggWiAxNpA+3j1TGt2VqsUUZWo
/lvHGs3KKQ==
=PzKp
-END PGP SIGNATURE-

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


Re: [libvirt] [PATCH]lxc: improve readability of lxcContainer[Send|Waitfor]Continue

2013-10-24 Thread Chen Hanxiao


 -Original Message-
 From: Martin Kletzander [mailto:mklet...@redhat.com]
 Sent: Thursday, October 24, 2013 6:52 PM
 To: Chen Hanxiao
 Cc: 'Michal Privoznik'; libvir-list@redhat.com
 Subject: Re: [libvirt] [PATCH]lxc: improve readability of
 lxcContainer[Send|Waitfor]Continue
 
 On Thu, Oct 24, 2013 at 05:55:59PM +0800, Chen Hanxiao wrote:
 
 
Subject: Re: [libvirt] [PATCH]lxc: improve readability of
lxcContainer[Send|Waitfor]Continue
   /usr/libexec/libvirt_lxc(+0x3197b)[0x7f2e1bd7b97b]
   /usr/libexec/libvirt_lxc(main+0xcdf)[0x7f2e1bd70e4f]
   /lib64/libc.so.6(__libc_start_main+0xf5)[0x7f2e19761b75]
   /usr/libexec/libvirt_lxc(+0x27065)[0x7f2e1bd71065]
  
 
 You can convert those using addr2line.

Thanks

 
   We still can't see who is the caller, and we got too many logs.
   Additionally, filters with long name like '
lxcContainerWaitForContinue'
   will not take effect.
  
   With this patch, we got:
   17931: debug : lxcContainerWaitForContinue:394 : virLXCControllerRun
 wait
   continue on fd 12
  
   I think we still need this patch.
  
 
 I don't, though.  This adds unnecessary code.

Thanks. I see.

 
 Sorry,
 Martin


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


Re: [libvirt] [PATCH 0/3] Add complete blkiotune support for per-device with blkio cgroup

2013-10-24 Thread hzguanqi...@corp.netease.com
Hi, guys,

I've developed some patches to support setting device iops and bps with blkio 
cgroup,
by extending the existed 'domainSetBlkioParameters' and 
'domainGetBlkioParameters'
interface. Please help me to review the patches and give me your expertise.

Thanks very much.

On 2013-10-24 16:18 , Guan Qiang wrote:
From: Guan Qiang hzguanqi...@corp.netease.com

The patches add a complete blkiotune support per-device with blkio cgroup 
for both lxc or qemu driver, by extending the existed 
'domainSetBlkioParameters' 
and 'domainGetBlkioParameters' interface. 
Beside device weight, read/write bps and iops throttle can be set per-device
with these patches.
Virsh command 'blkiotune' is extended to support the above function too.

Guan Qiang (3):
  qemu: add blkiotune support for device iops and bps throttle setting
  lxc: add blkiotune support for per device
  blkiotune: add virsh support for blkiotune interface

docs/formatdomain.html.in  |8 +
docs/schemas/domaincommon.rng  |   28 +-
include/libvirt/libvirt.h.in   |   40 ++
src/conf/domain_conf.c |  115 ++-
src/conf/domain_conf.h |   16 +-
src/libvirt_private.syms   |4 +-
src/lxc/lxc_cgroup.c   |9 +-
src/lxc/lxc_driver.c   |  743 +++-
src/qemu/qemu_cgroup.c |   10 +-
src/qemu/qemu_driver.c |  579 +--
src/util/vircgroup.c   |   79 ++-
src/util/vircgroup.h   |8 +-
.../qemuxml2argv-blkiotune-device.xml  |4 +
tools/virsh-domain.c   |   64 ++
tools/virsh.pod|   32 +-
15 files changed, 1614 insertions(+), 125 deletions(-)

-- 
1.7.9.5



-- 
Best regards!
GuanQiang
10:44:00--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 1/2]virsh: introduce member exclude_option in vshCmdOptDef and improve auto complete with it

2013-10-24 Thread Chen Hanxiao
From: Chen Hanxiao chenhanx...@cn.fujitsu.com

If we need to exclude one parameter from another,
we could use member 'exclude_option' to specify one.

With this flag, we could archive what Eric comments on:
https://www.redhat.com/archives/libvir-list/2013-October/msg00965.html
1. COMMAND TAB or COMMAND --TAB
Auto complete will NOT show option that marked as VSH_OT_ALIAS
2. COMMAND --shTAB
Auto complete will show --shareable
(this one was marked as VSH_OT_ALIAS)
3. COMMAND --mode XXX TAB or COMMAND --mode XXX --shTAB
Auto complete will NOT show --shareable
(we set new member exclude_option for mode)
4. COMMAND --shareable --moTAB
Auto complete will NOT show --mode
(we set new member exclude_option for mode)

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
 tools/virsh.c | 8 
 tools/virsh.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/tools/virsh.c b/tools/virsh.c
index bad78c9..93f525e 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2686,6 +2686,7 @@ vshReadlineOptionsGenerator(const char *text, int state)
 static int list_index, len;
 static const vshCmdDef *cmd = NULL;
 const char *name;
+const char *exclude_option;
 
 if (!state) {
 /* determine command name */
@@ -2712,6 +2713,7 @@ vshReadlineOptionsGenerator(const char *text, int state)
 
 while ((name = cmd-opts[list_index].name)) {
 const vshCmdOptDef *opt = cmd-opts[list_index];
+exclude_option = opt-exclude_option;
 char *res;
 
 list_index++;
@@ -2720,6 +2722,12 @@ vshReadlineOptionsGenerator(const char *text, int state)
 /* ignore non --option */
 continue;
 
+if (len == 2  opt-type == VSH_OT_ALIAS)
+continue;
+
+if (exclude_option  (strstr(rl_line_buffer, exclude_option)))
+continue;
+
 if (len  2) {
 if (STRNEQLEN(name, text + 2, len - 2))
 continue;
diff --git a/tools/virsh.h b/tools/virsh.h
index b843788..89b284f 100644
--- a/tools/virsh.h
+++ b/tools/virsh.h
@@ -173,6 +173,7 @@ struct _vshCmdOptDef {
  * the name of a later public option */
 vshCompleter completer; /* option completer */
 unsigned int completer_flags;   /* option completer flags */
+const char *exclude_option;/* check the exclusion of option */
 };
 
 /*
-- 
1.8.2.1

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


[libvirt] [PATCH 0/2] improve auto complete in virsh

2013-10-24 Thread Chen Hanxiao
From: Chen Hanxiao chenhanx...@cn.fujitsu.com


Chen Hanxiao (2):
  [libvirt]virsh: introduce member exclude_option in vshCmdOptDef and
improve auto complete with it
  [libvirt]virsh: set --shareable and --mode's new member:
exclude_option

 tools/virsh-domain.c | 6 --
 tools/virsh.c| 8 
 tools/virsh.h| 1 +
 3 files changed, 13 insertions(+), 2 deletions(-)

-- 
1.8.2.1

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


[libvirt] [PATCH 2/2]virsh: set --shareable and --mode's new member: exclude_option

2013-10-24 Thread Chen Hanxiao
From: Chen Hanxiao chenhanx...@cn.fujitsu.com

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
 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 59e3d8d..cb2678b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -297,11 +297,13 @@ static const vshCmdOptDef opts_attach_disk[] = {
 },
 {.name = shareable,
  .type = VSH_OT_ALIAS,
- .help = mode=shareable
+ .help = mode=shareable,
+ .exclude_option = --mode
 },
 {.name = mode,
  .type = VSH_OT_STRING,
- .help = N_(mode of device reading and writing)
+ .help = N_(mode of device reading and writing),
+ .exclude_option = --shareable
 },
 {.name = sourcetype,
  .type = VSH_OT_STRING,
-- 
1.8.2.1

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


[libvirt] [PATCH]doc: fix a typo in formatdomain

2013-10-24 Thread Chen Hanxiao
From: Chen Hanxiao chenhanx...@cn.fujitsu.com

s/no/not

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
 docs/formatdomain.html.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8ad755b..aa90701 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -3163,7 +3163,7 @@
   parameters in its codelt;parametersgt;/code element -
   an codeinterfaceid/code which is a standard uuid used to
   uniquely identify this particular interface to Open vSwitch (if
-  you do no specify one, a random interfaceid will be generated
+  you do not specify one, a random interfaceid will be generated
   for you when you first define the interface), and an
   optional codeprofileid/code which is sent to Open vSwitch as
   the interfaces port-profile.
-- 
1.8.2.1

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