Re: [libvirt] Help out

2014-01-20 Thread Michal Privoznik
On 18.01.2014 18:37, Giorgio Zoppi wrote:
 Hi all,
 how could I help out? Is there a bug list or a todo list? Are u able to
 pin a virtualization sandbox to a given processor?

Libvirt uses the redhat's bugzilla to track upstream issues:

https://bugzilla.redhat.com/buglist.cgi?bug_status=NEWbug_status=ASSIGNEDcomponent=libvirtlist_id=2117565product=Virtualization%20Toolsquery_format=advanced

There's a plenty of unassigned issues (assigned to libvirt-maint). But
working on an assigned bug is acceptable too :)

And regarding the vCPU pinning - see vcpupin command in virsh or the
virDomainPinVcpuFlags() API.

Michal

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


[libvirt] [PATCH v3] vbox: add support for v4.2.20+ and v4.3.4+

2014-01-20 Thread Manuel VIVES
Hi,

While working on adding virDomain*Stats support to the vbox driver, we
found bugs in the VirtualBox API C bindings. These bugs have been fixed
in versions 4.2.20 and 4.3.4.
However, the changes in the C bindings are incompatible with the 
vbox_CAPI_v4_2.h
and vbox_CAPI_v4_3.h files which are bundled in libvirt source code. This is 
why the
following patch adds vbox_CAPI_v4_2_20.h and vbox_CAPI_v4_3_4.h.

As stated by Matthias Bolte, the actual underlying problem here is that
libvirt assumes that VirtualBox API can only change between release versions
(4.2 - 4.3), but we have a case here where it changed (or got fixed) between
minor versions (4.2.18 - 4.2.20).

This patch makes the VBOX_API_VERSION represent the full API
version number (i.e 4002 = 4002000) so there are specific version
numbers for Vbox 4.2.20 (4002020) and 4.3.4 (4003004)

As the patch is too big for the mailing list, it is publicly available
at http://git-lab.diateam.net/cots/libvirt.git/ with the branch name
'vbox-4.2.20-4.3.4-support-v3'

Regards,
Manuel VIVES

v3: 
- Changed the commit message for being more precise.
- Resend after freeze.

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


Re: [libvirt] [libvirt-sandbox PATCH v3] Add filter support.

2014-01-20 Thread Christophe Fergeau
On Fri, Jan 17, 2014 at 04:29:37PM -0800, Ian Main wrote:
 On Thu, Jan 09, 2014 at 12:19:52PM +0100, Christophe Fergeau wrote:
  Hey,
  
  Wouldn't something like the patch below help to remove the code duplication
  in libvirt-sandbox-config-builder-{container,machine}.c ?
  
  Christophe
 
 Yes, definitely.  My thinking was that the whole builder section should
 be gone over as there is still lots of duplicate code in there even with
 this patch.

I haven't looked very carefully for duplication, the code related to network 
interface was
at least different enough not to look duplicated. Even if there is
preexisting duplication, it's better to try to avoid adding more ;)


Christophe


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

Re: [libvirt] [PATCH 2/2] qemu: Don't fail if the SCSI host device is shareable between domains

2014-01-20 Thread Osier Yang

On 17/01/14 21:44, John Ferlan wrote:


On 01/17/2014 02:06 AM, Osier Yang wrote:

...snip...

As a conclusion, I think the only concern from you is about the problem
on the running domain of an old libvirt (without these 2 patches). Right?
If so, my thought is to add document somewhere, though I have not
much idea about where to put the document, and how to write the
document to explain the problem which is such complicated.


Just trying to think and reason through the possibilities to help make
sure we're on the same page and reduce the chance for possible future
corner case issues...

With regard to the error message - just a way to indicate that the
failure was due to the device not being set shareable should be fine.
Whether that's this domain hasn't set it shareable or another domain
hasn't set it shareable is a nice addition. Just saying already in use
doesn't give enough of a hint that perhaps there is a way or for what
reason we failed.  Of course reading the code it's easy, but if you're a
customer without code...

Finally - I think a note in the Device section of formatdomain.html to
indicate when support was really added. Sure the tag was added in 1.0.6,
but it's not really functional until 1.2.2.  Not sure how best to say
that other than perhaps changing the since value... In the same area it
should be noted that all domains using/defining the device need to have
the shareable tag; otherwise, depending on order of domain startup one
or more domains will fail to start.



Agreed. formatdomain.html is a good place to do that. I will post
a v3 series including the document together.

Osier

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


[libvirt] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Thierry Parmentelat
Hello there

I am trying to locate the namespaces in place for a given lxc container 
(specifically /proc/pid/ns/*)

And to this end I was wondering what is the recommended way to probe for an lxc 
container's init pid
(mostly I'm after the mnt and pid namespaces, and probably network ones, but 
the actual list probably should not matter) 

I've found about virsh domid but this gives me the pid for libvirt_lxc, which 
turns out to have unmodified namespaces (at least as far as the mnt ns)
OTOH this process has exactly one child which is the container's init, which 
seems to have the right set of namespaces 

My angle right now is to look in /proc/domid_pid/task/children for a - 
hopefully single - pid and that seems to work for now, but I am concerned this 
code may be fragile so I would rather use a more robust approach; or maybe this 
is robust ? 

Any insight would be most welcome -- Thanks in advance

---
PS.
I am using a stock fedora20 box with 
[root@vnode11 ~]# rpm -q libvirt
libvirt-1.1.3.2-1.fc20.x86_64



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


[libvirt] [PATCHv2 0/6] Add BlkIO and CPU/mem stat API implementations for lxc

2014-01-20 Thread Thorsten Behrens
This patch set adds block io, memory and domain cpu statistics API
slot implementations to the LXC driver, in order to get linux
container monitoring and accounting a bit closer to qemu standards.

The last patch is a tad quirky (happy to hear suggestions on
alternative ways), in that it widens the permissible value set
at the .domainBlockStats slot: for lxc guests, it is relatively
likely to have zero disk devices, since host filesystems can be
used via passthrough bind mounts. Therefore, passing the zero-length
string as device path, is interpreted as 'return summary stats for
the entire domains's block io'.

Thorsten Behrens (6):
  Add util virCgroupGetBlkioIo*Serviced methods.
  Implement domainMemoryStats API slot for LXC driver.
  Make qemuGetDomainTotalCPUStats a virCgroup function.
  Implement domainGetCPUStats for lxc driver.
  Implemet lxcDomainBlockStats for lxc driver
  Widening API change - accept empty path for virDomainBlockStats

 src/libvirt.c|   8 +-
 src/libvirt_private.syms |   3 +
 src/lxc/lxc_driver.c | 239 +++
 src/qemu/qemu_driver.c   |  54 +---
 src/util/vircgroup.c | 291 +++
 src/util/vircgroup.h |  17 +++
 tools/virsh-domain-monitor.c |  11 +-
 tools/virsh.pod  |   5 +-
 8 files changed, 569 insertions(+), 59 deletions(-)

-- 
1.8.4

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


Re: [libvirt] [PATCH 1/6] Add util virCgroupGetBlkioIo*Serviced methods.

2014-01-20 Thread Thorsten Behrens
Gao feng wrote:
  +virCgroupGetBlkioIoServiced(virCgroupPtr group,
  +long long *bytes_read,
  +long long *bytes_write,
  +long long *requests_read,
  +long long *requests_write)
  +{
  +long long stats_val;
  +char *str1=NULL, *str2=NULL, *p1, *p2;
 please add blank.
 char *str1 = NULL, *str2 = NULL, *p1, *p2;

Will do in the v2 patchset going out in a minute. Since this is done
quite inconsistently over the code base, adjusted bracket-spacing.pl
accordingly  fixed the fallout. Will mail separate patchset today.

Cheers,

-- Thorsten


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

[libvirt] [PATCHv2 5/6] Implemet lxcDomainBlockStats for lxc driver

2014-01-20 Thread Thorsten Behrens
---

Notes on v2:
 - works as-is, will send lxcDomainBlockStatsFlags patch separately

 src/lxc/lxc_driver.c | 51 +++
 1 file changed, 51 insertions(+)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 19426f5..bf6fd5c 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2023,6 +2023,56 @@ lxcDomainGetSchedulerParameters(virDomainPtr domain,
 
 
 static int
+lxcDomainBlockStats(virDomainPtr dom,
+const char *path,
+struct _virDomainBlockStats *stats)
+{
+int ret = -1, idx;
+virDomainObjPtr vm;
+virDomainDiskDefPtr disk = NULL;
+virLXCDomainObjPrivatePtr priv;
+
+if (!(vm = lxcDomObjFromDomain(dom)))
+return ret;
+
+priv = vm-privateData;
+
+if (virDomainBlockStatsEnsureACL(dom-conn, vm-def)  0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   %s, _(domain is not running));
+goto cleanup;
+}
+
+if ((idx = virDomainDiskIndexByName(vm-def, path, false))  0) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(invalid path: %s), path);
+goto cleanup;
+}
+disk = vm-def-disks[idx];
+
+if (!disk-info.alias) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(missing disk device alias name for %s), disk-dst);
+goto cleanup;
+}
+
+ret = virCgroupGetBlkioIoDeviceServiced(priv-cgroup,
+disk-info.alias,
+stats-rd_bytes,
+stats-wr_bytes,
+stats-rd_req,
+stats-wr_req);
+cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
+
+static int
 lxcDomainSetBlkioParameters(virDomainPtr dom,
 virTypedParameterPtr params,
 int nparams,
@@ -4958,6 +5008,7 @@ static virDriver lxcDriver = {
 .domainGetSchedulerParametersFlags = lxcDomainGetSchedulerParametersFlags, 
/* 0.9.2 */
 .domainSetSchedulerParameters = lxcDomainSetSchedulerParameters, /* 0.5.0 
*/
 .domainSetSchedulerParametersFlags = lxcDomainSetSchedulerParametersFlags, 
/* 0.9.2 */
+.domainBlockStats = lxcDomainBlockStats, /* 0.4.1 */
 .domainInterfaceStats = lxcDomainInterfaceStats, /* 0.7.3 */
 .domainMemoryStats = lxcDomainMemoryStats, /* 1.2.2 */
 .nodeGetCPUStats = lxcNodeGetCPUStats, /* 0.9.3 */
-- 
1.8.4

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


[libvirt] [PATCHv2 2/6] Implement domainMemoryStats API slot for LXC driver.

2014-01-20 Thread Thorsten Behrens
---

Notes on v2:
 - check if domain is running, fixed ret val calculation
 - api slot comment is now referencing 1.2.2

 src/lxc/lxc_driver.c | 50 ++
 1 file changed, 50 insertions(+)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 5ae4b65..8cf8e48 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -4556,6 +4556,55 @@ lxcNodeGetInfo(virConnectPtr conn,
 
 
 static int
+lxcDomainMemoryStats(virDomainPtr dom,
+ struct _virDomainMemoryStat *stats,
+ unsigned int nr_stats,
+ unsigned int flags)
+{
+virDomainObjPtr vm;
+int ret = -1;
+virLXCDomainObjPrivatePtr priv;
+
+virCheckFlags(0, -1);
+
+if (!(vm = lxcDomObjFromDomain(dom)))
+goto cleanup;
+
+priv = vm-privateData;
+
+if (virDomainMemoryStatsEnsureACL(dom-conn, vm-def)  0)
+goto cleanup;
+
+ret = 0;
+if (!virDomainObjIsActive(vm))
+goto cleanup;
+
+if (ret  nr_stats) {
+stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON;
+stats[ret].val = vm-def-mem.cur_balloon;
+ret++;
+}
+if (ret  nr_stats) {
+stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_SWAP_IN;
+virCgroupGetMemSwapUsage(priv-cgroup, stats[ret].val);
+ret++;
+}
+if (ret  nr_stats) {
+unsigned long kb;
+stats[ret].tag = VIR_DOMAIN_MEMORY_STAT_RSS;
+virCgroupGetMemoryUsage(priv-cgroup, kb);
+stats[ret].val = kb;
+ret++;
+}
+
+cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
+
+static int
 lxcNodeGetCPUStats(virConnectPtr conn,
int cpuNum,
virNodeCPUStatsPtr params,
@@ -4783,6 +4832,7 @@ static virDriver lxcDriver = {
 .domainSetSchedulerParameters = lxcDomainSetSchedulerParameters, /* 0.5.0 
*/
 .domainSetSchedulerParametersFlags = lxcDomainSetSchedulerParametersFlags, 
/* 0.9.2 */
 .domainInterfaceStats = lxcDomainInterfaceStats, /* 0.7.3 */
+.domainMemoryStats = lxcDomainMemoryStats, /* 1.2.2 */
 .nodeGetCPUStats = lxcNodeGetCPUStats, /* 0.9.3 */
 .nodeGetMemoryStats = lxcNodeGetMemoryStats, /* 0.9.3 */
 .nodeGetCellsFreeMemory = lxcNodeGetCellsFreeMemory, /* 0.6.5 */
-- 
1.8.4

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


[libvirt] [PATCHv2 3/6] Make qemuGetDomainTotalCPUStats a virCgroup function.

2014-01-20 Thread Thorsten Behrens
To reuse this from other drivers, like lxc.
---

Notes on v2:
 - renamed to proper camel case: virCgroupGetDomainTotalCpuStats

 src/libvirt_private.syms |  1 +
 src/qemu/qemu_driver.c   | 54 ++--
 src/util/vircgroup.c | 53 +++
 src/util/vircgroup.h |  5 +
 4 files changed, 61 insertions(+), 52 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e4815b3..97198d1 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1013,6 +1013,7 @@ virCgroupGetCpuCfsQuota;
 virCgroupGetCpusetCpus;
 virCgroupGetCpusetMems;
 virCgroupGetCpuShares;
+virCgroupGetDomainTotalCpuStats;
 virCgroupGetFreezerState;
 virCgroupGetMemoryHardLimit;
 virCgroupGetMemorySoftLimit;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ebb77dc..a1e45c3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -105,7 +105,6 @@
 
 #define QEMU_NB_NUMA_PARAM 2
 
-#define QEMU_NB_TOTAL_CPU_STAT_PARAM 3
 #define QEMU_NB_PER_CPU_STAT_PARAM 2
 
 #define QEMU_SCHED_MIN_PERIOD  1000LL
@@ -15304,56 +15303,6 @@ cleanup:
 return ret;
 }
 
-/* qemuDomainGetCPUStats() with start_cpu == -1 */
-static int
-qemuDomainGetTotalcpuStats(virDomainObjPtr vm,
-   virTypedParameterPtr params,
-   int nparams)
-{
-unsigned long long cpu_time;
-int ret;
-qemuDomainObjPrivatePtr priv = vm-privateData;
-
-if (nparams == 0) /* return supported number of params */
-return QEMU_NB_TOTAL_CPU_STAT_PARAM;
-/* entry 0 is cputime */
-ret = virCgroupGetCpuacctUsage(priv-cgroup, cpu_time);
-if (ret  0) {
-virReportSystemError(-ret, %s, _(unable to get cpu account));
-return -1;
-}
-
-if (virTypedParameterAssign(params[0], VIR_DOMAIN_CPU_STATS_CPUTIME,
-VIR_TYPED_PARAM_ULLONG, cpu_time)  0)
-return -1;
-
-if (nparams  1) {
-unsigned long long user;
-unsigned long long sys;
-
-ret = virCgroupGetCpuacctStat(priv-cgroup, user, sys);
-if (ret  0) {
-virReportSystemError(-ret, %s, _(unable to get cpu account));
-return -1;
-}
-
-if (virTypedParameterAssign(params[1],
-VIR_DOMAIN_CPU_STATS_USERTIME,
-VIR_TYPED_PARAM_ULLONG, user)  0)
-return -1;
-if (nparams  2 
-virTypedParameterAssign(params[2],
-VIR_DOMAIN_CPU_STATS_SYSTEMTIME,
-VIR_TYPED_PARAM_ULLONG, sys)  0)
-return -1;
-
-if (nparams  QEMU_NB_TOTAL_CPU_STAT_PARAM)
-nparams = QEMU_NB_TOTAL_CPU_STAT_PARAM;
-}
-
-return nparams;
-}
-
 /* This function gets the sums of cpu time consumed by all vcpus.
  * For example, if there are 4 physical cpus, and 2 vcpus in a domain,
  * then for each vcpu, the cpuacct.usage_percpu looks like this:
@@ -15552,7 +15501,8 @@ qemuDomainGetCPUStats(virDomainPtr domain,
 }
 
 if (start_cpu == -1)
-ret = qemuDomainGetTotalcpuStats(vm, params, nparams);
+ret = virCgroupGetDomainTotalCpuStats(priv-cgroup,
+  params, nparams);
 else
 ret = qemuDomainGetPercpuStats(vm, params, nparams,
start_cpu, ncpus);
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 83fcefc..66045fb 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -51,11 +51,14 @@
 #include virhashcode.h
 #include virstring.h
 #include virsystemd.h
+#include virtypedparam.h
 
 #define CGROUP_MAX_VAL 512
 
 #define VIR_FROM_THIS VIR_FROM_CGROUP
 
+#define CGROUP_NB_TOTAL_CPU_STAT_PARAM 3
+
 #if defined(__linux__)  defined(HAVE_GETMNTENT_R)  \
 defined(_DIRENT_HAVE_D_TYPE)  defined(_SC_CLK_TCK)
 # define VIR_CGROUP_SUPPORTED
@@ -2629,6 +2632,56 @@ virCgroupDenyDevicePath(virCgroupPtr group, const char 
*path, int perms)
 }
 
 
+
+int
+virCgroupGetDomainTotalCpuStats(virCgroupPtr group,
+virTypedParameterPtr params,
+int nparams)
+{
+unsigned long long cpu_time;
+int ret;
+
+if (nparams == 0) /* return supported number of params */
+return CGROUP_NB_TOTAL_CPU_STAT_PARAM;
+/* entry 0 is cputime */
+ret = virCgroupGetCpuacctUsage(group, cpu_time);
+if (ret  0) {
+virReportSystemError(-ret, %s, _(unable to get cpu account));
+return -1;
+}
+
+if (virTypedParameterAssign(params[0], VIR_DOMAIN_CPU_STATS_CPUTIME,
+VIR_TYPED_PARAM_ULLONG, cpu_time)  0)
+return -1;
+
+if (nparams  1) {
+unsigned long long user;
+unsigned long long sys;
+
+ret = virCgroupGetCpuacctStat(group, user, sys);
+if (ret  0) {

[libvirt] [PATCHv2 1/6] Add util virCgroupGetBlkioIo*Serviced methods.

2014-01-20 Thread Thorsten Behrens
This reads blkio stats from blkio.throttle.io_service_bytes and
blkio.throttle.io_serviced.
---

Notes v2:
 - loop over all devices in io_service_bytes / io_serviced files
 - report value_names in error message
 - adds overflow checks to summation
 - moved loop invariants out for virCgroupGetBlkioIoDeviceServiced
 - fixed func signatures for non-cgroup dummy impls

 src/libvirt_private.syms |   2 +
 src/util/vircgroup.c | 238 +++
 src/util/vircgroup.h |  12 +++
 3 files changed, 252 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 91d1304..e4815b3 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1002,6 +1002,8 @@ virCgroupDenyDevice;
 virCgroupDenyDeviceMajor;
 virCgroupDenyDevicePath;
 virCgroupFree;
+virCgroupGetBlkioIoDeviceServiced;
+virCgroupGetBlkioIoServiced;
 virCgroupGetBlkioWeight;
 virCgroupGetCpuacctPercpuUsage;
 virCgroupGetCpuacctStat;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 43eb649..83fcefc 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1826,6 +1826,217 @@ virCgroupGetBlkioWeight(virCgroupPtr group, unsigned 
int *weight)
 
 
 /**
+ * virCgroupGetBlkioIoServiced:
+ *
+ * @group: The cgroup to get throughput for
+ * @kb: Pointer to returned serviced io in kilobytes
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+virCgroupGetBlkioIoServiced(virCgroupPtr group,
+long long *bytes_read,
+long long *bytes_write,
+long long *requests_read,
+long long *requests_write)
+{
+long long stats_val;
+char *str1 = NULL, *str2 = NULL, *p1, *p2;
+size_t i;
+int ret = -1;
+
+const char *value_names[] = {
+Read ,
+Write 
+};
+long long *bytes_ptrs[] = {
+bytes_read,
+bytes_write
+};
+long long *requests_ptrs[] = {
+requests_read,
+requests_write
+};
+
+*bytes_read = 0;
+*bytes_write = 0;
+*requests_read = 0;
+*requests_write = 0;
+
+if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ blkio.throttle.io_service_bytes, str1)  0)
+goto cleanup;
+
+if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ blkio.throttle.io_serviced, str2)  0)
+goto cleanup;
+
+/* sum up all entries of the same kind, from all devices */
+for (i = 0; i  ARRAY_CARDINALITY(value_names); i++) {
+p1 = str1;
+p2 = str2;
+
+while ((p1 = strstr(p1, value_names[i]))) {
+p1 += strlen(value_names[i]);
+if (virStrToLong_ll(p1, p1, 10, stats_val)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Cannot parse byte %sstat '%s'),
+   value_names[i],
+   p1);
+goto cleanup;
+}
+
+if (stats_val  0 ||
+(stats_val  0  *bytes_ptrs[i]  (LLONG_MAX - stats_val)))
+{
+virReportError(VIR_ERR_OVERFLOW,
+   _(Sum of byte %sstat overflows),
+   value_names[i]);
+goto cleanup;
+}
+*bytes_ptrs[i] += stats_val;
+}
+
+while ((p2 = strstr(p2, value_names[i]))) {
+p2 += strlen(value_names[i]);
+if (virStrToLong_ll(p2, p2, 10, stats_val)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Cannot parse %srequest stat '%s'),
+   value_names[i],
+   p2);
+goto cleanup;
+}
+
+if (stats_val  0 ||
+(stats_val  0  *requests_ptrs[i]  (LLONG_MAX - stats_val)))
+{
+virReportError(VIR_ERR_OVERFLOW,
+   _(Sum of %srequest stat overflows),
+   value_names[i]);
+goto cleanup;
+}
+*requests_ptrs[i] += stats_val;
+}
+}
+
+ret = 0;
+
+cleanup:
+VIR_FREE(str2);
+VIR_FREE(str1);
+return ret;
+}
+
+
+/**
+ * virCgroupGetBlkioIoDeviceServiced:
+ *
+ * @group: The cgroup to get throughput for
+ * @path: The device to get throughput for
+ * @kb_read: Pointer to serviced read io in kilobytes
+ * @kb_write: Pointer to serviced write io in kilobytes
+ * @kb_total: Pointer to serviced io in kilobytes
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+virCgroupGetBlkioIoDeviceServiced(virCgroupPtr group,
+  const char *path,
+  long long *bytes_read,
+  long long *bytes_write,
+   

[libvirt] [PATCHv2 4/6] Implement domainGetCPUStats for lxc driver.

2014-01-20 Thread Thorsten Behrens
---

Notes on v2:
 - elided extra memset and leftover loop var n
 - api slot comment references 1.2.2 now

 src/lxc/lxc_driver.c | 128 +++
 1 file changed, 128 insertions(+)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 8cf8e48..19426f5 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -75,6 +75,8 @@
 
 
 #define LXC_NB_MEM_PARAM  3
+#define LXC_NB_PER_CPU_STAT_PARAM 1
+
 
 static int lxcStateInitialize(bool privileged,
   virStateInhibitCallback callback,
@@ -4775,6 +4777,131 @@ cleanup:
 }
 
 
+static int
+lxcDomainGetPercpuStats(virDomainObjPtr vm,
+virTypedParameterPtr params,
+unsigned int nparams,
+int start_cpu,
+unsigned int ncpus)
+{
+int rv = -1;
+size_t i;
+int id, max_id;
+char *pos;
+char *buf = NULL;
+virLXCDomainObjPrivatePtr priv = vm-privateData;
+virTypedParameterPtr ent;
+int param_idx;
+unsigned long long cpu_time;
+
+/* TODO: share api contract code with other drivers here */
+
+/* return the number of supported params */
+if (nparams == 0  ncpus != 0)
+return LXC_NB_PER_CPU_STAT_PARAM;
+
+/* To parse account file, we need to know how many cpus are present.  */
+max_id = nodeGetCPUCount();
+if (max_id  0)
+return rv;
+
+if (ncpus == 0) { /* returns max cpu ID */
+rv = max_id;
+goto cleanup;
+}
+
+if (start_cpu  max_id) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(start_cpu %d larger than maximum of %d),
+   start_cpu, max_id);
+goto cleanup;
+}
+
+/* we get percpu cputime accounting info. */
+if (virCgroupGetCpuacctPercpuUsage(priv-cgroup, buf))
+goto cleanup;
+pos = buf;
+
+/* return percpu cputime in index 0 */
+param_idx = 0;
+
+/* number of cpus to compute */
+if (start_cpu = max_id - ncpus)
+id = max_id - 1;
+else
+id = start_cpu + ncpus - 1;
+
+for (i = 0; i = id; i++) {
+if (virStrToLong_ull(pos, pos, 10, cpu_time)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(cpuacct parse error));
+goto cleanup;
+}
+if (i  start_cpu)
+continue;
+ent = params[(i - start_cpu) * nparams + param_idx];
+if (virTypedParameterAssign(ent, VIR_DOMAIN_CPU_STATS_CPUTIME,
+VIR_TYPED_PARAM_ULLONG, cpu_time)  0)
+goto cleanup;
+}
+
+rv = nparams;
+
+cleanup:
+VIR_FREE(buf);
+return rv;
+}
+
+
+static int
+lxcDomainGetCPUStats(virDomainPtr dom,
+ virTypedParameterPtr params,
+ unsigned int nparams,
+ int start_cpu,
+ unsigned int ncpus,
+ unsigned int flags)
+{
+virDomainObjPtr vm = NULL;
+int ret = -1;
+bool isActive;
+virLXCDomainObjPrivatePtr priv;
+
+virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
+
+if (!(vm = lxcDomObjFromDomain(dom)))
+return ret;
+
+priv = vm-privateData;
+
+if (virDomainGetCPUStatsEnsureACL(dom-conn, vm-def)  0)
+goto cleanup;
+
+isActive = virDomainObjIsActive(vm);
+if (!isActive) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(domain is not running));
+goto cleanup;
+}
+
+if (!virCgroupHasController(priv-cgroup, VIR_CGROUP_CONTROLLER_CPUACCT)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   %s, _(cgroup CPUACCT controller is not mounted));
+goto cleanup;
+}
+
+if (start_cpu == -1)
+ret = virCgroupGetDomainTotalCpuStats(priv-cgroup,
+  params, nparams);
+else
+ret = lxcDomainGetPercpuStats(vm, params, nparams,
+  start_cpu, ncpus);
+cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
+
 /* Function Tables */
 static virDriver lxcDriver = {
 .no = VIR_DRV_LXC,
@@ -4852,6 +4979,7 @@ static virDriver lxcDriver = {
 .nodeSuspendForDuration = lxcNodeSuspendForDuration, /* 0.9.8 */
 .domainSetMetadata = lxcDomainSetMetadata, /* 1.1.3 */
 .domainGetMetadata = lxcDomainGetMetadata, /* 1.1.3 */
+.domainGetCPUStats = lxcDomainGetCPUStats, /* 1.2.2 */
 .nodeGetMemoryParameters = lxcNodeGetMemoryParameters, /* 0.10.2 */
 .nodeSetMemoryParameters = lxcNodeSetMemoryParameters, /* 0.10.2 */
 .domainSendProcessSignal = lxcDomainSendProcessSignal, /* 1.0.1 */
-- 
1.8.4

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


[libvirt] [PATCHv2 6/6] Widening API change - accept empty path for virDomainBlockStats

2014-01-20 Thread Thorsten Behrens
And provide domain summary stat in that case, for lxc backend.
Use case is a container inheriting all devices from the host,
e.g. when doing application containerization.
---

Notes on v2:
 - adapted virDomainBlockStats docs
 - adapted virsh domblkstat docs
 - made virsh actually accept empty disk argument
 - pedaling back a bit on the API change - accepting a NULL ptr
   for the disk arg would need changing the remote protocol, so
   better just take the empty string. Makes this less invasive even.

 src/libvirt.c|  8 ++--
 src/lxc/lxc_driver.c | 10 ++
 tools/virsh-domain-monitor.c | 11 ---
 tools/virsh.pod  |  5 +++--
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 87a4d46..ead0813 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -7781,7 +7781,9 @@ error:
  * an unambiguous source name of the block device (the source
  * file='...'/ sub-element, such as /path/to/image).  Valid names
  * can be found by calling virDomainGetXMLDesc() and inspecting
- * elements within //domain/devices/disk.
+ * elements within //domain/devices/disk. Some drivers might also
+ * accept the empty string for the @disk parameter, and then yield
+ * summary stats for the entire domain.
  *
  * Domains may have more than one block device.  To get stats for
  * each you should make multiple calls to this function.
@@ -7847,7 +7849,9 @@ error:
  * an unambiguous source name of the block device (the source
  * file='...'/ sub-element, such as /path/to/image).  Valid names
  * can be found by calling virDomainGetXMLDesc() and inspecting
- * elements within //domain/devices/disk.
+ * elements within //domain/devices/disk. Some drivers might also
+ * accept the empty string for the @disk parameter, and then yield
+ * summary stats for the entire domain.
  *
  * Domains may have more than one block device.  To get stats for
  * each you should make multiple calls to this function.
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index bf6fd5c..31f1625 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2046,6 +2046,16 @@ lxcDomainBlockStats(virDomainPtr dom,
 goto cleanup;
 }
 
+if (!*path) {
+/* empty path - return entire domain blkstats instead */
+ret = virCgroupGetBlkioIoServiced(priv-cgroup,
+  stats-rd_bytes,
+  stats-wr_bytes,
+  stats-rd_req,
+  stats-wr_req);
+goto cleanup;
+}
+
 if ((idx = virDomainDiskIndexByName(vm-def, path, false))  0) {
 virReportError(VIR_ERR_INVALID_ARG,
_(invalid path: %s), path);
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index b29b82a..6be253f 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -880,7 +880,7 @@ static const vshCmdOptDef opts_domblkstat[] = {
 },
 {.name = device,
  .type = VSH_OT_DATA,
- .flags = VSH_OFLAG_REQ,
+ .flags = VSH_OFLAG_EMPTY_OK,
  .help = N_(block device)
 },
 {.name = human,
@@ -946,8 +946,13 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
 if (!(dom = vshCommandOptDomain(ctl, cmd, name)))
 return false;
 
-if (vshCommandOptStringReq(ctl, cmd, device, device)  0)
-goto cleanup;
+/* device argument is optional now. if it's missing, supply empty
+   string to denote 'all devices'. A NULL device arg would violate
+   API contract.
+ */
+rc = vshCommandOptStringReq(ctl, cmd, device, device); /* and ignore rc 
*/
+if (!device)
+device = ;
 
 rc = virDomainBlockStatsFlags(dom, device, NULL, nparams, 0);
 
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 3534b54..c3ca016 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -616,12 +616,13 @@ If I--graceful is specified, don't resort to extreme 
measures
 (e.g. SIGKILL) when the guest doesn't stop after a reasonable timeout;
 return an error instead.
 
-=item Bdomblkstat Idomain Iblock-device [I--human]
+=item Bdomblkstat Idomain [Iblock-device] [I--human]
 
 Get device block stats for a running domain.  A Iblock-device corresponds
 to a unique target name (target dev='name'/) or source file (source
 file='name'/) for one of the disk devices attached to Idomain (see
-also Bdomblklist for listing these names).
+also Bdomblklist for listing these names). On a lxc domain, omitting the
+Iblock-device yields device block stats summarily for the entire domain.
 
 Use I--human for a more human readable output.
 
-- 
1.8.4

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


[libvirt] [PATCH 1/2] Make syntax check notice assignments w/o surrounding spaces.

2014-01-20 Thread Thorsten Behrens
---
 build-aux/bracket-spacing.pl | 8 
 1 file changed, 8 insertions(+)

diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl
index 802a640..fd7438e 100755
--- a/build-aux/bracket-spacing.pl
+++ b/build-aux/bracket-spacing.pl
@@ -144,6 +144,14 @@ foreach my $file (@ARGV) {
 $ret = 1;
 last;
 }
+
+# Require spaces around assignment '=' and compounds
+while ($data =~ /[^!|\-+*\/%\^'= ]=[^=]/ ||
+   $data =~ /[^!|\-+*\/%\^'=]=[^= \\\n]/) {
+print $file:$.: $line;
+$ret = 1;
+last;
+}
 }
 close FILE;
 }
-- 
1.8.4

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


[libvirt] [PATCH 2/2] maint: align whitespace with project conventions.

2014-01-20 Thread Thorsten Behrens
---
 examples/object-events/event-test.c | 20 +--
 src/conf/nwfilter_conf.c| 72 ++---
 src/esx/esx_vi.c|  2 +-
 src/libvirt.c   |  2 +-
 src/nwfilter/nwfilter_learnipaddr.c |  2 +-
 src/openvz/openvz_conf.c|  2 +-
 src/openvz/openvz_driver.c  |  2 +-
 src/phyp/phyp_driver.c  |  2 +-
 src/util/virlog.c   |  4 +--
 src/util/virsysinfo.c   |  2 +-
 src/xen/xen_driver.c|  4 +--
 src/xen/xs_internal.c   | 10 +++---
 src/xenapi/xenapi_driver.c  | 22 ++--
 tests/commandtest.c |  4 +--
 tests/qemumonitorjsontest.c |  2 +-
 tools/virsh-domain.c|  6 ++--
 tools/virsh-host.c  |  2 +-
 tools/virt-login-shell.c|  2 +-
 18 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/examples/object-events/event-test.c 
b/examples/object-events/event-test.c
index 228a091..2a5a83b 100644
--- a/examples/object-events/event-test.c
+++ b/examples/object-events/event-test.c
@@ -70,22 +70,22 @@ const char *eventToString(int event) {
 const char *ret = ;
 switch ((virDomainEventType) event) {
 case VIR_DOMAIN_EVENT_DEFINED:
-ret =Defined;
+ret = Defined;
 break;
 case VIR_DOMAIN_EVENT_UNDEFINED:
-ret =Undefined;
+ret = Undefined;
 break;
 case VIR_DOMAIN_EVENT_STARTED:
-ret =Started;
+ret = Started;
 break;
 case VIR_DOMAIN_EVENT_SUSPENDED:
-ret =Suspended;
+ret = Suspended;
 break;
 case VIR_DOMAIN_EVENT_RESUMED:
-ret =Resumed;
+ret = Resumed;
 break;
 case VIR_DOMAIN_EVENT_STOPPED:
-ret =Stopped;
+ret = Stopped;
 break;
 case VIR_DOMAIN_EVENT_SHUTDOWN:
 ret = Shutdown;
@@ -229,16 +229,16 @@ networkEventToString(int event)
 const char *ret = ;
 switch ((virNetworkEventLifecycleType) event) {
 case VIR_NETWORK_EVENT_DEFINED:
-ret =Defined;
+ret = Defined;
 break;
 case VIR_NETWORK_EVENT_UNDEFINED:
-ret =Undefined;
+ret = Undefined;
 break;
 case VIR_NETWORK_EVENT_STARTED:
-ret =Started;
+ret = Started;
 break;
 case VIR_NETWORK_EVENT_STOPPED:
-ret =Stopped;
+ret = Stopped;
 break;
 }
 return ret;
diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 30ec094..6db8ea9 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -161,30 +161,30 @@ virNWFilterUnlockFilterUpdates(void) {
 /*
  * attribute names for the rules XML
  */
-static const char srcmacaddr_str[]   = srcmacaddr;
-static const char srcmacmask_str[]   = srcmacmask;
-static const char dstmacaddr_str[]   = dstmacaddr;
-static const char dstmacmask_str[]   = dstmacmask;
-static const char arpsrcmacaddr_str[]= arpsrcmacaddr;
-static const char arpdstmacaddr_str[]= arpdstmacaddr;
-static const char arpsrcipaddr_str[] = arpsrcipaddr;
-static const char arpdstipaddr_str[] = arpdstipaddr;
-static const char srcipaddr_str[]= srcipaddr;
-static const char srcipmask_str[]= srcipmask;
-static const char dstipaddr_str[]= dstipaddr;
-static const char dstipmask_str[]= dstipmask;
-static const char srcipfrom_str[]= srcipfrom;
-static const char srcipto_str[]  = srcipto;
-static const char dstipfrom_str[]= dstipfrom;
-static const char dstipto_str[]  = dstipto;
-static const char srcportstart_str[] = srcportstart;
-static const char srcportend_str[]   = srcportend;
-static const char dstportstart_str[] = dstportstart;
-static const char dstportend_str[]   = dstportend;
-static const char dscp_str[] = dscp;
-static const char state_str[]= state;
-static const char ipset_str[]= ipset;
-static const char ipsetflags_str[]   = ipsetflags;
+static const char srcmacaddr_str[]= srcmacaddr;
+static const char srcmacmask_str[]= srcmacmask;
+static const char dstmacaddr_str[]= dstmacaddr;
+static const char dstmacmask_str[]= dstmacmask;
+static const char arpsrcmacaddr_str[] = arpsrcmacaddr;
+static const char arpdstmacaddr_str[] = arpdstmacaddr;
+static const char arpsrcipaddr_str[]  = arpsrcipaddr;
+static const char arpdstipaddr_str[]  = arpdstipaddr;
+static const char srcipaddr_str[] = srcipaddr;
+static const char srcipmask_str[] = srcipmask;
+static const char dstipaddr_str[] = dstipaddr;
+static const char dstipmask_str[] = dstipmask;
+static const char srcipfrom_str[] = srcipfrom;
+static const char srcipto_str[]   = srcipto;
+static const char dstipfrom_str[] = dstipfrom;
+static const char dstipto_str[]   = 

[libvirt] [PATCH 0/2] Improve whitespace syntax checks

2014-01-20 Thread Thorsten Behrens
Check for whitespace around assignments / compount assignment
operators. Fix syntax-check fallout in PATCH 2/2.

Thorsten Behrens (2):
  Make syntax check notice assignments w/o surrounding spaces.
  maint: align whitespace with project conventions.

 build-aux/bracket-spacing.pl|  8 +
 examples/object-events/event-test.c | 20 +--
 src/conf/nwfilter_conf.c| 72 ++---
 src/esx/esx_vi.c|  2 +-
 src/libvirt.c   |  2 +-
 src/nwfilter/nwfilter_learnipaddr.c |  2 +-
 src/openvz/openvz_conf.c|  2 +-
 src/openvz/openvz_driver.c  |  2 +-
 src/phyp/phyp_driver.c  |  2 +-
 src/util/virlog.c   |  4 +--
 src/util/virsysinfo.c   |  2 +-
 src/xen/xen_driver.c|  4 +--
 src/xen/xs_internal.c   | 10 +++---
 src/xenapi/xenapi_driver.c  | 22 ++--
 tests/commandtest.c |  4 +--
 tests/qemumonitorjsontest.c |  2 +-
 tools/virsh-domain.c|  6 ++--
 tools/virsh-host.c  |  2 +-
 tools/virt-login-shell.c|  2 +-
 19 files changed, 89 insertions(+), 81 deletions(-)

-- 
1.8.4

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


Re: [libvirt] [PATCH V2 RESEND 8/8] lxc: allow to setup throttle blkio cgroup through virsh

2014-01-20 Thread Daniel P. Berrange
On Mon, Jan 20, 2014 at 11:25:56AM +0800, Gao feng wrote:
 On 12/20/2013 12:34 AM, Daniel P. Berrange wrote:
  On Fri, Dec 13, 2013 at 11:09:01AM +0800, Gao feng wrote:
  With this patch,user can set throttle blkio cgroup for
  lxc domain through virsh tool.
 
  Signed-off-by: Guan Qiang hzguanqi...@corp.netease.com
  Signed-off-by: Gao feng gaof...@cn.fujitsu.com
  ---
   src/lxc/lxc_driver.c | 671 
  +--
   1 file changed, 646 insertions(+), 25 deletions(-)
  
  
  ACK
  
  @@ -4623,6 +5243,7 @@ static virDriver lxcDriver = {
   .name = LXC_DRIVER_NAME,
   .connectOpen = lxcConnectOpen, /* 0.4.2 */
   .connectClose = lxcConnectClose, /* 0.4.2 */
  +.connectSupportsFeature = lxcConnectSupportsFeature, /* 1.1.4 */
  
  But change this to 1.2.1
  
 
 
 So this should be 1.2.2 now, right?

Yes, correct.

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] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Daniel P. Berrange
On Mon, Jan 20, 2014 at 11:38:08AM +0100, Thierry Parmentelat wrote:
 Hello there
 
 I am trying to locate the namespaces in place for a given lxc container 
 (specifically /proc/pid/ns/*)
 
 And to this end I was wondering what is the recommended way to probe for an 
 lxc container's init pid
 (mostly I'm after the mnt and pid namespaces, and probably network ones, but 
 the actual list probably should not matter) 
 
 I've found about virsh domid but this gives me the pid for libvirt_lxc, 
 which turns out to have unmodified namespaces (at least as far as the mnt ns)
 OTOH this process has exactly one child which is the container's init, which 
 seems to have the right set of namespaces 
 
 My angle right now is to look in /proc/domid_pid/task/children for a - 
 hopefully single - pid and
 that seems to work for now, but I am concerned this code may be fragile so I 
 would rather use a more
 robust approach; or maybe this is robust ? 

We don't really wish to expose the container PIDs to the host or namespace
details to client apps. Can you give more info about what you're trying to
achieve overall. I'd like to understand if there's some higher level API
we're missing that would more directly address your needs.


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] [PATCHv3] Add util virCgroupGetBlkioIo*Serviced methods.

2014-01-20 Thread Thorsten Behrens
This reads blkio stats from blkio.throttle.io_service_bytes and
blkio.throttle.io_serviced.
---

Note on v3:
 - rebased to current master, sadly the
   virCgroupSetBlkioDeviceReadBps etc conflicted

 src/libvirt_private.syms |   2 +
 src/util/vircgroup.c | 242 +++
 src/util/vircgroup.h |  12 +++
 3 files changed, 256 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3ede3d5..1e44ed8 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1002,6 +1002,8 @@ virCgroupDenyDevice;
 virCgroupDenyDeviceMajor;
 virCgroupDenyDevicePath;
 virCgroupFree;
+virCgroupGetBlkioIoDeviceServiced;
+virCgroupGetBlkioIoServiced;
 virCgroupGetBlkioWeight;
 virCgroupGetCpuacctPercpuUsage;
 virCgroupGetCpuacctStat;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index a6d60c5..2b70bcb 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1786,6 +1786,221 @@ virCgroupPathOfController(virCgroupPtr group,
 
 
 /**
+ * virCgroupGetBlkioIoServiced:
+ *
+ * @group: The cgroup to get throughput for
+ * @bytes_read: Pointer to returned bytes read
+ * @bytes_write: Pointer to returned bytes written
+ * @requests_read: Pointer to returned read io ops
+ * @requests_write: Pointer to returned write io ops
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+virCgroupGetBlkioIoServiced(virCgroupPtr group,
+long long *bytes_read,
+long long *bytes_write,
+long long *requests_read,
+long long *requests_write)
+{
+long long stats_val;
+char *str1 = NULL, *str2 = NULL, *p1, *p2;
+size_t i;
+int ret = -1;
+
+const char *value_names[] = {
+Read ,
+Write 
+};
+long long *bytes_ptrs[] = {
+bytes_read,
+bytes_write
+};
+long long *requests_ptrs[] = {
+requests_read,
+requests_write
+};
+
+*bytes_read = 0;
+*bytes_write = 0;
+*requests_read = 0;
+*requests_write = 0;
+
+if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ blkio.throttle.io_service_bytes, str1)  0)
+goto cleanup;
+
+if (virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_BLKIO,
+ blkio.throttle.io_serviced, str2)  0)
+goto cleanup;
+
+/* sum up all entries of the same kind, from all devices */
+for (i = 0; i  ARRAY_CARDINALITY(value_names); i++) {
+p1 = str1;
+p2 = str2;
+
+while ((p1 = strstr(p1, value_names[i]))) {
+p1 += strlen(value_names[i]);
+if (virStrToLong_ll(p1, p1, 10, stats_val)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Cannot parse byte %sstat '%s'),
+   value_names[i],
+   p1);
+goto cleanup;
+}
+
+if (stats_val  0 ||
+(stats_val  0  *bytes_ptrs[i]  (LLONG_MAX - stats_val)))
+{
+virReportError(VIR_ERR_OVERFLOW,
+   _(Sum of byte %sstat overflows),
+   value_names[i]);
+goto cleanup;
+}
+*bytes_ptrs[i] += stats_val;
+}
+
+while ((p2 = strstr(p2, value_names[i]))) {
+p2 += strlen(value_names[i]);
+if (virStrToLong_ll(p2, p2, 10, stats_val)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Cannot parse %srequest stat '%s'),
+   value_names[i],
+   p2);
+goto cleanup;
+}
+
+if (stats_val  0 ||
+(stats_val  0  *requests_ptrs[i]  (LLONG_MAX - stats_val)))
+{
+virReportError(VIR_ERR_OVERFLOW,
+   _(Sum of %srequest stat overflows),
+   value_names[i]);
+goto cleanup;
+}
+*requests_ptrs[i] += stats_val;
+}
+}
+
+ret = 0;
+
+cleanup:
+VIR_FREE(str2);
+VIR_FREE(str1);
+return ret;
+}
+
+
+/**
+ * virCgroupGetBlkioIoDeviceServiced:
+ *
+ * @group: The cgroup to get throughput for
+ * @path: The device to get throughput for
+ * @bytes_read: Pointer to returned bytes read
+ * @bytes_write: Pointer to returned bytes written
+ * @requests_read: Pointer to returned read io ops
+ * @requests_write: Pointer to returned write io ops
+ *
+ * Returns: 0 on success, -1 on error
+ */
+int
+virCgroupGetBlkioIoDeviceServiced(virCgroupPtr group,
+  const char *path,
+  long long *bytes_read,
+  long long *bytes_write,
+  

Re: [libvirt] Exposing and calculating CPU APIC IDs (was Re: [Qemu-devel] [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn())

2014-01-20 Thread Igor Mammedov
On Fri, 17 Jan 2014 17:13:55 -0200
Eduardo Habkost ehabk...@redhat.com wrote:

 On Wed, Jan 15, 2014 at 03:37:04PM +0100, Igor Mammedov wrote:
  On Wed, 15 Jan 2014 20:24:01 +0800
  Chen Fan chen.fan.f...@cn.fujitsu.com wrote:
   On Tue, 2014-01-14 at 11:40 +0100, Igor Mammedov wrote:
On Tue, 14 Jan 2014 17:27:20 +0800
Chen Fan chen.fan.f...@cn.fujitsu.com wrote:

 the intend of this patch is to register cpu vmstates with apic id 
 instead of cpu
 index, due to the property setting of apic_id is behind the cpu 
 initialization. so
 we move the registers of cpu vmstate from cpu_exec_init() to 
 x86_cpu_realizefn() to
 let the set apicid as the parameter.
 
 Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
 ---
  exec.c| 5 +
  target-i386/cpu.c | 9 +
  2 files changed, 14 insertions(+)
 
 diff --git a/exec.c b/exec.c
 index 7e49e8e..9be5855 100644
 --- a/exec.c
 +++ b/exec.c
 @@ -438,7 +438,9 @@ CPUState *qemu_get_cpu(int index)
  void cpu_exec_init(CPUArchState *env)
  {
  CPUState *cpu = ENV_GET_CPU(env);
 +#if !defined(TARGET_I386)
  CPUClass *cc = CPU_GET_CLASS(cpu);
 +#endif
  CPUState *some_cpu;
  int cpu_index;
  
 @@ -460,6 +462,8 @@ void cpu_exec_init(CPUArchState *env)
  #if defined(CONFIG_USER_ONLY)
  cpu_list_unlock();
  #endif
 +
 +#if !defined(TARGET_I386)
  if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
  vmstate_register(NULL, cpu_index, vmstate_cpu_common, cpu);
  }
 @@ -472,6 +476,7 @@ void cpu_exec_init(CPUArchState *env)
  if (cc-vmsd != NULL) {
  vmstate_register(NULL, cpu_index, cc-vmsd, cpu);
  }
 +#endif /* !TARGET_I386 */
  }
  
  #if defined(TARGET_HAS_ICE)
 diff --git a/target-i386/cpu.c b/target-i386/cpu.c
 index 967529a..dada6f6 100644
 --- a/target-i386/cpu.c
 +++ b/target-i386/cpu.c
 @@ -2552,6 +2552,7 @@ static void x86_cpu_apic_realize(X86CPU *cpu, 
 Error **errp)
  static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
  {
  CPUState *cs = CPU(dev);
 +CPUClass *cc = CPU_GET_CLASS(cs);
  X86CPU *cpu = X86_CPU(dev);
  X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
  CPUX86State *env = cpu-env;
 @@ -2615,6 +2616,14 @@ static void x86_cpu_realizefn(DeviceState 
 *dev, Error **errp)
  cpu_reset(cs);
  
  xcc-parent_realize(dev, local_err);
 +
 +if (qdev_get_vmsd(DEVICE(cs)) == NULL) {
 +vmstate_register(NULL, env-cpuid_apic_id, 
 vmstate_cpu_common, cs);
 +}
 +
 +if (cc-vmsd != NULL) {
 +vmstate_register(NULL, env-cpuid_apic_id, cc-vmsd, cs);
 +}
how about doing it in common CPUclass.realize()
you can use get_arch_id() for getting CPU id, it returns cpu_index by 
default
and apic_id for target-i386.
   
   Thanks for your kind suggestion, does this mean we can directly move
   vmstate_register to cpu_common_realizefn()? 
  yep, that is a gist of it.
  
  There is more to the issue with discontinuous CPUs, a lot of code still
  use cpu_index and the way it's allocated is not compatible with 
  discontinuous
  CPUs, so this issue should be fixed as well.
  
  Also you propose to use a raw apic id with CLI/user interface.
  I recall there were objections to it since APIC ID contains topology
  information and it's not trivial for user to get it right.
  The last idea that was discussed to fix it was not expose APIC ID to
  user but rather introduce QOM hierarchy like:
/machine/node/N/socket/X/core/Y/thread/Z
  and use it in user interface as a means to specify an arbitrary CPU
  and let QEMU calculate APIC ID based on this path.
  
  But nobody took on implementing it yet.
 
 We're taking so long to get a decent interface implemented, that part of
 me is considering exposing the APIC ID directly like suggested before,
 and requiring libvirt to calculate topology-aware APIC IDs[1] to
 properly implement CPU hotplug (and possibly for other tasks).
If you are speaking about 
'qemu will core dump with -smp 254, sockets=2, cores=3, threads=2'
http://patchwork.ozlabs.org/patch/301272/
bug then it's limitation of ACPI implementation,
I'm going to refactor it to use full APIC ids instead of using bitmap,
so that we won't ever run into issue regardless of cpu supported CPU count.

 
 Another part of me is hoping that the libvirt developers ask us to
 please not do that, so I can use it as argument against exposing the
 APIC IDs directly the next time we discuss this.  :)

why not try your  /machine/node/N/socket/X/core/Y/thread/Z idea first.
It will benefit not only cpu hotplug but also '-numa' and topology
description in general.


 [1] See target-i386/topology.h for references
 

--
libvir-list mailing list
libvir-list@redhat.com

[libvirt] 'host-passthrough' for arm64

2014-01-20 Thread Oleg Strikov
Hello guys,

I'm trying to come up with basic OpenStack support for arm64 node.
I'd like to use 'libvirt_cpu_mode=host-passthrough' configuration option
with Nova which issues cpu mode='host-passthrough' to libvirt xml config.
But with this option passed libvirt crashes with 'error: unsupported
configuration: CPU specification not supported by hypervisor'.
This happens because the following handlers are not implemented (or
implemented as stubs) inside src/cpu/cpu_aarch64.c:
* AArch64Decode()
* AArch64Update()
* AArch64guestData()

To solve exactly this 'host-passthrough'-related issue that's enough to
have the following set of handlers:

AArch64Decode(...)
{
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, -1);

/* I don't know any way to detect 'cortex-a57' or any other armv8 CPU
for now */
/* But I don't think that we can meet anything else than cortex-a57 */

/* We may also put 'host' there to specifically point out that
qemu-aarch64 supports only '-cpu host' for now */
/* pm215 told me that the ETA for '-cpu cortex-a57' and friends is
around 3 months from now */

return !(VIR_STRDUP(cpu-model, host or cortex-a57) == 1);
}

static int AArch64Update(...)
{
/* qemu-aarch64 supports only '-cpu host' for now */

guest-match = VIR_CPU_MATCH_EXACT;
virCPUDefFreeModel(guest);
return virCPUDefCopyModel(guest, host, true);
}

static virCPUCompareResult
AArch64guestData(..)
{
return  VIR_CPU_COMPARE_IDENTICAL;
}

That's clear that these handlers provide just basic functionality
('host-passthrough'-only) and have to be extended in future.
But is it something we can commit for now?

Another way to deal with this issue is to adopt some code from PPC handlers
(including CPU model detection and best fit qemu configuration discovery).
But this way will be blocked until:
(1) I find any way to reliably detect CPU model on ARMv8 board (any ideas?)
(2) pm215 implements TCG for arm64

What is the best way to choose to come up with the commitable code?

Many thanks for your help!
Oleg
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH 0/9] Fix corner cases in nodedev detach and reattach

2014-01-20 Thread Jiri Denemark
On Fri, Jan 17, 2014 at 11:39:16 +0100, Jiri Denemark wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=1046919
 
 The first two patches fix bugs in PCI device handling code, the third
 patch provides a nice error message when nodedev detach is not supported
 and the rest are tests for testing the bugs fixed in the first two
 patches.
 
 Jincheng Miao (1):
   qemu: Don't detach devices if passthrough doesn't work
 
 Jiri Denemark (8):
   pci: Make reattach work for unbound devices
   pci: Fix failure paths in detach
   virpcitest: Show PCI device tested by each test
   pci: Publish some internal code for virpcitest
   virpcimock: Mock /sys/bus/pci/drivers_probe
   virpcitest: More tests for device detach and reattach
   virpcimock: Add PCI driver which always fails
   virpcitest: Test virPCIDeviceDetach failure

I fixed the nits found by Michal and pushed this series. Thanks for the
review.

Jirka

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


Re: [libvirt] [PATCH 1/2] Make syntax check notice assignments w/o surrounding spaces.

2014-01-20 Thread Martin Kletzander
On Mon, Jan 20, 2014 at 12:27:28PM +0100, Thorsten Behrens wrote:
 ---
  build-aux/bracket-spacing.pl | 8 
  1 file changed, 8 insertions(+)

 diff --git a/build-aux/bracket-spacing.pl b/build-aux/bracket-spacing.pl
 index 802a640..fd7438e 100755
 --- a/build-aux/bracket-spacing.pl
 +++ b/build-aux/bracket-spacing.pl
 @@ -144,6 +144,14 @@ foreach my $file (@ARGV) {
  $ret = 1;
  last;
  }
 +
 +# Require spaces around assignment '=' and compounds
 +while ($data =~ /[^!|\-+*\/%\^'= ]=[^=]/ ||
 +   $data =~ /[^!|\-+*\/%\^'=]=[^= \\\n]/) {
 +print $file:$.: $line;
 +$ret = 1;
 +last;
 +}
  }
  close FILE;
  }
 --
 1.8.4


This is great, although the syntax-check should be changed in the
second patch so that git bisect is not broken in one commit.  It'd be
also nice to make this check for '==' not having spaves around itself,
but I'm not sure we have that requirement specified anywhere, so it's
ok for now, I guess.

ACK if that goes as a second patch and git bisect is not broken.

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 2/2] maint: align whitespace with project conventions.

2014-01-20 Thread Martin Kletzander
On Mon, Jan 20, 2014 at 12:27:29PM +0100, Thorsten Behrens wrote:
 ---
  examples/object-events/event-test.c | 20 +--
  src/conf/nwfilter_conf.c| 72 
 ++---
  src/esx/esx_vi.c|  2 +-
  src/libvirt.c   |  2 +-
  src/nwfilter/nwfilter_learnipaddr.c |  2 +-
  src/openvz/openvz_conf.c|  2 +-
  src/openvz/openvz_driver.c  |  2 +-
  src/phyp/phyp_driver.c  |  2 +-
  src/util/virlog.c   |  4 +--
  src/util/virsysinfo.c   |  2 +-
  src/xen/xen_driver.c|  4 +--
  src/xen/xs_internal.c   | 10 +++---
  src/xenapi/xenapi_driver.c  | 22 ++--
  tests/commandtest.c |  4 +--
  tests/qemumonitorjsontest.c |  2 +-
  tools/virsh-domain.c|  6 ++--
  tools/virsh-host.c  |  2 +-
  tools/virt-login-shell.c|  2 +-
  18 files changed, 81 insertions(+), 81 deletions(-)

[...]
 diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
 index 91b16f8..b14e1d7 100644
 --- a/src/openvz/openvz_conf.c
 +++ b/src/openvz/openvz_conf.c
 @@ -937,7 +937,7 @@ static char *
  openvzLocateConfDir(void)
  {
  const char *conf_dir_list[] = {/etc/vz/conf, /usr/local/etc/conf, 
 NULL};
 -int i=0;
 +int i = 0;

Thanks to this fix, there is another problem making this fail due to
'i' not being size_t.

Also s/whitespace/shitespaces/ in $SUBJ.

Other than that the patch looks fine, but as I mentioned in the first
patch, in order not to break future bisecting, these patches should be
applied in reverse order (first fix those problems and then make the
syntax-check check them).

I fixed mentioned things and pushed.  Thank you and congratulations to your
first patches in libvirt!

Have a nice day,
Martin


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

[libvirt] Propose patch?

2014-01-20 Thread Joel Simoes

Hi, all.

I'm Joel

I wan't propose patch to correct bug to refresh volume on sheepdog from 
a sheep pool.
Bug I'm not understanding how to configure correctly my .git/config to 
send patch.


Warning, I'm not C developper, this patch requiered correction for char 
analyse and copy. It's work but ...


My patch (add auto volumes (vdi) and refresh when adding a pool sheepdog)

Thanks.


diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c
index a6981ce..5bcad03 100644
--- a/src/storage/storage_backend_sheepdog.c
+++ b/src/storage/storage_backend_sheepdog.c
@@ -34,6 +34,7 @@
 #include viralloc.h
 #include virlog.h
 #include virstring.h
+#include assert.h
 
 #define VIR_FROM_THIS VIR_FROM_STORAGE
 
@@ -44,6 +45,56 @@ static int virStorageBackendSheepdogRefreshVol(virConnectPtr conn,
 void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
  virStoragePoolObjPtr pool);
 
+char** str_split(char* a_str, const char a_delim);
+
+char** str_split(char* a_str, const char a_delim) {
+char** result = 0;
+size_t count = 0;
+
+
+char* tmp = a_str;
+
+
+char* last_comma = 0;
+char delim[2];
+delim[0] = a_delim;
+delim[1] = 0;
+
+/* Count how many elements will be extracted. */
+while (*tmp) {
+if (a_delim == *tmp) {
+count++;
+last_comma = tmp;
+}
+tmp++;
+}
+
+/* Add space for trailing token. */
+count += last_comma  (a_str + strlen(a_str) - 1);
+
+/* Add space for terminating null string so caller
+   knows where the list of returned strings ends. */
+count++;
+
+result = malloc(sizeof (char*) * count);
+
+
+if (result) {
+size_t idx = 0;
+char* token = strtok(a_str, delim);
+
+while (token) {
+assert(idx  count);
+*(result + idx++) = strdup(token);
+token = strtok(0, delim);
+}
+assert(idx == count - 1);
+*(result + idx) = 0;
+}
+
+return result;
+}
+
 int
 virStorageBackendSheepdogParseNodeInfo(virStoragePoolDefPtr pool,
char *output)
@@ -111,6 +162,69 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
 
 
 static int
+virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
+virStoragePoolObjPtr pool) {
+int ret;
+char *output = NULL;
+
+virCommandPtr cmd = virCommandNewArgList(COLLIE, vdi, list, -r, NULL);
+virStorageBackendSheepdogAddHostArg(cmd, pool);
+virCommandSetOutputBuffer(cmd, output);
+ret = virCommandRun(cmd, NULL);
+char** lines;
+lines = (char**) str_split(output, '\n');
+int i;
+for (i = 0; *(lines + i); i++) {
+char *line = *(lines + i);
+char** cells;
+cells = (char**) str_split(line, ' ');
+int j;
+for (j = 0; *(cells + j); j++) {
+
+char *cell = *(cells + j);
+if (j == 1) {
+virStorageVolDefPtr vol = NULL;
+if (VIR_ALLOC(vol)  0)
+goto cleanup;
+
+if (VIR_STRDUP(vol-name, cell)  0)
+goto cleanup;
+
+vol-type = VIR_STORAGE_VOL_BLOCK;
+
+
+if (VIR_REALLOC_N(pool-volumes.objs,
+pool-volumes.count + 1)  0)
+goto cleanup;
+pool-volumes.objs[pool-volumes.count++] = vol;
+
+if (virStorageBackendSheepdogRefreshVol(conn, pool, vol)  0)
+goto cleanup;
+
+vol = NULL;
+}
+
+free(*(cells + j));
+}
+
+free(cells);
+free(*(lines + i));
+}
+
+
+free(lines);
+
+if (ret  0)
+goto cleanup;
+
+
+cleanup:
+virCommandFree(cmd);
+return ret;
+}
+
+
+static int
 virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
  virStoragePoolObjPtr pool)
 {
@@ -122,9 +236,10 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
 virStorageBackendSheepdogAddHostArg(cmd, pool);
 virCommandSetOutputBuffer(cmd, output);
 ret = virCommandRun(cmd, NULL);
-if (ret == 0)
+if (ret == 0){
 ret = virStorageBackendSheepdogParseNodeInfo(pool-def, output);
-
+virStorageBackendSheepdogRefreshAllVol(conn, pool);
+}
 virCommandFree(cmd);
 VIR_FREE(output);
 return ret;
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH RESEND v4 1/2] Introduce Libvirt Wireshark dissector

2014-01-20 Thread Yuto KAWAMURA
2014/1/16 Michal Privoznik mpriv...@redhat.com:
 On 15.01.2014 18:06, Yuto KAWAMURA(kawamuray) wrote:
 From: Yuto KAWAMURA(kawamuray) kawamuray.dad...@gmail.com

 Introduce Wireshark dissector plugin which adds support to Wireshark
 for dissecting libvirt RPC protocol.
 Added following files to build Wireshark dissector from libvirt source
 tree.
 * tools/wireshark/*: Source tree of Wireshark dissector plugin.

 Added followings to configure.ac or Makefile.am.
 configure.ac
 * --with-wireshark-dissector: Enable support for building Wireshark
   dissector.
 * --with-ws-plugindir: Specify wireshark plugin directory that dissector
   will installed.
 * Added tools/wireshark/{Makefile,src/Makefile} to  AC_CONFIG_FILES.
 Makefile.am
 * Added tools/wireshark/ to SUBDIR.
 ---
  .gitignore  |2 +
  Makefile.am |3 +-
  cfg.mk  |8 +-
  configure.ac|   72 ++-
  tools/wireshark/Makefile.am |   22 +
  tools/wireshark/README.md   |   31 +
  tools/wireshark/src/Makefile.am |   42 ++
  tools/wireshark/src/packet-libvirt.c|  512 
  tools/wireshark/src/packet-libvirt.h|  128 
  tools/wireshark/util/genxdrstub.pl  | 1011 
 +++
  tools/wireshark/util/make-dissector-reg |  198 ++
  11 files changed, 2023 insertions(+), 6 deletions(-)
  create mode 100644 tools/wireshark/Makefile.am
  create mode 100644 tools/wireshark/README.md
  create mode 100644 tools/wireshark/src/Makefile.am
  create mode 100644 tools/wireshark/src/packet-libvirt.c
  create mode 100644 tools/wireshark/src/packet-libvirt.h
  create mode 100755 tools/wireshark/util/genxdrstub.pl
  create mode 100755 tools/wireshark/util/make-dissector-reg


 diff --git a/tools/wireshark/src/packet-libvirt.c 
 b/tools/wireshark/src/packet-libvirt.c
 new file mode 100644
 index 000..2d0350c
 --- /dev/null
 +++ b/tools/wireshark/src/packet-libvirt.c

 +static void
 +dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 +{
 +goffset offset;
 +guint32 prog, proc, type, serial, status;
 +const value_string *vs;
 +
 +col_set_str(pinfo-cinfo, COL_PROTOCOL, Libvirt);
 +col_clear(pinfo-cinfo, COL_INFO);
 +
 +offset = 4; /* End of length field */
 +prog   = tvb_get_ntohl(tvb, offset); offset += 4;
 +offset += 4; /* Ignore version header field */
 +proc   = tvb_get_ntohl(tvb, offset); offset += 4;
 +type   = tvb_get_ntohl(tvb, offset); offset += 4;
 +serial = tvb_get_ntohl(tvb, offset); offset += 4;
 +status = tvb_get_ntohl(tvb, offset); offset += 4;
 +
 +col_add_fstr(pinfo-cinfo, COL_INFO, Prog=%s,
 + val_to_str(prog, program_strings, %x));
 +
 +vs = get_program_data(prog, VIR_PROGRAM_PROCSTRINGS);
 +if (vs == NULL) {
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Proc=%u, proc);
 +} else {
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Proc=%s, 
 val_to_str(proc, vs, %d));
 +}
 +
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Type=%s Serial=%u Status=%s,
 +val_to_str(type, type_strings, %d), serial,
 +val_to_str(status, status_strings, %d));
 +
 +if (tree) {
 +gint hf_proc;
 +proto_item *ti;
 +proto_tree *libvirt_tree;
 +
 +ti = proto_tree_add_item(tree, proto_libvirt, tvb, 0, 
 tvb_length(tvb), ENC_NA);
 +libvirt_tree = proto_item_add_subtree(ti, ett_libvirt);
 +
 +offset = 0;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_length,  tvb, offset, 
 4, ENC_NA); offset += 4;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_program, tvb, offset, 
 4, ENC_NA); offset += 4;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_version, tvb, offset, 
 4, ENC_NA); offset += 4;
 +
 +hf_proc = *(int *)get_program_data(prog, VIR_PROGRAM_PROCHFVAR);

 There's a possible NULL dereference here. get_program might return NULL in 
 case @prog is not one of REMOTE, QEMU, LXC, KEEPALIVE. This can possibly 
 happen and it did for me indeed:

 Program terminated with signal 11, Segmentation fault.
 #0  0x7fac1cc60a86 in dissect_libvirt_message (tvb=0x387acc0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:396
 396 hf_proc = *(int *)get_program_data(prog, 
 VIR_PROGRAM_PROCHFVAR);
 (gdb) bt
 #0  0x7fac1cc60a86 in dissect_libvirt_message (tvb=0x387acc0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:396
 #1  0x0034469198fe in tcp_dissect_pdus () from 
 /usr/lib64/libwireshark.so.3
 #2  0x7fac1cc60c0c in dissect_libvirt (tvb=0x3879aa0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:424
 #3  0x0034462dff54 in ?? () from /usr/lib64/libwireshark.so.3
 #4  0x0034462e0608 in ?? () from /usr/lib64/libwireshark.so.3
 #5  0x0034462e0e0c in ?? () from /usr/lib64/libwireshark.so.3
 #6  

Re: [libvirt] Propose patch?

2014-01-20 Thread Daniel P. Berrange
On Mon, Jan 20, 2014 at 02:54:43PM +0100, Joel Simoes wrote:
 Hi, all.
 
 I'm Joel
 
 I wan't propose patch to correct bug to refresh volume on sheepdog
 from a sheep pool.
 Bug I'm not understanding how to configure correctly my .git/config
 to send patch.

You don't neccessarily need to change you git config file - you
can just invoke 'git send-email' with any args. As an example if
I just want to send the most recent commit that is in git I can
use '-1' as a shortcut. eg

  $ git send-email --annotate --to libvir-list@redhat.com 
--smtp-server=hostname of SMTP serveR --no-chain-reply-to -1

If I have created a whole series of patches, on a separate branch
then I can alternatively use

  $ git send-email --annotate --to libvir-list@redhat.com 
--smtp-server=hostname of SMTP serveR --no-chain-reply-to master..

which says send email for every patch that isn't present on the master
branch.

Good tip is to replace 'libvir-list@redhat.com' with your own email
address, so you can practice sending emails without accidentally
spamming the main list. Once you're comfortable with how it works
then send to the main list.

 Warning, I'm not C developper, this patch requiered correction for
 char analyse and copy. It's work but ...
 
 My patch (add auto volumes (vdi) and refresh when adding a pool sheepdog)

Thanks for taking the effort to write a patch !

 diff --git a/src/storage/storage_backend_sheepdog.c 
 b/src/storage/storage_backend_sheepdog.c
 index a6981ce..5bcad03 100644
 --- a/src/storage/storage_backend_sheepdog.c
 +++ b/src/storage/storage_backend_sheepdog.c
 @@ -34,6 +34,7 @@
  #include viralloc.h
  #include virlog.h
  #include virstring.h
 +#include assert.h

We've got a policy that our code avoids any use of 'assert' and
must return errors to the user instead of aborting.

  #define VIR_FROM_THIS VIR_FROM_STORAGE
  
 @@ -44,6 +45,56 @@ static int 
 virStorageBackendSheepdogRefreshVol(virConnectPtr conn,
  void virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
   virStoragePoolObjPtr pool);
  
 +char** str_split(char* a_str, const char a_delim);
 +
 +char** str_split(char* a_str, const char a_delim) {

If you #include virstring.h you can access to virStringSplit
method, so you can avoid writing this str_split code.


 @@ -111,6 +162,69 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd,
  
  
  static int
 +virStorageBackendSheepdogRefreshAllVol(virConnectPtr conn ATTRIBUTE_UNUSED,
 +virStoragePoolObjPtr pool) {
 +int ret;
 +char *output = NULL;
 +
 +virCommandPtr cmd = virCommandNewArgList(COLLIE, vdi, list, -r, 
 NULL);
 +virStorageBackendSheepdogAddHostArg(cmd, pool);
 +virCommandSetOutputBuffer(cmd, output);
 +ret = virCommandRun(cmd, NULL);

You need todo

   if (ret  0)
  goto cleanup;

otherwise you'll end up trying to 'str_split(NULL, '\n')' when
an error occurs.

 +char** lines;
 +lines = (char**) str_split(output, '\n');
 +int i;

Our style rules require 'size_t i' - if you run 'make check' and
'make syntax-check' it will warn you about important style rules
we follow. the HACKING file describes some of the them in more
detail

 +for (i = 0; *(lines + i); i++) {
 +char *line = *(lines + i);
 +char** cells;
 +cells = (char**) str_split(line, ' ');
 +int j;

Also 'size_t j' for this one'

 +for (j = 0; *(cells + j); j++) {
 +
 +char *cell = *(cells + j);
 +if (j == 1) {
 +virStorageVolDefPtr vol = NULL;
 +if (VIR_ALLOC(vol)  0)
 +goto cleanup;
 +
 +if (VIR_STRDUP(vol-name, cell)  0)
 +goto cleanup;
 +
 +vol-type = VIR_STORAGE_VOL_BLOCK;
 +
 +
 +if (VIR_REALLOC_N(pool-volumes.objs,
 +pool-volumes.count + 1)  0)
 +goto cleanup;

We've got a slight preference towards 'VIR_EXPAND_N' instead
of VIR_REALLOC_N with size + 1.

 +pool-volumes.objs[pool-volumes.count++] = vol;
 +
 +if (virStorageBackendSheepdogRefreshVol(conn, pool, vol)  0)
 +goto cleanup;
 +
 +vol = NULL;
 +}
 +
 +free(*(cells + j));
 +}
 +
 +free(cells);
 +free(*(lines + i));
 +}
 +
 +
 +free(lines);

You need to call  VIR_FREE instead of free() for our style rules.

 +
 +if (ret  0)
 +goto cleanup;

Ah, this needs to be much higher up before the loop

 +
 +
 +cleanup:
 +virCommandFree(cmd);
 +return ret;
 +}
 +
 +
 +static int
  virStorageBackendSheepdogRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED,
   virStoragePoolObjPtr pool)
  {
 @@ -122,9 +236,10 @@ virStorageBackendSheepdogRefreshPool(virConnectPtr conn 
 ATTRIBUTE_UNUSED,
  virStorageBackendSheepdogAddHostArg(cmd, pool);
  

Re: [libvirt] [RFC PATCH 2/3] storage: Fix hardcoded qemu connection

2014-01-20 Thread Peter Krempa
On 12/21/13 05:14, Adam Walters wrote:
 This utilizes the config driver I submitted to resolve the hardcoded qemu 
 connection string. With this, the storage driver no longer has a circular 
 dependency with QEMU. Without this patch, when libvirtd is restarted, QEMU 
 requires storage (when domains are using storage pool backings) and storage 
 requires QEMU. This causes issues during startup.

Please break the summary into multiple lines. The usual set point is 72
columns so that git log fits into the 80 column legacy terminal setting.

 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  src/storage/storage_driver.c | 12 ++--
  1 file changed, 6 insertions(+), 6 deletions(-)
 
 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
 index a614279..1077a66 100644
 --- a/src/storage/storage_driver.c
 +++ b/src/storage/storage_driver.c
 @@ -70,12 +70,12 @@ storageDriverAutostart(virStorageDriverStatePtr driver) {
  size_t i;
  virConnectPtr conn = NULL;
  
 -/* XXX Remove hardcoding of QEMU URI */
 -if (driverState-privileged)
 -conn = virConnectOpen(qemu:///system);
 -else
 -conn = virConnectOpen(qemu:///session);
 -/* Ignoring NULL conn - let backends decide */
 +conn = virConnectOpen(config:///);
 +/* Ignoring NULL conn - let backends decide.  *
 + * As long as the config driver is built, and *
 + * it should be, since it is default on and   *
 + * not configurable, a NULL conn should never *
 + * happen.

Missing closing of the comment. (fails pretty badly at compile time)

  
  for (i = 0; i  driver-pools.count; i++) {
  virStoragePoolObjPtr pool = driver-pools.objs[i];
 

Otherwise looks good.

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 2/2] qemu: Change the default unix monitor timeout

2014-01-20 Thread Pavel Fux
at least in my case changing the value to 30 seconds is not enough, we
had to change it to 5 minutes

I suggest you let the user change it as he wishes.



On Thu, Jan 16, 2014 at 6:21 PM, Martin Kletzander mklet...@redhat.comwrote:

 On Thu, Jan 16, 2014 at 04:11:07PM +, Daniel P. Berrange wrote:
  On Thu, Jan 09, 2014 at 09:22:06AM +0100, Martin Kletzander wrote:
   There is a number of reported issues when we fail starting a domain.
   Turns out that, in some scenarios like high load, 3 second timeout is
   not enough for qemu to start up to the phase where the socket is
   created.  Since the timeout is configurable and there is no downside
   of waiting longer, raise the timeout right to 30 seconds.
  
   Signed-off-by: Martin Kletzander mklet...@redhat.com
   ---
src/qemu/qemu.conf  | 2 +-
src/qemu/qemu_monitor.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
  
   diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
   index 6217b49..4936d88 100644
   --- a/src/qemu/qemu.conf
   +++ b/src/qemu/qemu.conf
   @@ -472,6 +472,6 @@
# such file or directory that could be because libvirt did not wait
# enough time, you can try increasing this timeout.
#
   -# Default is 3
   +# Default is 30
#
#monitor_socket_open_timeout = 60
   diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
   index f34527a..6a437b1 100644
   --- a/src/qemu/qemu_monitor.c
   +++ b/src/qemu/qemu_monitor.c
   @@ -273,7 +273,7 @@ qemuMonitorOpenUnix(const char *monitor, pid_t
 cpid, virQEMUDriverPtr driver)
virQEMUDriverConfigPtr cfg = NULL;
struct sockaddr_un addr;
int monfd;
   -int timeout = 3; /* In seconds */
   +int timeout = 30; /* In seconds */
int ret;
size_t i = 0;
 
  ACK.
 
  It is safe to wait longer, since in the loop we kill() to check if
  QEMU is still running or not.
 

 Pushed, thanks.

 Martin

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

Re: [libvirt] [PATCH 2/2] qemu: Change the default unix monitor timeout

2014-01-20 Thread Daniel P. Berrange
On Mon, Jan 20, 2014 at 04:33:09PM +0200, Pavel Fux wrote:
 at least in my case changing the value to 30 seconds is not enough, we
 had to change it to 5 minutes

What is the scenario in which you're seeing this problem ? Is it a problem
when you are running lots of machines at once on a host ? Waiting 5 minutes
for a QEMU process to start is really a ridiculous amount of time - I'd
really question whether the VMs can even do any useful work at all if the
system is being that slow

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] [RFC PATCH 1/3] driver: Implement new state driver field

2014-01-20 Thread Peter Krempa
On 12/21/13 05:14, Adam Walters wrote:
 This implements a new field in the virStateDriver struct. In order to prevent 
 possible compilation issues, this patch also implements te new field in all 
 of the existing drivers. Other than in driver.h, the changes are all a single 
 line addition to the files.

Please break this long line as advised in 2/3.

 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  src/config/config_driver.c  | 1 +
  src/driver.h| 6 ++
  src/interface/interface_backend_netcf.c | 1 +
  src/libxl/libxl_driver.c| 1 +
  src/lxc/lxc_driver.c| 1 +
  src/network/bridge_driver.c | 1 +
  src/node_device/node_device_hal.c   | 1 +
  src/node_device/node_device_udev.c  | 1 +
  src/nwfilter/nwfilter_driver.c  | 1 +
  src/qemu/qemu_driver.c  | 1 +
  src/remote/remote_driver.c  | 1 +
  src/secret/secret_driver.c  | 1 +
  src/storage/storage_driver.c| 1 +
  src/uml/uml_driver.c| 1 +
  src/xen/xen_driver.c| 1 +
  15 files changed, 20 insertions(+)
 
 diff --git a/src/config/config_driver.c b/src/config/config_driver.c
 index a057300..a817c7a 100644
 --- a/src/config/config_driver.c
 +++ b/src/config/config_driver.c
 @@ -228,6 +228,7 @@ static virStateDriver configStateDriver = {
  .stateInitialize = configStateInitialize,
  .stateCleanup = configStateCleanup,
  .stateReload = configStateReload,
 +.stateType = VIR_DRV_STATE_DRV_LIBVIRT,
  };
  
  int configRegister(void) {
 diff --git a/src/driver.h b/src/driver.h
 index b6927ea..6863910 100644
 --- a/src/driver.h
 +++ b/src/driver.h
 @@ -1833,6 +1833,11 @@ typedef int
  typedef int
  (*virDrvStateStop)(void);
  
 +typedef enum {
 +VIR_DRV_STATE_DRV_LIBVIRT = 1,
 +VIR_DRV_STATE_DRV_HYPERVISOR = 2,
 +} virDrvStateDrvType;
 +
  typedef struct _virStateDriver virStateDriver;
  typedef virStateDriver *virStateDriverPtr;
  
 @@ -1843,6 +1848,7 @@ struct _virStateDriver {
  virDrvStateCleanup stateCleanup;
  virDrvStateReload stateReload;
  virDrvStateStop stateStop;
 +virDrvStateDrvType stateType;
  };
  # endif

These additions require patching some of the check scripts too. 
Please apply the following patch, otherwise this won't pass make check:

  GEN  check-drivername
Driver struct field stateType should be named stateDrvType
  GEN  check-driverimpls
./libxl/libxl_driver.c:26463 Bad prefix 'VIR_DRV_STATE_DRV_HYPERVISOR' for API 
'stateType', expecting 'libxl'
./libxl/libxl_driver.c:26463 Bad impl name 'VIR_DRV_STATE_DRV_HYPERVISOR' for 
API 'stateType', expecting 'libxlStateType'
./lxc/lxc_driver.c:37541 Bad prefix 'VIR_DRV_STATE_DRV_HYPERVISOR' for API 
'stateType', expecting 'lxc'
./lxc/lxc_driver.c:37541 Bad impl name 'VIR_DRV_STATE_DRV_HYPERVISOR' for API 
'stateType', expecting 'lxcStateType'


diff --git a/src/check-driverimpls.pl b/src/check-driverimpls.pl
index f726403..2266323 100755
--- a/src/check-driverimpls.pl
+++ b/src/check-driverimpls.pl
@@ -37,7 +37,7 @@ while () {

 next if $api eq no;
 next if $api eq name;
+next if $api eq stateType;

 my $suffix = $impl;
 my $prefix = $impl;
diff --git a/src/check-drivername.pl b/src/check-drivername.pl
index 5c8de0a..d481128 100755
--- a/src/check-drivername.pl
+++ b/src/check-drivername.pl
@@ -66,6 +66,8 @@ while (DRVFILE) {
 my $drv = $1;
 my $field = $2;

+next if $field =~ /stateType/;
+
 my $tmp = $drv;
 $tmp =~ s/virDrv//;
 $tmp =~ s/^NWFilter/nwfilter/;

Or possibly don't apply the last hunk and re-name the field to
stateDrvType which sounds a little bit better (not required).

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] How to configure MacVtap passthrough mode to SR-IOV VF?

2014-01-20 Thread Thomas-Mich Richter
On 01/19/2014 12:08 PM, opendaylight wrote:
 Hi guys.
 These days I'm doing research on SR-IOV  Live migration. As we 
 all know there is big problem that SR-IOV  Live migration can not exist at 
 the same time. 
 I heard that KVM + SRIOV + MacVtap can solve this problem. So I 
 want to try.
 My environment:
 Host: Dell R610, OS: RHEL 6.4 ( kernel 2.6.32)
 NIC: intel 82599
 I follow a document from intel guy, it said that I should write 
 xml like below:
 
 network
  namemacvtap_passthrough’/name
  forward mode=’passthrough
   interface dev=’vf0’ /
   interface dev=’vf1’ /
   .. ..
 /forward

About a year ago I played around with an Intel 82599 SR-IOV card using RHEL 6.5 
latest version. 
It worked fine for me. My setup is as follows:

Eth2 is the PF, which has 2 VF. I load the ixgbe device driver with max_vfs=2 
parameter.
Eth4 and Eth5 are the 2 VF on top of my PF.

[root@c7b5 lldpad]# ip l sh dev eth2
2: eth2: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:1b:21:63:bf:80 brd ff:ff:ff:ff:ff:ff
vf 0 MAC 3e:97:40:4d:fb:82
vf 1 MAC 52:54:00:98:14:08
[root@c7b5 lldpad]# ip a sh dev eth5
8: eth5: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc mq state UP qlen 1000
link/ether 52:54:00:98:14:08 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.5/24 scope global eth5
inet6 fe80::1c12:b6ff:fe1c:d213/64 scope link tentative dadfailed 
   valid_lft forever preferred_lft forever
[root@c7b5 lldpad]# 

The PF has no ip address, but my VF eth5 has. So I can ping this address from 
other boxes.

Next I start a VM with this network attachment, extract from my VM xml file.
interface type='direct'
  mac address='52:54:00:98:14:08'/
  source dev='eth5' mode='passthrough'/
  target dev='macvtap0'/
  model type='virtio'/
  alias name='net0'/
  address type='pci' domain='0x' bus='0x00' slot='0x03' 
function='0x0'/  
/interface

[root@c7b5 lldpad]# ip a sh dev macvtap0
21: macvtap0@eth5: BROADCAST,MULTICAST,UP,LOWER_UP mtu 1500 qdisc mq state 
UNKNOWN qlen 500
link/ether 52:54:00:98:14:08 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5054:ff:fe98:1408/64 scope link 
   valid_lft forever preferred_lft forever
[root@c7b5 lldpad]#

My VM has the ip address 192.168.0.205 (static assigned) and I can ping it from 
a another box:
...
64 bytes from 192.168.0.205: icmp_seq=125 ttl=64 time=0.462 ms
64 bytes from 192.168.0.205: icmp_seq=126 ttl=64 time=0.472 ms
64 bytes from 192.168.0.205: icmp_seq=127 ttl=64 time=0.477 ms

This setup worked for me. I can not say more about other setups...
Hope this helps


-- 
Thomas Richter, Dept 3250, IBM LTC Boeblingen, Data Center Networking
--
Vorsitzende des Aufsichtsrats: Martina Koederitz 
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 
243294

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


Re: [libvirt] [RFC PATCH 3/3] libvirt: Implement two-tier driver loading

2014-01-20 Thread Peter Krempa
On 12/21/13 05:14, Adam Walters wrote:
 This implements a two-tier driver loading system into libvirt. The two 
 classes of drivers are Libvirt drivers and Hypervisor drivers. Hypervisor 
 drivers are fairly self-explanatory, they provide domain services. Libvirt 
 drivers are sort of the backend drivers for those, like the secret and 
 storage drivers. In the two-tier loading system here, the Libvirt drivers 
 are all loaded and auto-started. Once those have finished, the Hypervisor 
 drivers are loaded and auto-started. By doing things in this manner, we do 
 not have to hard-code a driver loading order or roll our own dynamic 
 dependency-based loading algorithm, while still gaining the benefits of a 
 more orderly driver loading approach, which should help minimize the 
 possibility of a race condition during startup. If another race condition is 
 found, the code can be extended to provide any number of extra tiers without 
 much trouble.

Again, as in 2/3, please break the long line into some paragraphs.

 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  src/libvirt.c | 57 +
  1 file changed, 49 insertions(+), 8 deletions(-)
 
 diff --git a/src/libvirt.c b/src/libvirt.c
 index 77f481e..9c00491 100644
 --- a/src/libvirt.c
 +++ b/src/libvirt.c
 @@ -837,31 +837,72 @@ int virStateInitialize(bool privileged,
 void *opaque)
  {
  size_t i;
 +virStateDriverPtr virLibvirtStateDriverTab[MAX_DRIVERS];
 +int virLibvirtStateDriverTabCount = 0;
 +virStateDriverPtr virHypervisorStateDriverTab[MAX_DRIVERS];
 +int virHypervisorStateDriverTabCount = 0;
  
  if (virInitialize()  0)
  return -1;
  
  for (i = 0; i  virStateDriverTabCount; i++) {
 -if (virStateDriverTab[i]-stateInitialize) {
 +switch (virStateDriverTab[i]-stateType) {
 +case VIR_DRV_STATE_DRV_LIBVIRT:
 +virLibvirtStateDriverTab[virLibvirtStateDriverTabCount++] =
 +virStateDriverTab[i];
 +break;
 +case VIR_DRV_STATE_DRV_HYPERVISOR:
 +virHypervisorStateDriverTab[virHypervisorStateDriverTabCount++] =
 +virStateDriverTab[i];
 +break;
 +}
 +}

Hmmm, this duplicates the loading code for each driver tier. As we don't
really need to copy the driver structure pointers into separate arrays
to load each driver tier I'd suggest the following multi-pass algorithm:

for (driverTier = 0; driverTier  driverTierLast; driverTier++) {
for (i = 0; i  virStateDriverTabCount i++) {
if (virStateDriverTab[i]-stateType != driverTier)
continue;

... ALL THE EXISTING LOADER CODE ...
}
}

This'd save a lot of the code duplication and still would keep the
ordering you are trying to introduce. I like the overal idea of this series.

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] [RFC PATCH 1/7] config: Adding source for the config driver

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 This is the source code to the config driver. This driver is a hypervisor 
 driver that does not support any domain operations. The sole purpose of this 
 driver is to allow access to various bits of configuration information, such 
 as secret or network definitions, from the initialization and auto-start 
 routines of other drivers. This is the first step toward breaking the 
 circular dependencies present in QEMU and the Storage driver, in addition to 
 preventing future cases.

Again, please trim the commit message (see 2/3 in your other series for
instructions).


 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  src/config/config_driver.c | 237 
 +
  1 file changed, 237 insertions(+)
  create mode 100644 src/config/config_driver.c
 
 diff --git a/src/config/config_driver.c b/src/config/config_driver.c
 new file mode 100644
 index 000..a057300
 --- /dev/null
 +++ b/src/config/config_driver.c
 @@ -0,0 +1,237 @@
 +/*
 + * config_driver.c: core driver methods for accessing configs
 + *
 + * Copyright (C) 2013 Adam Walters
 + *
 + * 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: Adam Walters a...@pandorasboxen.com
 + */
 +#include config.h
 +#include string.h
 +
 +#include internal.h
 +#include datatypes.h
 +#include driver.h
 +#include virlog.h
 +#include viralloc.h
 +#include virerror.h
 +#include virstring.h
 +#include viraccessapicheck.h
 +#include nodeinfo.h
 +#include config_driver.h
 +
 +#define VIR_FROM_THIS VIR_FROM_CONFIG
 +
 +virConfigDriverPtr config_driver = NULL;
 +
 +static int configStateCleanup(void) {
 +if (config_driver == NULL)
 +return -1;
 +
 +virObjectUnref(config_driver-closeCallbacks);
 +
 +virSysinfoDefFree(config_driver-hostsysinfo);
 +
 +virMutexDestroy(config_driver-lock);
 +VIR_FREE(config_driver);
 +
 +return 0;
 +}
 +
 +static int configStateInitialize(bool privileged,
 + virStateInhibitCallback callback 
 ATTRIBUTE_UNUSED,
 + void *opaque ATTRIBUTE_UNUSED)
 +{
 +if (!privileged) {
 +VIR_INFO(Not running privileged, disabling driver);
 +return 0;
 +}

Won't this driver be beneficial for session connections too? (they run
unprivileged.

 +
 +if (VIR_ALLOC(config_driver)  0)
 +return -1;
 +
 +if (virMutexInit(config_driver-lock)  0) {
 +VIR_ERROR(_(cannot initialize mutex));
 +VIR_FREE(config_driver);
 +return -1;
 +}
 +
 +config_driver-hostsysinfo = virSysinfoRead();
 +
 +if (!(config_driver-closeCallbacks = virCloseCallbacksNew()))
 +goto cleanup;
 +
 +return 0;
 +
 +cleanup:
 +configStateCleanup();
 +return -1;
 +}

...

 +
 +static virDriver configDriver = {
 +.name = config,
 +.connectOpen = configConnectOpen, /* 0.2.0 */
 +.connectClose = configConnectClose, /* 0.2.0 */
 +.connectSupportsFeature = configConnectSupportsFeature, /* 0.5.0 */
 +.connectGetType = configConnectGetType, /* 0.2.0 */
 +.connectGetHostname = configConnectGetHostname, /* 0.3.3 */
 +.connectGetSysinfo = configConnectGetSysinfo, /* 0.8.8 */
 +.nodeGetInfo = configNodeGetInfo, /* 0.2.0 */
 +.connectIsEncrypted = configConnectIsEncrypted, /* 0.7.3 */
 +.connectIsSecure = configConnectIsSecure, /* 0.7.3 */
 +.connectIsAlive = configConnectIsAlive, /* 0.9.8 */

The comments here should state the release where the API was implemented
for the driver, thus you need to change them to /* 1.2.2 */.

 +};
 +
 +
 +static virStateDriver configStateDriver = {
 +.name = config,
 +.stateInitialize = configStateInitialize,
 +.stateCleanup = configStateCleanup,
 +.stateReload = configStateReload,
 +};
 +
 +int configRegister(void) {
 +virRegisterDriver(configDriver);
 +virRegisterStateDriver(configStateDriver);
 +return 0;
 +}
 

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] [RFC PATCH 5/7] po: Add config_driver.c to POTFILES.in

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 Adding config_driver.c to POTFILES.in to fix a syntax-check error.
 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  po/POTFILES.in | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/po/POTFILES.in b/po/POTFILES.in
 index 49dfc9c..0e23610 100644
 --- a/po/POTFILES.in
 +++ b/po/POTFILES.in
 @@ -27,6 +27,7 @@ src/conf/snapshot_conf.c
  src/conf/storage_conf.c
  src/conf/storage_encryption_conf.c
  src/conf/virchrdev.c
 +src/config/config_driver.c
  src/cpu/cpu.c
  src/cpu/cpu_generic.c
  src/cpu/cpu_map.c
 

This patch will need to be squashed into the patch that actually
introduces the syntax-check error. Libvirt's policy is that after each
patch the tree must be buildable and pass make check and  make
syntax-check.

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] [RFC PATCH 6/7] configure: Add config driver to configure script

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 This conditionally enables compilation of the config driver based on if we 
 are building libvirtd or not. Since this is only needed for hypervisor 
 modules during libvirtd startup, we don't need to bother compiling the config 
 driver when only building the client.
 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  configure.ac | 10 ++
  1 file changed, 10 insertions(+)
 
 diff --git a/configure.ac b/configure.ac
 index ddbcc8e..4834c51 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -1606,6 +1606,16 @@ if test $with_secrets = yes ; then
  fi
  AM_CONDITIONAL([WITH_SECRETS], [test $with_secrets = yes])
  
 +if test $with_libvirtd = no ; then
 +  with_config=no
 +else
 +  with_config=yes
 +fi
 +if test $with_config = yes ; then
 +AC_DEFINE_UNQUOTED([WITH_CONFIG], 1, [whether local config driver is 
 enabled])
 +fi
 +AM_CONDITIONAL([WITH_CONFIG], [test $with_config = yes])
 +
  
  AC_ARG_WITH([storage-dir],
[AS_HELP_STRING([--with-storage-dir],
 

This patch definitely needs to go after the makefile change, otherwise
the tree won't be buildable after this patch. Also you may want to
squash it with the makefile changes.

Also the configure script contains a section outputting the config
summary at the bottom of configure.ac where you need to add a
corresponding entry for the new driver.

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] [RFC PATCH 7/7] Makefile: Add config driver to src/Makefile.am

2014-01-20 Thread Peter Krempa
On 12/21/13 05:04, Adam Walters wrote:
 This completes the addition of the config driver to libvirt. The final piece 
 here is to add the config driver into the Makefile (via automake) so that the 
 driver is actually compiled and linked.
 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  src/Makefile.am | 25 +
  1 file changed, 25 insertions(+)
 

These changes look reasonable but they need to be before or merged with
the previous patch.

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] [RFC PATCH 4/7] libvirtd: Add config driver hooks

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 This patch adds the config driver hooks and moves the secret driver hook 
 definitions higher on the list. The secret driver move isn't strictly needed, 
 but the comments state that these should be in preferred load order. Since 
 other drivers might utilize the secret driver, it makes sense to have it 
 loaded earlier in the startup sequence.

The change of module order looks okay to me but it should be split out
into a separate patch. The loading of the config driver can then be
squashed in the patch dealing with configure/makefile.

 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  daemon/libvirtd.c | 21 +++--
  1 file changed, 15 insertions(+), 6 deletions(-)
 


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] [RFC PATCH 3/7] virterror: Adding a new VIR_FROM_ define

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 This patch adds VIR_FROM_CONFIG to the virErrorDomain enum. Both of these 
 files must be patched in unison to prevent compilation failures.
 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  include/libvirt/virterror.h | 2 ++
  src/util/virerror.c | 2 ++
  2 files changed, 4 insertions(+)
 

This patch should be squashed into 1/7. Looks good otherwise.

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] 'host-passthrough' for arm64

2014-01-20 Thread Cole Robinson
On 01/20/2014 08:19 AM, Oleg Strikov wrote:
 Hello guys,
 
 I'm trying to come up with basic OpenStack support for arm64 node.
 I'd like to use 'libvirt_cpu_mode=host-passthrough' configuration option with
 Nova which issues cpu mode='host-passthrough' to libvirt xml config.
 But with this option passed libvirt crashes with 'error: unsupported
 configuration: CPU specification not supported by hypervisor'.
 This happens because the following handlers are not implemented (or
 implemented as stubs) inside src/cpu/cpu_aarch64.c:
 * AArch64Decode()
 * AArch64Update()
 * AArch64guestData()
 
 To solve exactly this 'host-passthrough'-related issue that's enough to have
 the following set of handlers:
 
 AArch64Decode(...)
 {
 virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, -1);
 
 /* I don't know any way to detect 'cortex-a57' or any other armv8 CPU for
 now */
 /* But I don't think that we can meet anything else than cortex-a57 */
 
 /* We may also put 'host' there to specifically point out that
 qemu-aarch64 supports only '-cpu host' for now */
 /* pm215 told me that the ETA for '-cpu cortex-a57' and friends is around
 3 months from now */
 
 return !(VIR_STRDUP(cpu-model, host or cortex-a57) == 1);
 }
 
 static int AArch64Update(...)
 {
 /* qemu-aarch64 supports only '-cpu host' for now */
 
 guest-match = VIR_CPU_MATCH_EXACT;
 virCPUDefFreeModel(guest);
 return virCPUDefCopyModel(guest, host, true);
 }
 
 static virCPUCompareResult
 AArch64guestData(..)
 {
 return  VIR_CPU_COMPARE_IDENTICAL;
 }
 
 That's clear that these handlers provide just basic functionality
 ('host-passthrough'-only) and have to be extended in future.
 But is it something we can commit for now?
 
 Another way to deal with this issue is to adopt some code from PPC handlers
 (including CPU model detection and best fit qemu configuration discovery).
 But this way will be blocked until:
 (1) I find any way to reliably detect CPU model on ARMv8 board (any ideas?)
 (2) pm215 implements TCG for arm64
 
 What is the best way to choose to come up with the commitable code?
 

IMO the above is fine, doesn't look like it should cause any compatibility
issues with a real implementation in the future, and allows launching
qemu-system-aarch64 with its preferred -cpu host flag. I'd say post the patch,
and if other folks disagree they can comment there.

Thanks,
Cole

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


Re: [libvirt] [RFC PATCH 2/7] config: Adding header for the config driver

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 This is the header file for the config driver.
 
 Signed-off-by: Adam Walters a...@pandorasboxen.com
 ---
  src/config/config_driver.h | 44 
  1 file changed, 44 insertions(+)
  create mode 100644 src/config/config_driver.h
 

Looks good, but should be squashed into 1/7.

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] [RFC PATCH 0/7] Adding 'config' driver

2014-01-20 Thread Peter Krempa
On 12/21/13 05:03, Adam Walters wrote:
 This patchset adds a driver named 'config' that allows access to 
 configuration data, such as secret and storage definitions. This is a 
 pre-requisite for my next patchset which resolves the race condition on 
 libvirtd startup and the circular dependencies between QEMU and the storage 
 driver.
 
 The basic rationale behind this idea is that there exist circumstances under 
 which a driver may need to access things such as secrets during a time at 
 which there is no active connection to a hypervisor. Without a connection, 
 the data can't be accessed currently. I felt that this was a much simpler 
 solution to the problem that building new APIs that do not require a 
 connection to operate.
 
 This driver is technically what one may call a hypervisor driver, but it does 
 not implement any domain operations. It simply exists to handle requests by 
 drivers for access to informatino that would otherwise require a connection. 
 The URI used for this driver is 'config:///' and has been tested working on 4 
 different machines of mine, running three different distributions of Linux 
 (Archlinux, Gentoo, and CentOS). Being a very simple driver, I would expect 
 it to work pretty much anywhere.
 
 I would love to hear any comments and suggestions you may have about this 
 driver. At the very least this plus my next patchset resolves the startup 
 race condition on my machine. If a more robust setup (likely a new internal 
 API) is in the works, this driver could act as a band-aid to allow access to 
 this type of data in the interim if a better resolution is a ways off.
 
 Adam Walters (7):
   config: Adding source for the config driver
   config: Adding header for the config driver
   virterror: Adding a new VIR_FROM_ define
   libvirtd: Add config driver hooks
   po: Add config_driver.c to POTFILES.in
   configure: Add config driver to configure script
   Makefile: Add config driver to src/Makefile.am
 
  configure.ac|  10 ++
  daemon/libvirtd.c   |  21 ++--
  include/libvirt/virterror.h |   2 +
  po/POTFILES.in  |   1 +
  src/Makefile.am |  25 +
  src/config/config_driver.c  | 237 
 
  src/config/config_driver.h  |  44 
  src/util/virerror.c |   2 +
  8 files changed, 336 insertions(+), 6 deletions(-)
  create mode 100644 src/config/config_driver.c
  create mode 100644 src/config/config_driver.h
 

In general the code looks sane. I'm looking forward to see a v2 of this
series and I promise it won't take that long to review it as this time :).

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 RESEND v4 1/2] Introduce Libvirt Wireshark dissector

2014-01-20 Thread Michal Privoznik
On 20.01.2014 15:04, Yuto KAWAMURA wrote:
 2014/1/16 Michal Privoznik mpriv...@redhat.com:
 On 15.01.2014 18:06, Yuto KAWAMURA(kawamuray) wrote:
 From: Yuto KAWAMURA(kawamuray) kawamuray.dad...@gmail.com

 Introduce Wireshark dissector plugin which adds support to Wireshark
 for dissecting libvirt RPC protocol.
 Added following files to build Wireshark dissector from libvirt source
 tree.
 * tools/wireshark/*: Source tree of Wireshark dissector plugin.

 Added followings to configure.ac or Makefile.am.
 configure.ac
 * --with-wireshark-dissector: Enable support for building Wireshark
   dissector.
 * --with-ws-plugindir: Specify wireshark plugin directory that dissector
   will installed.
 * Added tools/wireshark/{Makefile,src/Makefile} to  AC_CONFIG_FILES.
 Makefile.am
 * Added tools/wireshark/ to SUBDIR.
 ---
  .gitignore  |2 +
  Makefile.am |3 +-
  cfg.mk  |8 +-
  configure.ac|   72 ++-
  tools/wireshark/Makefile.am |   22 +
  tools/wireshark/README.md   |   31 +
  tools/wireshark/src/Makefile.am |   42 ++
  tools/wireshark/src/packet-libvirt.c|  512 
  tools/wireshark/src/packet-libvirt.h|  128 
  tools/wireshark/util/genxdrstub.pl  | 1011 
 +++
  tools/wireshark/util/make-dissector-reg |  198 ++
  11 files changed, 2023 insertions(+), 6 deletions(-)
  create mode 100644 tools/wireshark/Makefile.am
  create mode 100644 tools/wireshark/README.md
  create mode 100644 tools/wireshark/src/Makefile.am
  create mode 100644 tools/wireshark/src/packet-libvirt.c
  create mode 100644 tools/wireshark/src/packet-libvirt.h
  create mode 100755 tools/wireshark/util/genxdrstub.pl
  create mode 100755 tools/wireshark/util/make-dissector-reg


 diff --git a/tools/wireshark/src/packet-libvirt.c 
 b/tools/wireshark/src/packet-libvirt.c
 new file mode 100644
 index 000..2d0350c
 --- /dev/null
 +++ b/tools/wireshark/src/packet-libvirt.c

 +static void
 +dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree 
 *tree)
 +{
 +goffset offset;
 +guint32 prog, proc, type, serial, status;
 +const value_string *vs;
 +
 +col_set_str(pinfo-cinfo, COL_PROTOCOL, Libvirt);
 +col_clear(pinfo-cinfo, COL_INFO);
 +
 +offset = 4; /* End of length field */
 +prog   = tvb_get_ntohl(tvb, offset); offset += 4;
 +offset += 4; /* Ignore version header field */
 +proc   = tvb_get_ntohl(tvb, offset); offset += 4;
 +type   = tvb_get_ntohl(tvb, offset); offset += 4;
 +serial = tvb_get_ntohl(tvb, offset); offset += 4;
 +status = tvb_get_ntohl(tvb, offset); offset += 4;
 +
 +col_add_fstr(pinfo-cinfo, COL_INFO, Prog=%s,
 + val_to_str(prog, program_strings, %x));
 +
 +vs = get_program_data(prog, VIR_PROGRAM_PROCSTRINGS);
 +if (vs == NULL) {
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Proc=%u, proc);
 +} else {
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Proc=%s, 
 val_to_str(proc, vs, %d));
 +}
 +
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Type=%s Serial=%u Status=%s,
 +val_to_str(type, type_strings, %d), serial,
 +val_to_str(status, status_strings, %d));
 +
 +if (tree) {
 +gint hf_proc;
 +proto_item *ti;
 +proto_tree *libvirt_tree;
 +
 +ti = proto_tree_add_item(tree, proto_libvirt, tvb, 0, 
 tvb_length(tvb), ENC_NA);
 +libvirt_tree = proto_item_add_subtree(ti, ett_libvirt);
 +
 +offset = 0;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_length,  tvb, offset, 
 4, ENC_NA); offset += 4;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_program, tvb, offset, 
 4, ENC_NA); offset += 4;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_version, tvb, offset, 
 4, ENC_NA); offset += 4;
 +
 +hf_proc = *(int *)get_program_data(prog, VIR_PROGRAM_PROCHFVAR);

 There's a possible NULL dereference here. get_program might return NULL in 
 case @prog is not one of REMOTE, QEMU, LXC, KEEPALIVE. This can possibly 
 happen and it did for me indeed:

 Program terminated with signal 11, Segmentation fault.
 #0  0x7fac1cc60a86 in dissect_libvirt_message (tvb=0x387acc0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:396
 396 hf_proc = *(int *)get_program_data(prog, 
 VIR_PROGRAM_PROCHFVAR);
 (gdb) bt
 #0  0x7fac1cc60a86 in dissect_libvirt_message (tvb=0x387acc0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:396
 #1  0x0034469198fe in tcp_dissect_pdus () from 
 /usr/lib64/libwireshark.so.3
 #2  0x7fac1cc60c0c in dissect_libvirt (tvb=0x3879aa0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:424
 #3  0x0034462dff54 in ?? () from /usr/lib64/libwireshark.so.3
 #4  0x0034462e0608 in ?? () from /usr/lib64/libwireshark.so.3
 #5  0x0034462e0e0c in ?? () 

Re: [libvirt] [RFC PATCH 0/7] Adding 'config' driver

2014-01-20 Thread Daniel P. Berrange
On Fri, Dec 20, 2013 at 11:03:53PM -0500, Adam Walters wrote:
 This patchset adds a driver named 'config' that allows access to configuration
 data, such as secret and storage definitions. This is a pre-requisite for my
 next patchset which resolves the race condition on libvirtd startup and the
 circular dependencies between QEMU and the storage driver.

I vaguely recall something being mentioned in the past, but not the
details. Can you explain the details of the circular dependancy
problem that you're currently facing ?

 The basic rationale behind this idea is that there exist circumstances under 
 which a driver may need to access things such as secrets during a time at
 which there is no active connection to a hypervisor. Without a connection,
 the data can't be accessed currently. I felt that this was a much simpler
 solution to the problem that building new APIs that do not require a 
 connection
 to operate.

We have a handful of places in our code where we call out to public
APIs to implement some piece of functionality. I've never been all
that happy about these scenarios. If we call the public API directly,
they cause havoc with error reporting because we end up dispatching
and resetting errors in the middle of an nested API call. Calling the
driver methods directly by doing conn-driver-invokeMethod() is
somewhat tedious  error prone because we're then skipping various
sanity tests that the public APIs do.  With ACL checking now implemented
we also have the slightly odd situation that a public API check which
is documented as requiring permission '' may also require permissions
'' and '' to deal with other public APIs we invoke secretly.

I think there is a fairly strong argument that our internal implementations
could be decoupled from the public APIs, so we can call methods internally
without having to go via the public APIs at all.

On the flip side though, there's also a long term desire to separate
the different drivers into separate daemons, eg so the secrets driver
might move into a  libvirt-secretsd daemon, which might explicitly
require use to go via the public APIs.

 This driver is technically what one may call a hypervisor driver, but it
 does not implement any domain operations. It simply exists to handle requests
 by drivers for access to informatino that would otherwise require a 
 connection.
 The URI used for this driver is 'config:///' and has been tested working on 4
 different machines of mine, running three different distributions of Linux
 (Archlinux, Gentoo, and CentOS). Being a very simple driver, I would expect
 it to work pretty much anywhere.
 
 I would love to hear any comments and suggestions you may have about this
 driver. At the very least this plus my next patchset resolves the startup
 race condition on my machine. If a more robust setup (likely a new internal
 API) is in the works, this driver could act as a band-aid to allow access
 to this type of data in the interim if a better resolution is a ways off.

One big concern I have about this approach is the fact that once we add
this 'config:///' driver, it is very hard for us to ever remove it again,
since this concept leaks out into the public API. So we're going to want
to be very sure that this is something we wish to support long term, and
I don't really have such confidence myself.

I'd like to understand a bit more about the dependancy issue you're facing
to see if there's something else we can do to address it.

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

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


Re: [libvirt] [PATCH] Use AC_PATH_PROG to search for dmidecode

2014-01-20 Thread Eric Blake
On 01/17/2014 12:17 PM, Roman Bogorodskiy wrote:
 This is useful in certain circumstances, for example when
 libvirtd is being executed by FreeBSD rc script, it cannot find
 dmidecode installed from FreeBSD ports because it doesn't have
 /usr/local (default prefix for ports) in PATH.
 ---
  configure.ac  | 4 
  src/util/virsysinfo.c | 2 +-
  2 files changed, 5 insertions(+), 1 deletion(-)
 

ACK and 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] [RFC PATCH 0/7] Adding 'config' driver

2014-01-20 Thread Peter Krempa
On 01/20/14 17:27, Daniel P. Berrange wrote:
 On Fri, Dec 20, 2013 at 11:03:53PM -0500, Adam Walters wrote:
 This patchset adds a driver named 'config' that allows access to 
 configuration
 data, such as secret and storage definitions. This is a pre-requisite for my
 next patchset which resolves the race condition on libvirtd startup and the
 circular dependencies between QEMU and the storage driver.
 
 I vaguely recall something being mentioned in the past, but not the
 details. Can you explain the details of the circular dependancy
 problem that you're currently facing ?

The problem is that when we are re-starting with running VMs that have
storage placed on RBD volumes with secrets stored in the secret driver
we encounter the following dependancy:

1) the qemu driver depends on the storage driver to be started so that
disk type=volume can be resolved to the actual volumes

2) the storage driver depends on requesting credentials from the secret
driver and thus needs a connection to do so. For some strange reason the
storage driver opens qemu:///system for this purpose:

static void
storageDriverAutostart(virStorageDriverStatePtr driver) {
size_t i;
virConnectPtr conn = NULL;

/* XXX Remove hardcoding of QEMU URI */
if (driverState-privileged)
conn = virConnectOpen(qemu:///system);
else
conn = virConnectOpen(qemu:///session);
/* Ignoring NULL conn - let backends decide */

This works if the drivers are initialized, but breaks in the case we use
RBD volumes with secrets that and disk type=volume, where we need to
initialize the storage driver before the qemu driver.

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 1/8] rename virDomainBlkioDeviceWeightParseXML to virDomainBlkioDeviceParseXML

2014-01-20 Thread Eric Blake
On 12/11/2013 01:29 AM, Gao feng wrote:
 virDomainBlkioDeviceWeightParseXML will be used to parse
 the xml element read_bps, write_bps, read_iops, write_iops.
 
 Signed-off-by: Gao feng gaof...@cn.fujitsu.com
 ---
  src/conf/domain_conf.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

ACK.

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



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

Re: [libvirt] [PATCH] Add test for transient disk support in VMX files

2014-01-20 Thread Eric Blake
On 01/18/2014 04:20 AM, Wout Mertens wrote:
 From: Wout Mertens wout.mert...@gmail.com
 
 Adds test for transient disk translation in vmx files
 
 ---
  tests/vmx2xmldata/vmx2xml-harddisk-transient.vmx |6 +
  tests/vmx2xmldata/vmx2xml-harddisk-transient.xml |   25
 ++
  tests/vmx2xmltest.c  |1 +
  3 files changed, 32 insertions(+), 0 deletions(-)
  create mode 100644 tests/vmx2xmldata/vmx2xml-harddisk-transient.vmx
  create mode 100644 tests/vmx2xmldata/vmx2xml-harddisk-transient.xml

ACK and 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 1/8] rename virDomainBlkioDeviceWeightParseXML to virDomainBlkioDeviceParseXML

2014-01-20 Thread Eric Blake
On 01/20/2014 09:44 AM, Eric Blake wrote:
 On 12/11/2013 01:29 AM, Gao feng wrote:
 virDomainBlkioDeviceWeightParseXML will be used to parse
 the xml element read_bps, write_bps, read_iops, write_iops.

 Signed-off-by: Gao feng gaof...@cn.fujitsu.com
 ---
  src/conf/domain_conf.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)
 
 ACK.

Oh, I never saw this get reviewed, but I see it has already been in
libvirt.git for more than a month.  Sorry for the noise.

-- 
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] [PATCHv2 0/2] Avoid libvirtd crash when qemu crashes while snapshotting

2014-01-20 Thread Peter Krempa
Peter Krempa (2):
  DO NOT APPLY UPSTREAM: Reproducer for disk snapshot crash
  qemu: snapshot: Avoid libvirtd crash when qemu crashes while
snapshotting

 src/qemu/qemu_driver.c | 56 +++---
 1 file changed, 44 insertions(+), 12 deletions(-)

-- 
1.8.5.3

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


[libvirt] [PATCHv2 2/2] qemu: snapshot: Avoid libvirtd crash when qemu crashes while snapshotting

2014-01-20 Thread Peter Krempa
We shouldn't access the domain definition while we are in the monitor
section as the domain is unlocked. Additionaly after we exit from the
monitor we need to check if the VM is still alive. Not doing so resulted
into crash if qemu exits while attempting to do a external VM snapshot.
---

Notes:
Version 1 was reported to break locking of a VM but withoit enough data to 
reproduce/trace.
Version 2:
- changed some of the conditions so that proper cleanup paths are taken
- fixed returned error value in case the job can't be entered

 src/qemu/qemu_driver.c | 53 ++
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 66bbde9..e6f180c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12550,7 +12550,8 @@ 
qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
  virDomainDiskDefPtr disk,
  virDomainDiskDefPtr persistDisk,
  virJSONValuePtr actions,
- bool reuse)
+ bool reuse,
+ enum qemuDomainAsyncJob asyncJob)
 {
 qemuDomainObjPrivatePtr priv = vm-privateData;
 char *device = NULL;
@@ -12605,8 +12606,25 @@ 
qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
 /* create the actual snapshot */
 if (snap-format)
 formatStr = virStorageFileFormatTypeToString(snap-format);
+
+/* The monitor is only accessed if qemu doesn't support transactions.
+ * Otherwise the following monitor command only constructs the command.
+ */
+if (!actions 
+qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob)  0)
+goto cleanup;
+
 ret = qemuMonitorDiskSnapshot(priv-mon, actions, device, source,
   formatStr, reuse);
+if (!actions) {
+qemuDomainObjExitMonitor(driver, vm);
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(Domain crashed while taking the snapshot));
+ret = -1;
+}
+}
+
 virDomainAuditDisk(vm, disk-src, source, snapshot, ret = 0);
 if (ret  0)
 goto cleanup;
@@ -12712,9 +12730,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr 
driver,
  * Based on earlier qemuDomainSnapshotPrepare, all
  * disks in this list are now either SNAPSHOT_NO, or
  * SNAPSHOT_EXTERNAL with a valid file name and qcow2 format.  */
-if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob)  0)
-goto cleanup;
-
 for (i = 0; i  snap-def-ndisks; i++) {
 virDomainDiskDefPtr persistDisk = NULL;

@@ -12724,24 +12739,36 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr 
driver,
 int indx = virDomainDiskIndexByName(vm-newDef,
 vm-def-disks[i]-dst,
 false);
-if (indx = 0) {
+if (indx = 0)
 persistDisk = vm-newDef-disks[indx];
-persist = true;
-}
 }

 ret = qemuDomainSnapshotCreateSingleDiskActive(driver, vm,
snap-def-disks[i],
vm-def-disks[i],
persistDisk, actions,
-   reuse);
+   reuse, asyncJob);
 if (ret  0)
 break;
 }
 if (actions) {
-if (ret == 0)
-ret = qemuMonitorTransaction(priv-mon, actions);
+if (ret == 0) {
+if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
+ret = qemuMonitorTransaction(priv-mon, actions);
+qemuDomainObjExitMonitor(driver, vm);
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(domain crashed while taking the 
snapshot));
+ret = -1;
+}
+} else {
+/* failed to enter monitor, clean stuff up and quit */
+ret = -1;
+}
+}
+
 virJSONValueFree(actions);
+
 if (ret  0) {
 /* Transaction failed; undo the changes to vm.  */
 bool need_unlink = !(flags  VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT);
@@ -12755,8 +12782,11 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr 
driver,
 int indx = virDomainDiskIndexByName(vm-newDef,
 vm-def-disks[i]-dst,
 

[libvirt] [PATCHv2 1/2] DO NOT APPLY UPSTREAM: Reproducer for disk snapshot crash

2014-01-20 Thread Peter Krempa
Use the following xml to create a disk-only snapshot of a VM with this
patch applied to crash libvirtd:
domainsnapshot
  disks
disk name='vda' type='file'
  driver type='qcow2'/
  source file='/tmp/path.img'/
/disk
  /disks
/domainsnapshot
---
 src/qemu/qemu_driver.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index df4f5b5..66bbde9 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12599,6 +12599,9 @@ 
qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
 goto cleanup;
 }

+kill(vm-pid, 9);
+sleep(1);
+
 /* create the actual snapshot */
 if (snap-format)
 formatStr = virStorageFileFormatTypeToString(snap-format);
-- 
1.8.5.3

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


Re: [libvirt] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Thierry Parmentelat
Hi

Well if I need to run anything in the container context, short of entering it 
through e.g. ssh - hoping this is properly set up - well, I can’t..

I am using libvirt / lxc to set up a build box; essentially every night I would 
spawn a set of fresh VMs of some flavours (fedora18, ubuntu, what not) and use 
this to rebuild my system from scratch
In this context it’s a real hassle to have to even set up ssh, there is no good 
reason for the build VM to run an ssh service at all, and I am concerned it 
might pull dependencies that I do not need/want
I’d much rather have a direct means to just run some command inside the 
container.

Admittedly I’m brain-damaged after having used vservers for too long, and their 
‘vserver container exec command to run’ feature is in my genes now ;)

Now maybe I am the one who is missing something and there already is something 
to do that ?
Using the trick below I essentially have what I need mind you, I’m just 
concerned that it kind of works by accident :-)

Thanks for the feedback in any case — Thierry

On 20 Jan 2014, at 12:49, Daniel P. Berrange berra...@redhat.com wrote:

 On Mon, Jan 20, 2014 at 11:38:08AM +0100, Thierry Parmentelat wrote:
 Hello there
 
 I am trying to locate the namespaces in place for a given lxc container 
 (specifically /proc/pid/ns/*)
 
 And to this end I was wondering what is the recommended way to probe for an 
 lxc container's init pid
 (mostly I'm after the mnt and pid namespaces, and probably network ones, but 
 the actual list probably should not matter) 
 
 I've found about virsh domid but this gives me the pid for libvirt_lxc, 
 which turns out to have unmodified namespaces (at least as far as the mnt ns)
 OTOH this process has exactly one child which is the container's init, which 
 seems to have the right set of namespaces 
 
 My angle right now is to look in /proc/domid_pid/task/children for a - 
 hopefully single - pid and
 that seems to work for now, but I am concerned this code may be fragile so I 
 would rather use a more
 robust approach; or maybe this is robust ? 
 
 We don't really wish to expose the container PIDs to the host or namespace
 details to client apps. Can you give more info about what you're trying to
 achieve overall. I'd like to understand if there's some higher level API
 we're missing that would more directly address your needs.
 
 
 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] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Thierry Parmentelat
Oh, and I was about to forget..
The system I am talking about is PlanetLab, that we now manage with libvirt/lxc 
instead of the old vserver-based stuff (although the public testbed still is 
vastly vserver-based)
And in that context too, it’s much more efficient for us to plug an incoming 
ssh request inside the host to a simple fork that runs in the container 
context, instead of relying here again on ssh to reach the container..

My $0.02 — thanks again — Thierry

On 20 Jan 2014, at 18:53, Thierry Parmentelat thierry.parmente...@inria.fr 
wrote:

 Hi
 
 Well if I need to run anything in the container context, short of entering it 
 through e.g. ssh - hoping this is properly set up - well, I can’t..
 
 I am using libvirt / lxc to set up a build box; essentially every night I 
 would spawn a set of fresh VMs of some flavours (fedora18, ubuntu, what not) 
 and use this to rebuild my system from scratch
 In this context it’s a real hassle to have to even set up ssh, there is no 
 good reason for the build VM to run an ssh service at all, and I am concerned 
 it might pull dependencies that I do not need/want
 I’d much rather have a direct means to just run some command inside the 
 container.
 
 Admittedly I’m brain-damaged after having used vservers for too long, and 
 their ‘vserver container exec command to run’ feature is in my genes now ;)
 
 Now maybe I am the one who is missing something and there already is 
 something to do that ?
 Using the trick below I essentially have what I need mind you, I’m just 
 concerned that it kind of works by accident :-)
 
 Thanks for the feedback in any case — Thierry
 
 On 20 Jan 2014, at 12:49, Daniel P. Berrange berra...@redhat.com wrote:
 
 On Mon, Jan 20, 2014 at 11:38:08AM +0100, Thierry Parmentelat wrote:
 Hello there
 
 I am trying to locate the namespaces in place for a given lxc container 
 (specifically /proc/pid/ns/*)
 
 And to this end I was wondering what is the recommended way to probe for an 
 lxc container's init pid
 (mostly I'm after the mnt and pid namespaces, and probably network ones, 
 but the actual list probably should not matter) 
 
 I've found about virsh domid but this gives me the pid for libvirt_lxc, 
 which turns out to have unmodified namespaces (at least as far as the mnt 
 ns)
 OTOH this process has exactly one child which is the container's init, 
 which seems to have the right set of namespaces 
 
 My angle right now is to look in /proc/domid_pid/task/children for a - 
 hopefully single - pid and
 that seems to work for now, but I am concerned this code may be fragile so 
 I would rather use a more
 robust approach; or maybe this is robust ? 
 
 We don't really wish to expose the container PIDs to the host or namespace
 details to client apps. Can you give more info about what you're trying to
 achieve overall. I'd like to understand if there's some higher level API
 we're missing that would more directly address your needs.
 
 
 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] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Eric Blake
On 01/20/2014 10:53 AM, Thierry Parmentelat wrote:
 Hi

[please don't top-post on technical lists]

 
 Admittedly I’m brain-damaged after having used vservers for too long, and 
 their ‘vserver container exec command to run’ feature is in my genes now ;)
 
 Now maybe I am the one who is missing something and there already is 
 something to do that ?

Why doesn't 'virsh lxc-enter-namespace $dom command to run' work for
you?  There's also the setuid executable 'virt-login-shell' for a
special subset of LXC domains (where the current user can do
'virt-login-shell' to gain a shell access to the domain named after
their username, once you configure things to allow that user to access
virt-login-shell').

-- 
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] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Daniel P. Berrange
On Mon, Jan 20, 2014 at 06:53:28PM +0100, Thierry Parmentelat wrote:
 Hi
 
 Well if I need to run anything in the container context, short of entering
 it through e.g. ssh - hoping this is properly set up - well, I can’t..
 
 I am using libvirt / lxc to set up a build box; essentially every night
 I would spawn a set of fresh VMs of some flavours (fedora18, ubuntu,
 what not) and use this to rebuild my system from scratch
 In this context it’s a real hassle to have to even set up ssh, there is
 no good reason for the build VM to run an ssh service at all, and I am
 concerned it might pull dependencies that I do not need/want
 I’d much rather have a direct means to just run some command inside the 
 container.
 
 Admittedly I’m brain-damaged after having used vservers for too long, and 
 their
 ‘vserver container exec command to run’ feature is in my genes now ;)
 
 Now maybe I am the one who is missing something and there already is 
 something to do that ?
 Using the trick below I essentially have what I need mind you, I’m just 
 concerned that it
 kind of works by accident :-)

Yes, it already exists, albeit as a lxc specific custom command/api:

  $ virsh lxc-enter-namespace $CONTAINER /path/to/command/to/run arg1 arg2...

There's a corresponding API in the libvirt-lxc.so library
virDomainLxcEnterNamspace

Eventually we'll turn this into a proper libvirt API with a less sucky
virsh command name.

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] What is the robust/recommended way to retrieve the PID of a VM's init process ?

2014-01-20 Thread Thierry Parmentelat
Oh, I had totally failed to spot that one..
Thanks for the tip, I’ll give this a try :-)

On 20 Jan 2014, at 18:59, Daniel P. Berrange berra...@redhat.com wrote:

 On Mon, Jan 20, 2014 at 06:53:28PM +0100, Thierry Parmentelat wrote:
 Hi
 
 Well if I need to run anything in the container context, short of entering
 it through e.g. ssh - hoping this is properly set up - well, I can’t..
 
 I am using libvirt / lxc to set up a build box; essentially every night
 I would spawn a set of fresh VMs of some flavours (fedora18, ubuntu,
 what not) and use this to rebuild my system from scratch
 In this context it’s a real hassle to have to even set up ssh, there is
 no good reason for the build VM to run an ssh service at all, and I am
 concerned it might pull dependencies that I do not need/want
 I’d much rather have a direct means to just run some command inside the 
 container.
 
 Admittedly I’m brain-damaged after having used vservers for too long, and 
 their
 ‘vserver container exec command to run’ feature is in my genes now ;)
 
 Now maybe I am the one who is missing something and there already is 
 something to do that ?
 Using the trick below I essentially have what I need mind you, I’m just 
 concerned that it
 kind of works by accident :-)
 
 Yes, it already exists, albeit as a lxc specific custom command/api:
 
  $ virsh lxc-enter-namespace $CONTAINER /path/to/command/to/run arg1 arg2...
 
 There's a corresponding API in the libvirt-lxc.so library
 virDomainLxcEnterNamspace
 
 Eventually we'll turn this into a proper libvirt API with a less sucky
 virsh command name.
 
 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] qemu: snapshot: Avoid libvirtd crash when qemu crashes while snapshotting

2014-01-20 Thread Eric Blake
On 01/20/2014 10:09 AM, Peter Krempa wrote:
 We shouldn't access the domain definition while we are in the monitor
 section as the domain is unlocked. Additionaly after we exit from the

s/Additionaly/Additionally/

 monitor we need to check if the VM is still alive. Not doing so resulted
 into crash if qemu exits while attempting to do a external VM snapshot.

s/into/in a/

 ---
 
 Notes:
 Version 1 was reported to break locking of a VM but withoit enough data 
 to reproduce/trace.
 Version 2:
 - changed some of the conditions so that proper cleanup paths are taken
 - fixed returned error value in case the job can't be entered
 
  src/qemu/qemu_driver.c | 53 
 ++
  1 file changed, 41 insertions(+), 12 deletions(-)
 

Code looks correct, I also ran through a smoke test with your reproducer
1/2 applied, and confirmed that this code is definitely required for the
fix.

ACK with grammar fixes.

-- 
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 2/2] qemu: snapshot: Avoid libvirtd crash when qemu crashes while snapshotting

2014-01-20 Thread Martin Kletzander
On Mon, Jan 20, 2014 at 06:09:33PM +0100, Peter Krempa wrote:
 We shouldn't access the domain definition while we are in the monitor
 section as the domain is unlocked. Additionaly after we exit from the
 monitor we need to check if the VM is still alive. Not doing so resulted
 into crash if qemu exits while attempting to do a external VM snapshot.

s/a external/an external/ ;)

Martin


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

[libvirt] [vmware] Fix VMware driver version checking on Linux

2014-01-20 Thread ryan woodsmall
Recent changes to the VMware driver allow for VMware Fusion version checking on 
OS X. It looks like the version checking on Linux for VMware Workstation and 
Player could possibly be broken by the changes. The version check in 
vmware_conf.c bundled STDOUT and STDERR into a common buffer; when/if something 
is printed to STDERR, at least on Player, version checking fails.

This example output causes the version check to fail on a RHEL6-based Linux 
install:
**
[ryan@os-sl6-controller ~]$ vmplayer -v
Gtk-Message: Failed to load module canberra-gtk-module: 
libcanberra-gtk-module.so: cannot open shared object file: No such file or 
directory
VMware Player 6.0.1 build-1379776

[ryan@os-sl6-controller ~]$ virsh -c vmwareplayer:///session
error: failed to connect to the hypervisor
error: internal error: failed to parse VMware Player version
**

This patch bundles STDERR into the checked buffer only with the VMware Fusion 
driver, allowing the VMware Player version check to succeed on Linux even with 
the above warning. It looks like there's still an issue (see below) but virsh 
now starts at least.

**
[ryan@os-sl6-controller ~]$ virsh -c vmwareplayer:///session
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
   'quit' to quit

virsh # version
Compiled against library: libvirt 1.2.1
Using library: libvirt 1.2.1
Using API: VMware 1.2.1
Cannot extract running VMware hypervisor version

**

This is virsh running against VMware Player 6.0.1 on Linux x86_64. I have not 
tested on OS X since I don't have a license for VMware Fusion. Thanks everyone!

-r


diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c
index c96bd62..502d5c9 100644
--- a/src/vmware/vmware_conf.c
+++ b/src/vmware/vmware_conf.c
@@ -293,7 +293,8 @@ vmwareExtractVersion(struct vmware_driver *driver)
 
 cmd = virCommandNewArgList(bin, -v, NULL);
 virCommandSetOutputBuffer(cmd, outbuf);
-virCommandSetErrorBuffer(cmd, outbuf);
+if (driver-type == VMWARE_DRIVER_FUSION)
+virCommandSetErrorBuffer(cmd, outbuf);
 
 if (virCommandRun(cmd, NULL)  0)
 goto cleanup;

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


Re: [libvirt] [v10 1/6] add hostdev passthrough common library

2014-01-20 Thread Jim Fehlig
Jim Fehlig wrote:
 Chunyan Liu wrote:
   
 Extract code from qemu_hostdev.c and make it reusable for multiple drivers,
 meanwhile maintain a global hostdev state to solve conflict between different
 drivers.

 Signed-off-by: Chunyan Liu cy...@suse.com
 ---
  .gnulib  |2 +-
  po/POTFILES.in   |1 +
  src/Makefile.am  |1 +
  src/libvirt_private.syms |   21 +
  src/lxc/lxc_hostdev.c|   11 +-
  src/qemu/qemu_driver.c   |4 +-
  src/qemu/qemu_hostdev.c  |   42 +-
  src/util/virhostdev.c| 1691 
 ++
  src/util/virhostdev.h|  134 
  src/util/virpci.c|   30 +-
  src/util/virpci.h|9 +-
  src/util/virscsi.c   |   28 +-
  src/util/virscsi.h   |8 +-
  src/util/virusb.c|   29 +-
  src/util/virusb.h|8 +-
  15 files changed, 1970 insertions(+), 49 deletions(-)
  create mode 100644 src/util/virhostdev.c
  create mode 100644 src/util/virhostdev.h

 diff --git a/.gnulib b/.gnulib
 index d18d1b8..831b84c 16
 --- a/.gnulib
 +++ b/.gnulib
 @@ -1 +1 @@
 -Subproject commit d18d1b802380bb8f0a079c7312a1adffdce0
 +Subproject commit 831b84c59ef413c57a36b67344467d66a8a2ba70
   
 

 Oops, looks like you needed to update gnulib.
   

[...]

 diff --git a/src/util/virhostdev.h b/src/util/virhostdev.h
 new file mode 100644
 index 000..e15a70d
 --- /dev/null
 +++ b/src/util/virhostdev.h
 @@ -0,0 +1,134 @@
 +/* virhostdev.h: hostdev management
 + *
 + * Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
 + * Copyright (C) 2006-2007, 2009-2014 Red Hat, Inc.
 + * Copyright (C) 2006 Daniel P. Berrange
 + *
 + * 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: Chunyan Liu cy...@suse.com
 + * Author: Daniel P. Berrange berra...@redhat.com
 + */
 +
 +#ifndef __VIR_HOSTDEV_H__
 +# define __VIR_HOSTDEV_H__
 +
 +# include internal.h
 +
 +# include domain_conf.h
 +# include virpci.h
 +# include virusb.h
 +# include virscsi.h
 +
 +typedef enum {
 +VIR_SP_PCI_HOSTDEV   = (1  0), /* support pci passthrough */
 +VIR_SP_USB_HOSTDEV   = (1  1), /* support usb passthrough */
 +VIR_SP_SCSI_HOSTDEV  = (1  2), /* support scsi passthrough */
 +
 +VIR_COLD_BOOT= (1  8), /* cold boot */
 +VIR_STRICT_ACS_CHECK = (1  9), /* strict acs check */
 +} virHostdevManagerFlag;
 +
 +typedef struct _virHostdevManager virHostdevManager;
 +typedef virHostdevManager *virHostdevManagerPtr;
 +struct _virHostdevManager{
 +char *stateDir;
 +
 +virPCIDeviceListPtr activePciHostdevs;
 +virPCIDeviceListPtr inactivePciHostdevs;
 +virUSBDeviceListPtr activeUsbHostdevs;
 +virSCSIDeviceListPtr activeScsiHostdevs;
 +};
 +
 +virHostdevManagerPtr virHostdevManagerGetDefault(void);
 +
 +bool virHostdevHostSupportsPassthroughVFIO(void);
 +bool virHostdevHostSupportsPassthroughKVM(void);
 

While rebasing 3/6, noticed the name change here from
SupportsPassthroughLegacy to SupportsPassthroughKVM. IMO, we should
stick with the existing name.

Regards,
Jim

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


Re: [libvirt] [v10 2/6] add unit test to hostdev common library

2014-01-20 Thread Jim Fehlig
Chunyan Liu wrote:
 Add unit test for hostdev common library. Current tests are based on 
 virpcimock.

   

[...]

 diff --git a/tests/virpcimock.c b/tests/virpcimock.c
 index 49759b0..5676db7 100644
 --- a/tests/virpcimock.c
 +++ b/tests/virpcimock.c
   

Your can drop the changes to this file, since they were added by 508b566e.

Regards,
Jim

 @@ -149,7 +149,7 @@ static int pci_driver_handle_bind(const char *path);
  static int pci_driver_handle_unbind(const char *path);
  static int pci_driver_handle_new_id(const char *path);
  static int pci_driver_handle_remove_id(const char *path);
 -
 +static int pci_handle_drivers_probe(const char *path);
  
  /*
   * Helper functions
 @@ -585,6 +585,8 @@ pci_driver_handle_change(int fd ATTRIBUTE_UNUSED, const 
 char *path)
  } else if (STREQ(file, remove_id)) {
  /* handle write to remove_id */
  ret = pci_driver_handle_remove_id(path);
 +} else if (STREQ(file, drivers_probe)) {
 +ret = pci_handle_drivers_probe(path);
  } else {
  /* yet not handled write */
  ABORT(Not handled write to: %s, path);
 @@ -724,6 +726,16 @@ cleanup:
  return ret;
  }
  
 +static int
 +pci_handle_drivers_probe(const char *path)
   
 +{
 +struct pciDevice *dev = pci_device_find_by_content(path);
 +
 +if (pci_device_autobind(dev)  0)
 +ABORT(Unable to do driver reprobe.);
 +
 +return 0;
 +}
  
  /*
   * Functions to load the symbols and init the environment
 @@ -760,6 +772,9 @@ init_syms(void)
  static void
  init_env(void)
  {
 +int fd = -1;
 +char *filepath;
 +
  if (fakesysfsdir)
  return;
  
 @@ -791,6 +806,12 @@ init_env(void)
  MAKE_PCI_DEVICE(0005:90:01.0, 0x1033, 0x0035);
  MAKE_PCI_DEVICE(0005:90:01.1, 0x1033, 0x0035);
  MAKE_PCI_DEVICE(0005:90:01.2, 0x1033, 0x00e0);
 +
 +/* make file drivers_probe */
 +if (virAsprintfQuiet(filepath, %s/drivers_probe, fakesysfsdir)  0)
 +ABORT_OOM();
 +if ((fd = realopen(filepath, O_CREAT|O_WRONLY, 0200))  0)
 +ABORT(Unable to create: %s, filepath);
  }
  
  
   

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


Re: [libvirt] [v10 3/6] change qemu driver to use hostdev common library

2014-01-20 Thread Jim Fehlig
Chunyan Liu wrote:
 Change qemu driver to use hostdev common library instead of APIs in
 qemu_hostdev.[ch] Improve some test files.
   

[...]

 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index d39cdc4..29d4371 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -50,7 +50,6 @@
  #include qemu_capabilities.h
  #include qemu_command.h
  #include qemu_cgroup.h
 -#include qemu_hostdev.h
  #include qemu_hotplug.h
  #include qemu_monitor.h
  #include qemu_bridge_filter.h
 @@ -94,11 +93,10 @@
  #include virstring.h
  #include viraccessapicheck.h
  #include viraccessapicheckqemu.h
 +#include virhostdev.h
  
  #define VIR_FROM_THIS VIR_FROM_QEMU
  
 -#define QEMU_DRIVER_NAME QEMU
 -
  #define QEMU_NB_MEM_PARAM  3
  
  #define QEMU_NB_BLOCK_IO_TUNE_PARAM  6
 @@ -698,18 +696,6 @@ qemuStateInitialize(bool privileged,
  if (qemuSecurityInit(qemu_driver)  0)
  goto error;
  
 -if ((qemu_driver-activePciHostdevs = virPCIDeviceListNew()) == NULL)
 -goto error;
 -
 -if ((qemu_driver-activeUsbHostdevs = virUSBDeviceListNew()) == NULL)
 -goto error;
 -
 -if ((qemu_driver-inactivePciHostdevs = virPCIDeviceListNew()) == NULL)
 -goto error;
 -
 -if ((qemu_driver-activeScsiHostdevs = virSCSIDeviceListNew()) == NULL)
 -goto error;
 -
  if (!(qemu_driver-sharedDevices = virHashCreate(30, 
 qemuSharedDeviceEntryFree)))
  goto error;
  
 @@ -989,10 +975,6 @@ qemuStateCleanup(void) {
  
  virNWFilterUnRegisterCallbackDriver(qemuCallbackDriver);
  virObjectUnref(qemu_driver-config);
 -virObjectUnref(qemu_driver-activePciHostdevs);
 -virObjectUnref(qemu_driver-inactivePciHostdevs);
 -virObjectUnref(qemu_driver-activeUsbHostdevs);
 -virObjectUnref(qemu_driver-activeScsiHostdevs);
  virHashFree(qemu_driver-sharedDevices);
  virObjectUnref(qemu_driver-caps);
  virQEMUCapsCacheFree(qemu_driver-qemuCapsCache);
 @@ -10785,12 +10767,12 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
const char *driverName,
unsigned int flags)
  {
 -virQEMUDriverPtr driver = dev-conn-privateData;
  virPCIDevicePtr pci = NULL;
  unsigned domain = 0, bus = 0, slot = 0, function = 0;
  int ret = -1;
  virNodeDeviceDefPtr def = NULL;
  char *xml = NULL;
 +virHostdevManagerPtr hostdev_mgr;
  
  virCheckFlags(0, -1);
  
 @@ -10814,9 +10796,9 @@ qemuNodeDeviceDetachFlags(virNodeDevicePtr dev,
  
  if (!driverName) {
  /* prefer vfio */
 -if (qemuHostdevHostSupportsPassthroughVFIO())
 +if (virHostdevHostSupportsPassthroughVFIO())
  driverName = vfio;
 -else if (qemuHostdevHostSupportsPassthroughLegacy())
 +else if (virHostdevHostSupportsPassthroughKVM())
  driverName = kvm;
  }
  
   

This needs rebased after df802272.  And as mentioned in 1/6, we should
use the existing SupportsPassthroughLegacy name.

But in general, I think this series is in good shape.  I had a chance to
test the series on a machine with dual-port Broadcom BCM5709, which does
not have FLR.  I didn't notice any change in behavior after applying
this series.

It would be nice to get this merged early in the release cycle, meaning
soon.  Do any other libvirt maintainers have comments that Chunyan could
address in a V11?  I'd give an updated version a soft ACK, since I've
only recently become familiar with this code :-).

Regards,
Jim

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


Re: [libvirt] [PATCH RESEND v4 1/2] Introduce Libvirt Wireshark dissector

2014-01-20 Thread Yuto KAWAMURA
2014/1/21 Michal Privoznik mpriv...@redhat.com:
 On 20.01.2014 15:04, Yuto KAWAMURA wrote:
 2014/1/16 Michal Privoznik mpriv...@redhat.com:
 On 15.01.2014 18:06, Yuto KAWAMURA(kawamuray) wrote:
 From: Yuto KAWAMURA(kawamuray) kawamuray.dad...@gmail.com

 Introduce Wireshark dissector plugin which adds support to Wireshark
 for dissecting libvirt RPC protocol.
 Added following files to build Wireshark dissector from libvirt source
 tree.
 * tools/wireshark/*: Source tree of Wireshark dissector plugin.

 Added followings to configure.ac or Makefile.am.
 configure.ac
 * --with-wireshark-dissector: Enable support for building Wireshark
   dissector.
 * --with-ws-plugindir: Specify wireshark plugin directory that dissector
   will installed.
 * Added tools/wireshark/{Makefile,src/Makefile} to  AC_CONFIG_FILES.
 Makefile.am
 * Added tools/wireshark/ to SUBDIR.
 ---
  .gitignore  |2 +
  Makefile.am |3 +-
  cfg.mk  |8 +-
  configure.ac|   72 ++-
  tools/wireshark/Makefile.am |   22 +
  tools/wireshark/README.md   |   31 +
  tools/wireshark/src/Makefile.am |   42 ++
  tools/wireshark/src/packet-libvirt.c|  512 
  tools/wireshark/src/packet-libvirt.h|  128 
  tools/wireshark/util/genxdrstub.pl  | 1011 
 +++
  tools/wireshark/util/make-dissector-reg |  198 ++
  11 files changed, 2023 insertions(+), 6 deletions(-)
  create mode 100644 tools/wireshark/Makefile.am
  create mode 100644 tools/wireshark/README.md
  create mode 100644 tools/wireshark/src/Makefile.am
  create mode 100644 tools/wireshark/src/packet-libvirt.c
  create mode 100644 tools/wireshark/src/packet-libvirt.h
  create mode 100755 tools/wireshark/util/genxdrstub.pl
  create mode 100755 tools/wireshark/util/make-dissector-reg


 diff --git a/tools/wireshark/src/packet-libvirt.c 
 b/tools/wireshark/src/packet-libvirt.c
 new file mode 100644
 index 000..2d0350c
 --- /dev/null
 +++ b/tools/wireshark/src/packet-libvirt.c

 +static void
 +dissect_libvirt_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree 
 *tree)
 +{
 +goffset offset;
 +guint32 prog, proc, type, serial, status;
 +const value_string *vs;
 +
 +col_set_str(pinfo-cinfo, COL_PROTOCOL, Libvirt);
 +col_clear(pinfo-cinfo, COL_INFO);
 +
 +offset = 4; /* End of length field */
 +prog   = tvb_get_ntohl(tvb, offset); offset += 4;
 +offset += 4; /* Ignore version header field */
 +proc   = tvb_get_ntohl(tvb, offset); offset += 4;
 +type   = tvb_get_ntohl(tvb, offset); offset += 4;
 +serial = tvb_get_ntohl(tvb, offset); offset += 4;
 +status = tvb_get_ntohl(tvb, offset); offset += 4;
 +
 +col_add_fstr(pinfo-cinfo, COL_INFO, Prog=%s,
 + val_to_str(prog, program_strings, %x));
 +
 +vs = get_program_data(prog, VIR_PROGRAM_PROCSTRINGS);
 +if (vs == NULL) {
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Proc=%u, proc);
 +} else {
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Proc=%s, 
 val_to_str(proc, vs, %d));
 +}
 +
 +col_append_fstr(pinfo-cinfo, COL_INFO,  Type=%s Serial=%u 
 Status=%s,
 +val_to_str(type, type_strings, %d), serial,
 +val_to_str(status, status_strings, %d));
 +
 +if (tree) {
 +gint hf_proc;
 +proto_item *ti;
 +proto_tree *libvirt_tree;
 +
 +ti = proto_tree_add_item(tree, proto_libvirt, tvb, 0, 
 tvb_length(tvb), ENC_NA);
 +libvirt_tree = proto_item_add_subtree(ti, ett_libvirt);
 +
 +offset = 0;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_length,  tvb, 
 offset, 4, ENC_NA); offset += 4;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_program, tvb, 
 offset, 4, ENC_NA); offset += 4;
 +proto_tree_add_item(libvirt_tree, hf_libvirt_version, tvb, 
 offset, 4, ENC_NA); offset += 4;
 +
 +hf_proc = *(int *)get_program_data(prog, VIR_PROGRAM_PROCHFVAR);

 There's a possible NULL dereference here. get_program might return NULL in 
 case @prog is not one of REMOTE, QEMU, LXC, KEEPALIVE. This can possibly 
 happen and it did for me indeed:

 Program terminated with signal 11, Segmentation fault.
 #0  0x7fac1cc60a86 in dissect_libvirt_message (tvb=0x387acc0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:396
 396 hf_proc = *(int *)get_program_data(prog, 
 VIR_PROGRAM_PROCHFVAR);
 (gdb) bt
 #0  0x7fac1cc60a86 in dissect_libvirt_message (tvb=0x387acc0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:396
 #1  0x0034469198fe in tcp_dissect_pdus () from 
 /usr/lib64/libwireshark.so.3
 #2  0x7fac1cc60c0c in dissect_libvirt (tvb=0x3879aa0, 
 pinfo=0x7fffb9a03100, tree=0x3883090) at packet-libvirt.c:424
 #3  0x0034462dff54 in ?? () from /usr/lib64/libwireshark.so.3
 #4  0x0034462e0608 in ?? () from 

Re: [libvirt] [PATCH V2 RESEND 8/8] lxc: allow to setup throttle blkio cgroup through virsh

2014-01-20 Thread Gao feng
On 01/20/2014 07:46 PM, Daniel P. Berrange wrote:
 On Mon, Jan 20, 2014 at 11:25:56AM +0800, Gao feng wrote:
 On 12/20/2013 12:34 AM, Daniel P. Berrange wrote:
 On Fri, Dec 13, 2013 at 11:09:01AM +0800, Gao feng wrote:
 With this patch,user can set throttle blkio cgroup for
 lxc domain through virsh tool.

 Signed-off-by: Guan Qiang hzguanqi...@corp.netease.com
 Signed-off-by: Gao feng gaof...@cn.fujitsu.com
 ---
  src/lxc/lxc_driver.c | 671 
 +--
  1 file changed, 646 insertions(+), 25 deletions(-)


 ACK

 @@ -4623,6 +5243,7 @@ static virDriver lxcDriver = {
  .name = LXC_DRIVER_NAME,
  .connectOpen = lxcConnectOpen, /* 0.4.2 */
  .connectClose = lxcConnectClose, /* 0.4.2 */
 +.connectSupportsFeature = lxcConnectSupportsFeature, /* 1.1.4 */

 But change this to 1.2.1



 So this should be 1.2.2 now, right?
 
 Yes, correct.
 

Thanks! change and pushed.

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


Re: [libvirt] [PATCH 1/8] rename virDomainBlkioDeviceWeightParseXML to virDomainBlkioDeviceParseXML

2014-01-20 Thread Gao feng
On 01/21/2014 12:50 AM, Eric Blake wrote:
 On 01/20/2014 09:44 AM, Eric Blake wrote:
 On 12/11/2013 01:29 AM, Gao feng wrote:
 virDomainBlkioDeviceWeightParseXML will be used to parse
 the xml element read_bps, write_bps, read_iops, write_iops.

 Signed-off-by: Gao feng gaof...@cn.fujitsu.com
 ---
  src/conf/domain_conf.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

 ACK.
 
 Oh, I never saw this get reviewed, but I see it has already been in
 libvirt.git for more than a month.  Sorry for the noise.
 

:) thanks for your ack

I just pushed this patchset.

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


[libvirt] [PATCH v3] virsh nodecpustats returns incorrect stats of cpu on Linux when the number of online cpu exceed 9.

2014-01-20 Thread mars
From: Bing Bu Cao m...@linux.vnet.ibm.com

To retrieve node cpu statistics on Linux system, the
linuxNodeGetCPUstats function simply uses STRPREFIX() to match the
cpuid with the cpuid read from /proc/stat, it will cause
obvious error.

For example:
'virsh nodecpustats 1' will display stats of cpu1* if the latter is online and 
cpu1 is offline.

This patch fixes this bug.

Signed-off-by: Bing Bu Cao m...@linux.vnet.ibm.com
---
 src/nodeinfo.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 05bc038..cf6d29b 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -691,7 +691,7 @@ linuxNodeGetCPUStats(FILE *procstat,
 char line[1024];
 unsigned long long usr, ni, sys, idle, iowait;
 unsigned long long irq, softirq, steal, guest, guest_nice;
-char cpu_header[3 + INT_BUFSIZE_BOUND(cpuNum)];
+char cpu_header[4 + INT_BUFSIZE_BOUND(cpuNum)];
 
 if ((*nparams) == 0) {
 /* Current number of cpu stats supported by linux */
@@ -708,9 +708,9 @@ linuxNodeGetCPUStats(FILE *procstat,
 }
 
 if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) {
-strcpy(cpu_header, cpu);
+strcpy(cpu_header, cpu );
 } else {
-snprintf(cpu_header, sizeof(cpu_header), cpu%d, cpuNum);
+snprintf(cpu_header, sizeof(cpu_header), cpu%d , cpuNum);
 }
 
 while (fgets(line, sizeof(line), procstat) != NULL) {
-- 
1.7.7.6

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


Re: [libvirt] Exposing and calculating CPU APIC IDs (was Re: [Qemu-devel] [RFC 1/3] target-i386: moving registers of vmstate from cpu_exec_init() to x86_cpu_realizefn())

2014-01-20 Thread Chen Fan
On Mon, 2014-01-20 at 13:29 +0100, Igor Mammedov wrote:
 On Fri, 17 Jan 2014 17:13:55 -0200
 Eduardo Habkost ehabk...@redhat.com wrote:
 
  On Wed, Jan 15, 2014 at 03:37:04PM +0100, Igor Mammedov wrote:
   On Wed, 15 Jan 2014 20:24:01 +0800
   Chen Fan chen.fan.f...@cn.fujitsu.com wrote:
On Tue, 2014-01-14 at 11:40 +0100, Igor Mammedov wrote:
 On Tue, 14 Jan 2014 17:27:20 +0800
 Chen Fan chen.fan.f...@cn.fujitsu.com wrote:
 
  the intend of this patch is to register cpu vmstates with apic id 
  instead of cpu
  index, due to the property setting of apic_id is behind the cpu 
  initialization. so
  we move the registers of cpu vmstate from cpu_exec_init() to 
  x86_cpu_realizefn() to
  let the set apicid as the parameter.
  
  Signed-off-by: Chen Fan chen.fan.f...@cn.fujitsu.com
  ---
   exec.c| 5 +
   target-i386/cpu.c | 9 +
   2 files changed, 14 insertions(+)
  
  diff --git a/exec.c b/exec.c
  index 7e49e8e..9be5855 100644
  --- a/exec.c
  +++ b/exec.c
  @@ -438,7 +438,9 @@ CPUState *qemu_get_cpu(int index)
   void cpu_exec_init(CPUArchState *env)
   {
   CPUState *cpu = ENV_GET_CPU(env);
  +#if !defined(TARGET_I386)
   CPUClass *cc = CPU_GET_CLASS(cpu);
  +#endif
   CPUState *some_cpu;
   int cpu_index;
   
  @@ -460,6 +462,8 @@ void cpu_exec_init(CPUArchState *env)
   #if defined(CONFIG_USER_ONLY)
   cpu_list_unlock();
   #endif
  +
  +#if !defined(TARGET_I386)
   if (qdev_get_vmsd(DEVICE(cpu)) == NULL) {
   vmstate_register(NULL, cpu_index, vmstate_cpu_common, 
  cpu);
   }
  @@ -472,6 +476,7 @@ void cpu_exec_init(CPUArchState *env)
   if (cc-vmsd != NULL) {
   vmstate_register(NULL, cpu_index, cc-vmsd, cpu);
   }
  +#endif /* !TARGET_I386 */
   }
   
   #if defined(TARGET_HAS_ICE)
  diff --git a/target-i386/cpu.c b/target-i386/cpu.c
  index 967529a..dada6f6 100644
  --- a/target-i386/cpu.c
  +++ b/target-i386/cpu.c
  @@ -2552,6 +2552,7 @@ static void x86_cpu_apic_realize(X86CPU *cpu, 
  Error **errp)
   static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
   {
   CPUState *cs = CPU(dev);
  +CPUClass *cc = CPU_GET_CLASS(cs);
   X86CPU *cpu = X86_CPU(dev);
   X86CPUClass *xcc = X86_CPU_GET_CLASS(dev);
   CPUX86State *env = cpu-env;
  @@ -2615,6 +2616,14 @@ static void x86_cpu_realizefn(DeviceState 
  *dev, Error **errp)
   cpu_reset(cs);
   
   xcc-parent_realize(dev, local_err);
  +
  +if (qdev_get_vmsd(DEVICE(cs)) == NULL) {
  +vmstate_register(NULL, env-cpuid_apic_id, 
  vmstate_cpu_common, cs);
  +}
  +
  +if (cc-vmsd != NULL) {
  +vmstate_register(NULL, env-cpuid_apic_id, cc-vmsd, cs);
  +}
 how about doing it in common CPUclass.realize()
 you can use get_arch_id() for getting CPU id, it returns cpu_index by 
 default
 and apic_id for target-i386.

Thanks for your kind suggestion, does this mean we can directly move
vmstate_register to cpu_common_realizefn()? 
   yep, that is a gist of it.
   
   There is more to the issue with discontinuous CPUs, a lot of code still
   use cpu_index and the way it's allocated is not compatible with 
   discontinuous
   CPUs, so this issue should be fixed as well.
   
   Also you propose to use a raw apic id with CLI/user interface.
   I recall there were objections to it since APIC ID contains topology
   information and it's not trivial for user to get it right.
   The last idea that was discussed to fix it was not expose APIC ID to
   user but rather introduce QOM hierarchy like:
 /machine/node/N/socket/X/core/Y/thread/Z
   and use it in user interface as a means to specify an arbitrary CPU
   and let QEMU calculate APIC ID based on this path.
   
   But nobody took on implementing it yet.
  
  We're taking so long to get a decent interface implemented, that part of
  me is considering exposing the APIC ID directly like suggested before,
  and requiring libvirt to calculate topology-aware APIC IDs[1] to
  properly implement CPU hotplug (and possibly for other tasks).
 If you are speaking about 
 'qemu will core dump with -smp 254, sockets=2, cores=3, threads=2'
 http://patchwork.ozlabs.org/patch/301272/
 bug then it's limitation of ACPI implementation,
 I'm going to refactor it to use full APIC ids instead of using bitmap,
 so that we won't ever run into issue regardless of cpu supported CPU count.
 
  
  Another part of me is hoping that the libvirt developers ask us to
  please not do that, so I can use it as argument against exposing the
  APIC IDs directly the next time we discuss this.  :)
 
 why not try your  /machine/node/N/socket/X/core/Y/thread/Z idea first.
 It will benefit