[libvirt] [PATCH 5/5] block_resize: Expose the new API to virsh

2011-11-29 Thread Osier Yang
---
 tools/virsh.c   |   58 +++
 tools/virsh.pod |6 +
 2 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 6ed249b..27ecaf3 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6028,6 +6028,63 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd)
 return true;
 }
 
+/*
+ * blockresize command
+ */
+static const vshCmdInfo info_block_resize[] = {
+{help, N_(Resize block device of domain.)},
+{desc, N_(Resize block device of domain.)},
+{NULL, NULL}
+};
+
+static const vshCmdOptDef opts_block_resize[] = {
+{domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
+{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified source path or 
device 
+target shorthand of the block 
device)},
+{size, VSH_OT_INT, VSH_OFLAG_REQ, N_(New size of the block device in 
kilobytes, 
+   the size must be integer)},
+{NULL, 0, 0, NULL}
+};
+
+static bool
+cmdBlockResize(vshControl *ctl, const vshCmd *cmd)
+{
+virDomainPtr dom;
+const char *path = NULL;
+unsigned long long size = 0;
+unsigned int flags = 0;
+int ret = false;
+
+if (!vshConnectionUsability(ctl, ctl-conn))
+return false;
+
+if (vshCommandOptString(cmd, path, (const char **) path)  0) {
+vshError(ctl, %s, _(Path must not be empty));
+return false;
+}
+
+if (vshCommandOptULongLong(cmd, size, size)  0) {
+vshError(ctl, %s, _(Unable to parse integer));
+return false;
+}
+
+if (size  ULLONG_MAX / 1024) {
+vshError(ctl, _(Size must be less than %llu), ULLONG_MAX / 1024);
+return false;
+}
+
+if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+return false;
+
+if (virDomainBlockResize(dom, path, size, flags)  0) {
+vshError(ctl, _(Failed to resize block device '%s'), path);
+} else {
+vshPrint(ctl, _(Block device '%s' is resized), path);
+ret = true;
+}
+
+virDomainFree(dom);
+return ret;
+}
 
 /*
  * net-autostart command
@@ -14698,6 +14755,7 @@ static const vshCmdDef domManagementCmds[] = {
 {blkiotune, cmdBlkiotune, opts_blkiotune, info_blkiotune, 0},
 {blockpull, cmdBlockPull, opts_block_pull, info_block_pull, 0},
 {blockjob, cmdBlockJob, opts_block_job, info_block_job, 0},
+{blockresize, cmdBlockResize, opts_block_resize, info_block_resize, 0},
 #ifndef WIN32
 {console, cmdConsole, opts_console, info_console, 0},
 #endif
diff --git a/tools/virsh.pod b/tools/virsh.pod
index db872dd..a5758f4 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -583,6 +583,12 @@ If I--info is specified, the active job information on 
the specified
 disk will be printed.
 Ibandwidth can be used to set bandwidth limit for the active job.
 
+=item Bblockresize Idomain I--path I--size
+
+Resize a block device of domain while the domain is running, I--path
+specifies fully-qualified source path or device target shorthand of
+the block device, I--size specifies the new size in kilobytes.
+
 =item Bdominfo Idomain-id
 
 Returns basic information about the domain.
-- 
1.7.7.3

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


[libvirt] [PATCH 2/5] block_resize: Wire up the remote protocol

2011-11-29 Thread Osier Yang
---
 src/remote/remote_driver.c   |1 +
 src/remote/remote_protocol.x |   10 +-
 2 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index cc8f580..4a6da20 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4552,6 +4552,7 @@ static virDriver remote_driver = {
 .domainMigratePrepare = remoteDomainMigratePrepare, /* 0.3.2 */
 .domainMigratePerform = remoteDomainMigratePerform, /* 0.3.2 */
 .domainMigrateFinish = remoteDomainMigrateFinish, /* 0.3.2 */
+.domainBlockResize = remoteDomainBlockResize, /* 0.9.8 */
 .domainBlockStats = remoteDomainBlockStats, /* 0.3.2 */
 .domainBlockStatsFlags = remoteDomainBlockStatsFlags, /* 0.9.5 */
 .domainInterfaceStats = remoteDomainInterfaceStats, /* 0.3.2 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 5ea1114..0d53e7d 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -537,6 +537,13 @@ struct remote_domain_get_memory_parameters_ret {
 int nparams;
 };
 
+struct remote_domain_block_resize_args {
+remote_nonnull_domain dom;
+remote_nonnull_string disk;
+unsigned hyper size;
+unsigned int flags;
+};
+
 struct remote_domain_block_stats_args {
 remote_nonnull_domain dom;
 remote_nonnull_string path;
@@ -2564,7 +2571,8 @@ enum remote_procedure {
 REMOTE_PROC_DOMAIN_SNAPSHOT_NUM_CHILDREN = 246, /* autogen autogen 
priority:high */
 REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_CHILDREN_NAMES = 247, /* autogen autogen 
priority:high */
 REMOTE_PROC_DOMAIN_EVENT_DISK_CHANGE = 248, /* skipgen skipgen */
-REMOTE_PROC_DOMAIN_OPEN_GRAPHICS = 249 /* skipgen skipgen */
+REMOTE_PROC_DOMAIN_OPEN_GRAPHICS = 249, /* skipgen skipgen */
+REMOTE_PROC_DOMAIN_BLOCK_RESIZE = 250 /* autogen autogen */
 
 /*
  * Notice how the entries are grouped in sets of 10 ?
-- 
1.7.7.3

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


[libvirt] [PATCH 3/5] block_resize: Implement qemu monitor functions

2011-11-29 Thread Osier Yang
Implements functions for both HMP and QMP mode.

For HMP mode, qemu uses M as the units by default, so the passed sized
is divided by 1024.

For QMP mode, qemu uses Bytes as the units by default, the passed sized
is multiplied by 1024.

All of the monitor functions return -1 on failure, 0 on success, or -2 if
not supported.
---
 src/qemu/qemu_monitor.c  |   15 +++
 src/qemu/qemu_monitor.h  |5 +++--
 src/qemu/qemu_monitor_json.c |   32 
 src/qemu/qemu_monitor_json.h |4 +++-
 src/qemu/qemu_monitor_text.c |   33 +
 src/qemu/qemu_monitor_text.h |4 +++-
 6 files changed, 89 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 73e5ea9..6423bf7 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1307,6 +1307,21 @@ int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
 return ret;
 }
 
+int qemuMonitorBlockResize(qemuMonitorPtr mon,
+   const char *device,
+   unsigned long long size)
+{
+int ret;
+VIR_DEBUG(mon=%p, fd=%d, device=%p size=%llu,
+  mon, mon-fd, device, size);
+
+if (mon-json)
+ret = qemuMonitorJSONBlockResize(mon, device, size);
+else
+ret = qemuMonitorTextBlockResize(mon, device, size);
+
+return ret;
+}
 
 int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
   const char *password)
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 883e0aa..41b8da2 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -255,8 +255,9 @@ int qemuMonitorGetBlockStatsParamsNumber(qemuMonitorPtr mon,
 int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
   const char *dev_name,
   unsigned long long *extent);
-
-
+int qemuMonitorBlockResize(qemuMonitorPtr mon,
+   const char *device,
+   unsigned long long size);
 int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
   const char *password);
 int qemuMonitorSetPassword(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 56a62db..2ea5e48 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1775,6 +1775,38 @@ cleanup:
 return ret;
 }
 
+/* Return 0 on success, -1 on failure, or -2 if not supported. */
+int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
+   const char *device,
+   unsigned long long size)
+{
+int ret;
+virJSONValuePtr cmd;
+virJSONValuePtr reply = NULL;
+
+cmd = qemuMonitorJSONMakeCommand(block_resize,
+ s:device, device,
+ U:size, size * 1024,
+ NULL);
+if (!cmd)
+return -1;
+
+ret = qemuMonitorJSONCommand(mon, cmd, reply);
+
+if (ret == 0) {
+if (qemuMonitorJSONHasError(reply, CommandNotFound)) {
+ret = -2;
+goto cleanup;
+}
+
+ret = qemuMonitorJSONCheckError(cmd, reply);
+}
+
+cleanup:
+virJSONValueFree(cmd);
+virJSONValueFree(reply);
+return ret;
+}
 
 int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
   const char *password)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index f10d7d2..d31b32b 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -81,7 +81,9 @@ int qemuMonitorJSONGetBlockStatsParamsNumber(qemuMonitorPtr 
mon,
 int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
   const char *dev_name,
   unsigned long long *extent);
-
+int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
+   const char *device,
+   unsigned long long size);
 
 int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
   const char *password);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 5de4d24..728bea8 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1075,6 +1075,39 @@ int qemuMonitorTextGetBlockExtent(qemuMonitorPtr mon 
ATTRIBUTE_UNUSED,
 return -1;
 }
 
+/* Return 0 on success, -1 on failure, or -2 if not supported. */
+int qemuMonitorTextBlockResize(qemuMonitorPtr mon,
+   const char *device,
+   unsigned long long size)
+{
+char *cmd = NULL;
+char *reply = NULL;
+int ret = -1;
+
+if (virAsprintf(cmd, block_resize %s %llu,
+device, VIR_DIV_UP(size, 1024))  0) {
+virReportOOMError();
+goto cleanup;
+}
+
+if (qemuMonitorHMPCommand(mon, cmd, reply)  0) {
+

[libvirt] [PATCH 4/5] block_resize: Implement qemu driver method

2011-11-29 Thread Osier Yang
It requires the domain is running, otherwise fails. Resize to a lower
size is supported, but should be used with extreme caution.

In order to prohibit the size overflowing after multiplied by
1024. We do checking in the codes. For QMP mode, the default units
is Bytes, the passed size needs to be multiplied by 1024, however,
for HMP mode, the default units is Megabytes, the passed size
needs to be divided by 1024 then.
---
 src/qemu/qemu_driver.c |   91 
 1 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6cfdd1d..697182d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7055,6 +7055,96 @@ qemuGetSchedulerParameters(virDomainPtr dom,
VIR_DOMAIN_AFFECT_CURRENT);
 }
 
+/**
+ * Resize a block device while a guest is running. Resize to a lower size
+ * is supported, but should be used with extreme caution.  Note that it
+ * only supports to resize image files, it can't resize block devices
+ * like LVM volumes.
+ */
+static int
+qemuDomainBlockResize (virDomainPtr dom,
+   const char *path,
+   unsigned long long size,
+   unsigned int flags)
+{
+struct qemud_driver *driver = dom-conn-privateData;
+virDomainObjPtr vm;
+qemuDomainObjPrivatePtr priv;
+int ret = -1, i;
+char *device = NULL;
+virDomainDiskDefPtr disk = NULL;
+
+virCheckFlags(0, -1);
+
+if (size  ULLONG_MAX / 1024) {
+qemuReportError(VIR_ERR_INVALID_ARG,
+_(size must be less than %llu),
+ULLONG_MAX / 1024);
+return -1;
+}
+
+qemuDriverLock(driver);
+vm = virDomainFindByUUID(driver-domains, dom-uuid);
+qemuDriverUnlock(driver);
+
+if (!vm) {
+char uuidstr[VIR_UUID_STRING_BUFLEN];
+virUUIDFormat(dom-uuid, uuidstr);
+qemuReportError(VIR_ERR_NO_DOMAIN,
+_(no domain matching uuid '%s'), uuidstr);
+goto cleanup;
+}
+
+priv = vm-privateData;
+
+if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY)  0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+qemuReportError(VIR_ERR_OPERATION_INVALID,
+%s, _(domain is not running));
+goto endjob;
+}
+
+if ((i = virDomainDiskIndexByName(vm-def, path, false))  0) {
+qemuReportError(VIR_ERR_INVALID_ARG,
+_(invalid path: %s), path);
+goto cleanup;
+}
+disk = vm-def-disks[i];
+
+if (virAsprintf(device, %s%s, QEMU_DRIVE_HOST_PREFIX,
+disk-info.alias)  0) {
+virReportOOMError();
+goto endjob;
+}
+
+qemuDomainObjEnterMonitor(driver, vm);
+if (qemuMonitorBlockResize(priv-mon, device, size)  0) {
+qemuDomainObjExitMonitor(driver, vm);
+goto endjob;
+}
+qemuDomainObjExitMonitor(driver, vm);
+
+ret = 0;
+
+endjob:
+if (qemuDomainObjEndJob(driver, vm) == 0)
+vm = NULL;
+
+cleanup:
+VIR_FREE(device);
+if (vm)
+virDomainObjUnlock(vm);
+return ret;
+}
+
 /* This uses the 'info blockstats' monitor command which was
  * integrated into both qemu  kvm in late 2007.  If the command is
  * not supported we detect this and return the appropriate error.
@@ -10848,6 +10938,7 @@ static virDriver qemuDriver = {
 .domainSetSchedulerParameters = qemuSetSchedulerParameters, /* 0.7.0 */
 .domainSetSchedulerParametersFlags = qemuSetSchedulerParametersFlags, /* 
0.9.2 */
 .domainMigratePerform = qemudDomainMigratePerform, /* 0.5.0 */
+.domainBlockResize = qemuDomainBlockResize, /* 0.9.8 */
 .domainBlockStats = qemuDomainBlockStats, /* 0.4.1 */
 .domainBlockStatsFlags = qemuDomainBlockStatsFlags, /* 0.9.5 */
 .domainInterfaceStats = qemudDomainInterfaceStats, /* 0.4.1 */
-- 
1.7.7.3

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


[libvirt] [PATCH 1/5] block_resize: Define the new API

2011-11-29 Thread Osier Yang
The new API is named as virDomainBlockResize, intending to add
support for qemu monitor command block_resize (both HMP and QMP).

Similar with APIs like virDomainSetMemoryFlags, the units for
argument size is kilobytes.
---
 include/libvirt/libvirt.h.in |5 ++-
 src/driver.h |8 -
 src/libvirt.c|   68 ++
 src/libvirt_public.syms  |1 +
 4 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 0787f18..0ec4959 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1384,7 +1384,10 @@ int virDomainBlockPeek (virDomainPtr 
dom,
 size_t size,
 void *buffer,
 unsigned int flags);
-
+int virDomainBlockResize (virDomainPtr dom,
+  const char *disk,
+  unsigned long long size,
+  unsigned int flags);
 
 /** virDomainBlockInfo:
  *
diff --git a/src/driver.h b/src/driver.h
index 9e78257..015afc5 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -377,7 +377,12 @@ typedef int
  unsigned long long offset, size_t size,
  void *buffer,
  unsigned int flags);
-
+typedef int
+(*virDrvDomainBlockResize)
+(virDomainPtr domain,
+ const char *disk,
+ unsigned long long size,
+ unsigned int flags);
 typedef int
 (*virDrvDomainMemoryPeek)
 (virDomainPtr domain,
@@ -841,6 +846,7 @@ struct _virDriver {
 virDrvDomainMigratePrepare domainMigratePrepare;
 virDrvDomainMigratePerform domainMigratePerform;
 virDrvDomainMigrateFinish  domainMigrateFinish;
+virDrvDomainBlockResize domainBlockResize;
 virDrvDomainBlockStats  domainBlockStats;
 virDrvDomainBlockStatsFlags domainBlockStatsFlags;
 virDrvDomainInterfaceStats  domainInterfaceStats;
diff --git a/src/libvirt.c b/src/libvirt.c
index b428fe6..7efa4a3 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -7028,6 +7028,74 @@ error:
 }
 
 /**
+ * virDomainBlockResize:
+ * @dom: pointer to the domain object
+ * @disk: path to the block image, or shorthand
+ * @size: new size of the block image in kilobytes
+ * @flags: unused, always pass 0
+ *
+ * Note that this call may fail if the underlying virtualization hypervisor
+ * does not support it. And this call requires privileged access to the
+ * hypervisor.
+ *
+ * The @disk parameter is either an unambiguous source name of the
+ * block device (the source file='...'/ sub-element, such as
+ * /path/to/image), or (since 0.9.5) the device target shorthand
+ * (the target dev='...'/ sub-element, such as xvda).  Valid names
+ * can be found by calling virDomainGetXMLDesc() and inspecting
+ * elements within //domain/devices/disk.
+ *
+ * Resize a block device of domain while the domain is running.
+ *
+ * Returns: 0 in case of success or -1 in case of failure.
+ */
+
+int
+virDomainBlockResize (virDomainPtr dom,
+  const char *disk,
+  unsigned long long size,
+  unsigned int flags)
+{
+virConnectPtr conn;
+
+VIR_DOMAIN_DEBUG(dom, disk=%s, size=%llu, flags=%x, disk, size, flags);
+
+virResetLastError();
+
+if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
+virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
+virDispatchError(NULL);
+return -1;
+}
+conn = dom-conn;
+
+if (dom-conn-flags  VIR_CONNECT_RO) {
+virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+goto error;
+}
+
+if (!disk) {
+virLibDomainError(VIR_ERR_INVALID_ARG,
+   _(disk is NULL));
+goto error;
+}
+
+if (conn-driver-domainBlockResize) {
+int ret;
+ret =conn-driver-domainBlockResize(dom, disk, size, flags);
+if (ret  0)
+goto error;
+return ret;
+}
+
+virLibDomainError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+virDispatchError(dom-conn);
+return -1;
+}
+
+/**
  * virDomainMemoryPeek:
  * @dom: pointer to the domain object
  * @start: start of memory to peek
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 6ba1526..e78f353 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -502,6 +502,7 @@ LIBVIRT_0.9.8 {
 global:
 virConnectIsAlive;
 virConnectSetKeepAlive;
+virDomainBlockResize;
 } LIBVIRT_0.9.7;
 
 #  define new API here using predicted next version number 
-- 
1.7.7.3

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


[libvirt] [PATCH 0/5 v2] Support block device online resizing

2011-11-29 Thread Osier Yang
This patch series introduce new API virDomainBlockResize to expose
qemu monitor command block_size, which is for resizing the a block
device while the domain is running.

The prototype for the new API is:

int
virDomainBlockResize (virDomainPtr dom,
  const char *disk,
  unsigned long long size,
  unsigned int flags)

* @disk is the absolute source path or device target shorthand of
  the block device.

* The units for @size is kilobytes.

* @flags is unused currently.

[PATCH 1/5] block_resize: Define the new API
[PATCH 2/5] block_resize: Wire up the remote protocol
[PATCH 3/5] block_resize: Implement qemu monitor functions
[PATCH 4/5] block_resize: Implement qemu driver method
[PATCH 5/5] block_resize: Expose the new API to virsh

v1: http://www.redhat.com/archives/libvir-list/2011-July/msg01788.html

v1 ~ v2:
* Nearly just rebasing, with small improvements, nothing new except
  updating the API definitions to be consistent with commit 3ac26e26.

Regards,
Osier

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


[libvirt] [PATCH] virsh: Update docs for block related commands

2011-11-29 Thread Osier Yang
commit 3ac26e26 allows to lookup the disk via both target name
and source path. But virsh documents were not updated.
---
 tools/virsh.c   |   15 ++-
 tools/virsh.pod |   14 +-
 2 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 27ecaf3..94b5478 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1059,7 +1059,8 @@ static const vshCmdInfo info_domblkstat[] = {
 
 static const vshCmdOptDef opts_domblkstat[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
-{device, VSH_OT_DATA, VSH_OFLAG_REQ, N_(block device)},
+{device, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified source path or 
unique 
+  target name of the block 
device)},
 {human,  VSH_OT_BOOL, 0, N_(print a more human readable output)},
 {NULL, 0, 0, NULL}
 };
@@ -1637,7 +1638,8 @@ static const vshCmdInfo info_domblkinfo[] = {
 
 static const vshCmdOptDef opts_domblkinfo[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
-{device, VSH_OT_DATA, VSH_OFLAG_REQ, N_(block device)},
+{device, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified source path or 
unique target
+  name of the block device)},
 {NULL, 0, 0, NULL}
 };
 
@@ -5959,7 +5961,8 @@ static const vshCmdInfo info_block_pull[] = {
 
 static const vshCmdOptDef opts_block_pull[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
-{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified path of disk)},
+{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified source path or 
unique 
+target name of the disk)},
 {bandwidth, VSH_OT_DATA, VSH_OFLAG_NONE, N_(Bandwidth limit in MB/s)},
 {NULL, 0, 0, NULL}
 };
@@ -5983,7 +5986,8 @@ static const vshCmdInfo info_block_job[] = {
 
 static const vshCmdOptDef opts_block_job[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
-{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified path of disk)},
+{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified source path or 
unique
+target name of the disk)},
 {abort, VSH_OT_BOOL, VSH_OFLAG_NONE, N_(Abort the active job on the 
speficied disk)},
 {info, VSH_OT_BOOL, VSH_OFLAG_NONE, N_(Get active job information for 
the specified disk)},
 {bandwidth, VSH_OT_DATA, VSH_OFLAG_NONE, N_(Set the Bandwidth limit in 
MB/s)},
@@ -6039,7 +6043,8 @@ static const vshCmdInfo info_block_resize[] = {
 
 static const vshCmdOptDef opts_block_resize[] = {
 {domain, VSH_OT_DATA, VSH_OFLAG_REQ, N_(domain name, id or uuid)},
-{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified path of block 
device)},
+{path, VSH_OT_DATA, VSH_OFLAG_REQ, N_(Fully-qualified source path or 
unique 
+target name of the block 
device)},
 {size, VSH_OT_INT, VSH_OFLAG_REQ, N_(New size of the block device in 
kilobytes, 
the size must be integer)},
 {NULL, 0, 0, NULL}
diff --git a/tools/virsh.pod b/tools/virsh.pod
index a5758f4..61951e6 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -569,14 +569,16 @@ image has been pulled, the disk no longer depends on the 
backing image.
 It pulls data for the entire disk in the background, the process of the
 operation can be checked with Bblockjob.
 
-Ipath specifies fully-qualified path of the disk.
+Ipath specifies fully-qualified source path (source file='name'/) or
+unique target name (target dev='name'/) of the disk.
 Ibandwidth specifies copying bandwidth limit in Mbps.
 
 =item Bblockjob Idomain Ipath [I--abort] [I--info] [Ibandwidth]
 
 Manage active block operations.
 
-Ipath specifies fully-qualified path of the disk.
+Ipath specifies fully-qualified source path (source file='name'/) or
+unique target name (target dev='name'/) of the disk.
 If I--abort is specified, the active job on the specified disk will
 be aborted.
 If I--info is specified, the active job information on the specified
@@ -585,9 +587,11 @@ Ibandwidth can be used to set bandwidth limit for the 
active job.
 
 =item Bblockresize Idomain I--path I--size
 
-Resize a block device of domain while the domain is running, I--path
-specifies the absolute path of the block device, I--size specifies the
-new size in kilobytes
+Resize a block device of domain while the domain is running.
+
+Ipath specifies fully-qualified source path (source file='name'/) or
+unique target name (target dev='name'/) of the disk.
+I--size specifies the new size in kilobytes.
 
 =item Bdominfo Idomain-id
 
-- 
1.7.7.3

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


Re: [libvirt] [PATCH] Add 'Hybrid-Suspend' power management discovery for the host

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 03:07:29PM +0800, Daniel Veillard wrote:
 On Thu, Nov 24, 2011 at 02:22:41PM +0530, Srivatsa S. Bhat wrote:
  Some systems support a feature known as 'Hybrid-Suspend', apart from the
  usual system-wide sleep states such as Suspend-to-RAM (S3) or 
  Suspend-to-Disk
  (S4). Add the functionality to discover this power management feature and
  export it in the capabilities XML under the power_management tag.
  
  This addition was suggested in [1].
  
  References:
  1. http://www.redhat.com/archives/libvir-list/2011-November/msg01298.html
  
  Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com
  ---
  
   docs/formatcaps.html.in |   12 +++--
   docs/schemas/capability.rng |5 ++
   src/conf/capabilities.c |2 -
   src/util/util.c |   99 
  ++-
   src/util/util.h |8 ++-
   5 files changed, 88 insertions(+), 38 deletions(-)
  
  diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
  index ce6f9a6..c5fb925 100644
  --- a/docs/formatcaps.html.in
  +++ b/docs/formatcaps.html.in
  @@ -31,6 +31,7 @@ BIOS you will see/p
   lt;power_managementgt;
 lt;S3/gt;
 lt;S4/gt;
  +  lt;Hybrid-Suspend/gt;
   lt;power_management/gt;
 lt;/hostgt;/span
   
  @@ -70,11 +71,12 @@ the host platform, but other information may be 
  available, it shows the CPU arch
   topology, model name, and additional features which are not included in 
  the model but the
   CPU provides them. Features of the chip are shown within the feature block 
  (the block is
   similar to what you will find in a Xen fully virtualized domain 
  description). Further,
  -the power management features supported by the host are shown, such as 
  Suspend-to-RAM (S3)
  -and Suspend-to-Disk (S4). In case the query for power management features 
  succeeded but the
  -host does not support any such feature, then an empty 
  lt;power_management/gt;
  -tag will be shown. Otherwise, if the query itself failed, no such tag will
  -be displayed (i.e., there will not be any power_management block or empty 
  tag in the XML)./p
  +the power management features supported by the host are shown, such as 
  Suspend-to-RAM (S3),
  +Suspend-to-Disk (S4) and Hybrid-Suspend (a combination of S3 and S4).
  +In case the query for power management features succeeded but the host 
  does not support
  +any such feature, then an empty lt;power_management/gt; tag will be 
  shown. Otherwise,
  +if the query itself failed, no such tag will be displayed (i.e., there 
  will not be any
  +power_management block or empty tag in the XML)./p
   pThe second block (in blue) indicates the paravirtualization 
  support of the
   Xen support, you will see the os_type of xen to indicate a paravirtual
   kernel, then architecture information and potential features./p
  diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
  index 645769e..6cf2188 100644
  --- a/docs/schemas/capability.rng
  +++ b/docs/schemas/capability.rng
  @@ -121,6 +121,11 @@
   empty/
 /element
   /optional
  +optional
  +  element name='Hybrid-Suspend'
  +empty/
  +  /element
  +/optional
 /interleave
   /element
 /define
  diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
  index 87b60b0..8468861 100644
  --- a/src/conf/capabilities.c
  +++ b/src/conf/capabilities.c
  @@ -35,7 +35,7 @@
   #define VIR_FROM_THIS VIR_FROM_CAPABILITIES
   
   VIR_ENUM_IMPL(virHostPMCapability, VIR_HOST_PM_LAST,
  -  S3, S4)
  +  S3, S4, Hybrid-Suspend)
   
   /**
* virCapabilitiesNew:
  diff --git a/src/util/util.c b/src/util/util.c
  index ce697fb..ccd1a0e 100644
  --- a/src/util/util.c
  +++ b/src/util/util.c
  @@ -2623,47 +2623,50 @@ virTypedParameterArrayClear(virTypedParameterPtr 
  params, int nparams)
   }
   
   /**
  - * Get the Power Management Capabilities of the host system.
  - * The script 'pm-is-supported' (from the pm-utils package) is run
  - * to find out all the power management features supported by the host,
  - * such as Suspend-to-RAM (S3) and Suspend-to-Disk (S4).
  + * virDiscoverHostPMFeature:
  + * @bitmask: The bitmask which should be populated with the result of
  + *   the query
  + * @feature: The power management feature to check whether it is supported
  + *   by the host. Values could be:
  + *   VIR_HOST_PM_S3 for Suspend-to-RAM
  + *   VIR_HOST_PM_S4 for Suspend-to-Disk
  + *   VIR_HOST_PM_HYBRID_SUSPEND for Hybrid-Suspend
*
  - * @bitmask: Pointer to the bitmask which will be set appropriately to
  - *   indicate all the supported host power management features.
  + * Run the script 'pm-is-supported' (from the pm-utils package)
  + * to find out if @feature is supported by the host.
*
  - * Returns 0 if the query was successful, -1 upon 

Re: [libvirt] [PATCH] Add 'Hybrid-Suspend' power management discovery for the host

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 08:44:11AM +, Daniel P. Berrange wrote:
 On Tue, Nov 29, 2011 at 03:07:29PM +0800, Daniel Veillard wrote:
  On Thu, Nov 24, 2011 at 02:22:41PM +0530, Srivatsa S. Bhat wrote:
   Some systems support a feature known as 'Hybrid-Suspend', apart from the
   usual system-wide sleep states such as Suspend-to-RAM (S3) or 
   Suspend-to-Disk
   (S4). Add the functionality to discover this power management feature and
   export it in the capabilities XML under the power_management tag.
   
   This addition was suggested in [1].
   
   References:
   1. http://www.redhat.com/archives/libvir-list/2011-November/msg01298.html
   
   Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com
   ---
   
docs/formatcaps.html.in |   12 +++--
docs/schemas/capability.rng |5 ++
src/conf/capabilities.c |2 -
src/util/util.c |   99 
   ++-
src/util/util.h |8 ++-
5 files changed, 88 insertions(+), 38 deletions(-)
   
   diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
   index ce6f9a6..c5fb925 100644
   --- a/docs/formatcaps.html.in
   +++ b/docs/formatcaps.html.in
   @@ -31,6 +31,7 @@ BIOS you will see/p
lt;power_managementgt;
  lt;S3/gt;
  lt;S4/gt;
   +  lt;Hybrid-Suspend/gt;
lt;power_management/gt;
  lt;/hostgt;/span

   @@ -70,11 +71,12 @@ the host platform, but other information may be 
   available, it shows the CPU arch
topology, model name, and additional features which are not included in 
   the model but the
CPU provides them. Features of the chip are shown within the feature 
   block (the block is
similar to what you will find in a Xen fully virtualized domain 
   description). Further,
   -the power management features supported by the host are shown, such as 
   Suspend-to-RAM (S3)
   -and Suspend-to-Disk (S4). In case the query for power management 
   features succeeded but the
   -host does not support any such feature, then an empty 
   lt;power_management/gt;
   -tag will be shown. Otherwise, if the query itself failed, no such tag 
   will
   -be displayed (i.e., there will not be any power_management block or 
   empty tag in the XML)./p
   +the power management features supported by the host are shown, such as 
   Suspend-to-RAM (S3),
   +Suspend-to-Disk (S4) and Hybrid-Suspend (a combination of S3 and S4).
   +In case the query for power management features succeeded but the host 
   does not support
   +any such feature, then an empty lt;power_management/gt; tag will be 
   shown. Otherwise,
   +if the query itself failed, no such tag will be displayed (i.e., there 
   will not be any
   +power_management block or empty tag in the XML)./p
pThe second block (in blue) indicates the paravirtualization 
   support of the
Xen support, you will see the os_type of xen to indicate a paravirtual
kernel, then architecture information and potential features./p
   diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
   index 645769e..6cf2188 100644
   --- a/docs/schemas/capability.rng
   +++ b/docs/schemas/capability.rng
   @@ -121,6 +121,11 @@
empty/
  /element
/optional
   +optional
   +  element name='Hybrid-Suspend'
   +empty/
   +  /element
   +/optional
  /interleave
/element
  /define
   diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
   index 87b60b0..8468861 100644
   --- a/src/conf/capabilities.c
   +++ b/src/conf/capabilities.c
   @@ -35,7 +35,7 @@
#define VIR_FROM_THIS VIR_FROM_CAPABILITIES

VIR_ENUM_IMPL(virHostPMCapability, VIR_HOST_PM_LAST,
   -  S3, S4)
   +  S3, S4, Hybrid-Suspend)

/**
 * virCapabilitiesNew:
   diff --git a/src/util/util.c b/src/util/util.c
   index ce697fb..ccd1a0e 100644
   --- a/src/util/util.c
   +++ b/src/util/util.c
   @@ -2623,47 +2623,50 @@ virTypedParameterArrayClear(virTypedParameterPtr 
   params, int nparams)
}

/**
   - * Get the Power Management Capabilities of the host system.
   - * The script 'pm-is-supported' (from the pm-utils package) is run
   - * to find out all the power management features supported by the host,
   - * such as Suspend-to-RAM (S3) and Suspend-to-Disk (S4).
   + * virDiscoverHostPMFeature:
   + * @bitmask: The bitmask which should be populated with the result of
   + *   the query
   + * @feature: The power management feature to check whether it is 
   supported
   + *   by the host. Values could be:
   + *   VIR_HOST_PM_S3 for Suspend-to-RAM
   + *   VIR_HOST_PM_S4 for Suspend-to-Disk
   + *   VIR_HOST_PM_HYBRID_SUSPEND for Hybrid-Suspend
 *
   - * @bitmask: Pointer to the bitmask which will be set appropriately to
   - *   indicate all the supported host power 

Re: [libvirt] [PATCH v5 2/4] Add the remote protocol implementation for virNodeSuspendForDuration

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 03:12:26AM +0530, Srivatsa S. Bhat wrote:
 Implement the remote protocol for virNodeSuspendForDuration() API.
 
 Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com
 ---
 
  src/remote/remote_driver.c   |1 +
  src/remote/remote_protocol.x |   10 +-
  2 files changed, 10 insertions(+), 1 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH v5 1/4] Add a public API to invoke suspend/resume on the host

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 03:12:18AM +0530, Srivatsa S. Bhat wrote:
 Implement the public definitions for the new API
 virNodeSuspendForDuration() which will be subsequently used to
 do a timed suspend on the host.
 
 Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com
 ---
 
  include/libvirt/libvirt.h.in |   16 +++
  src/driver.h |6 
  src/libvirt.c|   61 
 ++
  src/libvirt_public.syms  |5 +++
  4 files changed, 88 insertions(+), 0 deletions(-)


ACK


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

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


Re: [libvirt] [PATCH 3/5] block_resize: Implement qemu monitor functions

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 04:27:34PM +0800, Osier Yang wrote:
 Implements functions for both HMP and QMP mode.
 
 For HMP mode, qemu uses M as the units by default, so the passed sized
 is divided by 1024.
 
 For QMP mode, qemu uses Bytes as the units by default, the passed sized
 is multiplied by 1024.
 
 All of the monitor functions return -1 on failure, 0 on success, or -2 if
 not supported.
 ---
  src/qemu/qemu_monitor.c  |   15 +++
  src/qemu/qemu_monitor.h  |5 +++--
  src/qemu/qemu_monitor_json.c |   32 
  src/qemu/qemu_monitor_json.h |4 +++-
  src/qemu/qemu_monitor_text.c |   33 +
  src/qemu/qemu_monitor_text.h |4 +++-
  6 files changed, 89 insertions(+), 4 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH v5 3/4] Implement the core API to suspend/resume the host

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 03:12:35AM +0530, Srivatsa S. Bhat wrote:
 Add the core functions that implement the functionality of the API.
 Suspend is done by using an asynchronous mechanism so that we can return
 the status to the caller before the host gets suspended. This asynchronous
 operation is achieved by suspending the host in a separate thread of
 execution. However, returning the status to the caller is only best-effort,
 but not guaranteed.
 
 To resume the host, an RTC alarm is set up (based on how long we want to
 suspend) before suspending the host. When this alarm fires, the host gets
 woken up.
 
 Suspend-to-RAM operation on a host running Linux can take upto more than 20
 seconds, depending on the load of the system. (Freezing of tasks, an operation
 preceding any suspend operation, is given up after a 20 second timeout).
 And Suspend-to-Disk can take even more time, considering the time required
 for compaction, creating the memory image and writing it to disk etc.
 So, we do not allow the user to specify a suspend duration of less than 60
 seconds, to be on the safer side, since we don't want to prematurely declare
 failure when we only had to wait for some more time.
 
 Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com
 ---
 
  src/Makefile.am   |1 
  src/libvirt.c |4 +
  src/libvirt_private.syms  |5 +
  src/lxc/lxc_driver.c  |2 
  src/qemu/qemu_driver.c|2 
  src/uml/uml_driver.c  |2 
  src/util/virnodesuspend.c |  269 
 +
  src/util/virnodesuspend.h |   36 ++
  src/xen/xen_driver.c  |2 
  9 files changed, 322 insertions(+), 1 deletions(-)
  create mode 100644 src/util/virnodesuspend.c
  create mode 100644 src/util/virnodesuspend.h

ACK

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

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


Re: [libvirt] [PATCH v5 4/4] Add virsh command to initiate suspend on the host

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 03:12:44AM +0530, Srivatsa S. Bhat wrote:
 Add a new command 'nodesuspend' to perform a timed suspend on the host.
 
 Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com
 ---
 
  tools/virsh.c   |   64 
 +++
  tools/virsh.pod |7 ++
  2 files changed, 71 insertions(+), 0 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH 4/5] block_resize: Implement qemu driver method

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 04:27:35PM +0800, Osier Yang wrote:
 It requires the domain is running, otherwise fails. Resize to a lower
 size is supported, but should be used with extreme caution.
 
 In order to prohibit the size overflowing after multiplied by
 1024. We do checking in the codes. For QMP mode, the default units
 is Bytes, the passed size needs to be multiplied by 1024, however,
 for HMP mode, the default units is Megabytes, the passed size
 needs to be divided by 1024 then.
 ---
  src/qemu/qemu_driver.c |   91 
 
  1 files changed, 91 insertions(+), 0 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH 1/5] block_resize: Define the new API

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 04:27:32PM +0800, Osier Yang wrote:
 The new API is named as virDomainBlockResize, intending to add
 support for qemu monitor command block_resize (both HMP and QMP).
 
 Similar with APIs like virDomainSetMemoryFlags, the units for
 argument size is kilobytes.
 ---
  include/libvirt/libvirt.h.in |5 ++-
  src/driver.h |8 -
  src/libvirt.c|   68 
 ++
  src/libvirt_public.syms  |1 +
  4 files changed, 80 insertions(+), 2 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH 5/5] block_resize: Expose the new API to virsh

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 04:27:36PM +0800, Osier Yang wrote:
 ---
  tools/virsh.c   |   58 
 +++
  tools/virsh.pod |6 +
  2 files changed, 64 insertions(+), 0 deletions(-)

ACK

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

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


Re: [libvirt] [PATCH 2/5] block_resize: Wire up the remote protocol

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 04:27:33PM +0800, Osier Yang wrote:
 ---
  src/remote/remote_driver.c   |1 +
  src/remote/remote_protocol.x |   10 +-
  2 files changed, 10 insertions(+), 1 deletions(-)

ACK


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

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


[libvirt] [PATCH RESEND] qemu: Honor the original properties of PCI device when detaching

2011-11-29 Thread Osier Yang
This patch fixes two problems:
1) The device will be reattached to host even if it's not
   managed, as there is a pciDeviceSetManaged.
2) The device won't be reattached to host with original
   driver properly. As it doesn't honor the device original
   properties which are maintained by driver-activePciHostdevs.
---
 src/qemu/qemu_hotplug.c |   17 +
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 96c0070..19e4a41 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1960,6 +1960,7 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver 
*driver,
 qemuDomainObjPrivatePtr priv = vm-privateData;
 int i, ret;
 pciDevice *pci;
+pciDevice *activePci;
 
 for (i = 0 ; i  vm-def-nhostdevs ; i++) {
 if (vm-def-hostdevs[i]-mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
@@ -2019,16 +2020,16 @@ int qemuDomainDetachHostPciDevice(struct qemud_driver 
*driver,
detach-source.subsys.u.pci.bus,
detach-source.subsys.u.pci.slot,
detach-source.subsys.u.pci.function);
-if (!pci)
-ret = -1;
-else {
-pciDeviceSetManaged(pci, detach-managed);
-pciDeviceListDel(driver-activePciHostdevs, pci);
-if (pciResetDevice(pci, driver-activePciHostdevs, NULL)  0)
+if (pci) {
+activePci = pciDeviceListSteal(driver-activePciHostdevs, pci);
+if (pciResetDevice(activePci, driver-activePciHostdevs, NULL))
+qemuReattachPciDevice(activePci, driver);
+else
 ret = -1;
-pciDeviceReAttachInit(pci);
-qemuReattachPciDevice(pci, driver);
 pciFreeDevice(pci);
+pciFreeDevice(activePci);
+} else {
+ret = -1;
 }
 
 if (qemuCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE) 
-- 
1.7.7.3

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


Re: [libvirt] [ PATCH v5 0/4] API to invoke S3/S4 on a host and also resume from within libvirt

2011-11-29 Thread Daniel Veillard
On Tue, Nov 29, 2011 at 03:12:07AM +0530, Srivatsa S. Bhat wrote:
 This patchset adds a new API to put a host to a suspended state
 (Suspend-to-RAM, Suspend-to-Disk or Hybrid-Suspend) and setup a timed resume
 to get the host back online, from within libvirt.
 This uses the RTC wakeup mechanism to set up a timer alarm before suspending
 the host, so that in-band resume is facilitated by the firing of the RTC
 alarm, which wakes up the host.
 
 This patch applies on top of the Hybrid-Suspend patch posted in [1].
[...]
 
 Srivatsa S. Bhat (4):
   Add a public API to invoke suspend/resume on the host
   Add the remote protocol implementation for virNodeSuspendForDuration
   Implement the core API to suspend/resume the host
   Add virsh command to initiate suspend on the host
 

  Okay I finally pushed this series. But all patches except 4/4 failed
to apply cleanly on git head, thay all also raised various make
syntax-check error, which I fixed in the standard way I think.
  The main issue is that patch 3/4 made make check fail all virshtest
for some reason (maybe the restricted PATH) the call to
virNodeSuspendInit() in virInitialize() was failing, an well in that
case nothing work. So I changed virNodeSuspendInit:
   - to not return -1 if virGetPMCapabilities() fails
   - only log an error if virGetPMCapabilities() fails and the
 effective user id is 0
   - initialize hostPMFeatures to 0 before checking

This code should probably still be revisited, because IMHO:
  - when run as non-root we should not expose suspend capabilities
that we may not be able to use as non-root (pm-suspend works
only as root for example, and pm-is-supported seems to work
differently as root or as non-root)
  - the error log was getting in the way of the virshtest checks
and we should probably not log error as non root.
  - I was tempted to not call virNodeSuspendInit() from virInitialize()
but I'm afraid the drivers code may rely on those data including
the lock being initialized.

So my changes certainly need reviews, but the first version is commited
now.

  Thanks, but in the future, please run make check and make syntax-check
on all commits before posting them to the list,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [ PATCH v5 0/4] API to invoke S3/S4 on a host and also resume from within libvirt

2011-11-29 Thread Srivatsa S. Bhat
On 11/29/2011 03:12 PM, Daniel Veillard wrote:

 On Tue, Nov 29, 2011 at 03:12:07AM +0530, Srivatsa S. Bhat wrote:
 This patchset adds a new API to put a host to a suspended state
 (Suspend-to-RAM, Suspend-to-Disk or Hybrid-Suspend) and setup a timed resume
 to get the host back online, from within libvirt.
 This uses the RTC wakeup mechanism to set up a timer alarm before suspending
 the host, so that in-band resume is facilitated by the firing of the RTC
 alarm, which wakes up the host.

 This patch applies on top of the Hybrid-Suspend patch posted in [1].
 [...]

 Srivatsa S. Bhat (4):
   Add a public API to invoke suspend/resume on the host
   Add the remote protocol implementation for virNodeSuspendForDuration
   Implement the core API to suspend/resume the host
   Add virsh command to initiate suspend on the host

 
   Okay I finally pushed this series. But all patches except 4/4 failed
 to apply cleanly on git head, thay all also raised various make
 syntax-check error, which I fixed in the standard way I think.
   The main issue is that patch 3/4 made make check fail all virshtest
 for some reason (maybe the restricted PATH) the call to
 virNodeSuspendInit() in virInitialize() was failing, an well in that
 case nothing work. So I changed virNodeSuspendInit:
- to not return -1 if virGetPMCapabilities() fails
- only log an error if virGetPMCapabilities() fails and the
  effective user id is 0
- initialize hostPMFeatures to 0 before checking
 
 This code should probably still be revisited, because IMHO:
   - when run as non-root we should not expose suspend capabilities
 that we may not be able to use as non-root (pm-suspend works
 only as root for example, and pm-is-supported seems to work
 differently as root or as non-root)
   - the error log was getting in the way of the virshtest checks
 and we should probably not log error as non root.
   - I was tempted to not call virNodeSuspendInit() from virInitialize()
 but I'm afraid the drivers code may rely on those data including
 the lock being initialized.
 
 So my changes certainly need reviews, but the first version is commited
 now.



Thanks a lot!

 
   Thanks, but in the future, please run make check and make syntax-check
 on all commits before posting them to the list,
 


Very sorry, it was an oversight from my side, caused by an eagerness to
quickly address all the review comments, to aid further reviews/pushing the
patches before the freeze deadline.
But in future, I will definitely remember to run all the sanity checks and
only then post patches. My sincere apologies for all the trouble I caused
because of that!

-- 
Regards,
Srivatsa S. Bhat
IBM Linux Technology Center

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


[libvirt] [PATCH RESEND] qemu: Do not free the device from activePciHostdevs if it's in use

2011-11-29 Thread Osier Yang
* src/qemu/qemu_hostdev.c (qemuDomainReAttachHostdevDevices):
pciDeviceListFree(pcidevs) in the end free()s the device even if
it's in use by other domain, which can cause rase.

How to reproduce:

script

virsh nodedev-dettach pci__00_19_0
virsh start test
virsh attach-device test hostdev.xml
virsh start test2

for i in {1..5}; do
echo [ -- ${i}th time --]
virsh nodedev-reattach pci__00_19_0
done

echo clean up
virsh destroy test
virsh nodedev-reattach pci__00_19_0
/script

Device pci__00_19_0 dettached

Domain test started

Device attached successfully

error: Failed to start domain test2
error: Requested operation is not valid: PCI device :00:19.0 is in use by 
domain test

[ -- 1th time --]
Device pci__00_19_0 re-attached

[ -- 2th time --]
Device pci__00_19_0 re-attached

[ -- 3th time --]
Device pci__00_19_0 re-attached

[ -- 4th time --]
Device pci__00_19_0 re-attached

[ -- 5th time --]
Device pci__00_19_0 re-attached

clean up
Domain test destroyed

Device pci__00_19_0 re-attached

The patch also fixes another problem, there won't be error like
qemuDomainReAttachHostdevDevices: Not reattaching active
device :00:19.0 in daemon log if some device is in active.
As pciResetDevice and pciReattachDevice won't be called for
the device anymore. This is sensiable as we already reported
error when preparing the device if it's active. Blindly trying
to pciResetDevice  pciReattachDevice on the device and getting
an error is just redundant.
---
 src/qemu/qemu_hostdev.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 9137388..60401f0 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -414,8 +414,10 @@ void qemuDomainReAttachHostdevDevices(struct qemud_driver 
*driver,
  */
 activeDev = pciDeviceListFind(driver-activePciHostdevs, dev);
 if (activeDev 
-STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev)))
+STRNEQ_NULLABLE(name, pciDeviceGetUsedBy(activeDev))) {
+pciDeviceListSteal(pcidevs, dev);
 continue;
+}
 
 /* pciDeviceListFree() will take care of freeing the dev. */
 pciDeviceListSteal(driver-activePciHostdevs, dev);
-- 
1.7.7.3

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


[libvirt] gdb works abnormally when debug the libvirt.

2011-11-29 Thread ShaoHe Feng
When I  to use gdb to check whether qemuMonitorJSONIOProcessEvent
processes the Event that I expect.

but the gdb works  abnormally.
I list the the position of the source file by gdb. It is the correct
functionqemuMonitorJSONIOProcessEvent.
However I set break point on this  position. then info b, it is the
wrong function qemuMonitorJSONIOProcess.

I debug my libvirt on Ubuntu 11.10 this time.But I have set  a break
point at this function on redhat 6.0 before, it can work well.

My gcc version is: gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
My gdb version is: GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08

here is the info:

(gdb) list qemu/qemu_monitor_json.c:88
83qemuMonitorJSONIOProcessEvent(qemuMonitorPtr mon,
84  virJSONValuePtr obj)
85{
86const char *type;
87int i;
88int findEventFlag = -1;
89VIR_DEBUG(mon=%p obj=%p, mon, obj);
90   
91type = virJSONValueObjectGetString(obj, event);
92if (!type) {



(gdb) b qemu/qemu_monitor_json.c:88
Breakpoint 5 at 0x4a18d4: file qemu/qemu_monitor_json.c, line 88.
(gdb) info b
Num Type   Disp Enb AddressWhat
5   breakpoint keep y   0x004a18d4 in
qemuMonitorJSONIOProcess at qemu/qemu_monitor_json.c:88
(gdb)

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

Re: [libvirt] gdb works abnormally when debug the libvirt.

2011-11-29 Thread Michal Privoznik
On 29.11.2011 11:32, ShaoHe Feng wrote:
 When I  to use gdb to check whether qemuMonitorJSONIOProcessEvent
 processes the Event that I expect.
 
 but the gdb works  abnormally.
 I list the the position of the source file by gdb. It is the correct
 functionqemuMonitorJSONIOProcessEvent.
 However I set break point on this  position. then info b, it is the
 wrong function qemuMonitorJSONIOProcess.
 
 I debug my libvirt on Ubuntu 11.10 this time.But I have set  a break
 point at this function on redhat 6.0 before, it can work well.
 
 My gcc version is: gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
 My gdb version is: GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
 
 here is the info:
 
 (gdb) list qemu/qemu_monitor_json.c:88
 83qemuMonitorJSONIOProcessEvent(qemuMonitorPtr mon,
 84  virJSONValuePtr obj)
 85{
 86const char *type;
 87int i;
 88int findEventFlag = -1;
 89VIR_DEBUG(mon=%p obj=%p, mon, obj);
 90   
 91type = virJSONValueObjectGetString(obj, event);
 92if (!type) {
 
 
 
 (gdb) b qemu/qemu_monitor_json.c:88
 Breakpoint 5 at 0x4a18d4: file qemu/qemu_monitor_json.c, line 88.
 (gdb) info b
 Num Type   Disp Enb AddressWhat
 5   breakpoint keep y   0x004a18d4 in
 qemuMonitorJSONIOProcess at qemu/qemu_monitor_json.c:88
 (gdb)
 
 

This may be caused by libvirtd being compiled with -O2; You want to turn
that off:
1) get libvirt sources, unpack them and cd unpacked sources
2) export CFLAGS='-O0'
3) ./autogen --system  make

Now you should have libvirtd in ./daemon/libvirtd; However, this is
libtool wrapper script. So you won't succeed running it directly (gdb
./daemon/libvirtd); I personally use attach: gdb -p $(pgrep libvirtd);
NB, you should shutdown your system libvirtd: service libvirtd shutdown

Michal

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


[libvirt] All virsh commands testing failed with git head

2011-11-29 Thread Osier Yang

Part of the error log is pasted, looks like it's caused by
the calling of virNodeSuspendInit in virInitialize.


cd tests; LIBVIRT_DEBUG=1 VIR_TEST_DEBUG=1 ./virshtest; cd -
TEST: virshtest
 1) virsh list (default)  ...
Offset 0
Expect [ ]
Actual [2011-11-29 18:44:38.153: 24448: info : libvirt version: 0.9.7
2011-11-29 18:44:38.153: 24448: error : virNodeSuspendInit:86 : Failed 
to get host power management features

 ]

... FAILED
 2) virsh list (custom)   ...
Offset 0
Expect [ ]
Actual [2011-11-29 18:44:38.180: 24463: info : libvirt version: 0.9.7
2011-11-29 18:44:38.180: 24463: error : virNodeSuspendInit:86 : Failed 
to get host power management features

 ]

... FAILED
 3) virsh nodeinfo (default)  ...
Offset 0
Expect [C]
Actual [2011-11-29 18:44:38.212: 24478: info : libvirt version: 0.9.7
2011-11-29 18:44:38.212: 24478: error : virNodeSuspendInit:86 : Failed 
to get host power management features

C]

... FAILED

Regards,
Osier

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


[libvirt] [PATCH] examples: Correct the example command to use testnode.xml

2011-11-29 Thread Osier Yang
 * s/-connection/-c/
 * Removes the redundant '/'.
 * Add absolute so that it's more clear.

Pushed under trivial rule.
---
 examples/xml/test/testnode.xml |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/examples/xml/test/testnode.xml b/examples/xml/test/testnode.xml
index adc5440..001e353 100644
--- a/examples/xml/test/testnode.xml
+++ b/examples/xml/test/testnode.xml
@@ -4,7 +4,7 @@
  of applications using libvirt. To use this with virsh, run something
  like:
 
-  virsh -connect test:path/to/this/dir/testnode.xml nodeinfo
+  virsh -c test://absolute/path/to/this/dir/testnode.xml nodeinfo
 
  --
   domain file=testdomfv0.xml/
-- 
1.7.7.3

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


Re: [libvirt] All virsh commands testing failed with git head

2011-11-29 Thread Daniel Veillard
On Tue, Nov 29, 2011 at 06:46:26PM +0800, Osier Yang wrote:
 Part of the error log is pasted, looks like it's caused by
 the calling of virNodeSuspendInit in virInitialize.
 

  Weird that worked for me , lemme recheck that everything went in ...

 cd tests; LIBVIRT_DEBUG=1 VIR_TEST_DEBUG=1 ./virshtest; cd -
 TEST: virshtest
  1) virsh list (default)  ...
 Offset 0
 Expect [ ]
 Actual [2011-11-29 18:44:38.153: 24448: info : libvirt version: 0.9.7
 2011-11-29 18:44:38.153: 24448: error : virNodeSuspendInit:86 :
 Failed to get host power management features
  ]

  Are you running the tests as root ?
If no, that's weird
If yes, do you have pm-utils package installed ?

  I think there is still some cleanups to do there, as I pointed in my
message about it, but I didn't expected failures like this

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] examples: Correct the example command to use testnode.xml

2011-11-29 Thread Daniel Veillard
On Tue, Nov 29, 2011 at 07:12:31PM +0800, Osier Yang wrote:
  * s/-connection/-c/
  * Removes the redundant '/'.
  * Add absolute so that it's more clear.
 
 Pushed under trivial rule.
 ---
  examples/xml/test/testnode.xml |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/examples/xml/test/testnode.xml b/examples/xml/test/testnode.xml
 index adc5440..001e353 100644
 --- a/examples/xml/test/testnode.xml
 +++ b/examples/xml/test/testnode.xml
 @@ -4,7 +4,7 @@
   of applications using libvirt. To use this with virsh, run something
   like:
  
 -  virsh -connect test:path/to/this/dir/testnode.xml nodeinfo
 +  virsh -c test://absolute/path/to/this/dir/testnode.xml nodeinfo

  Actually that's wrong :-)

  That mean the resource /path/to/this/dir/testnode.xml on the absolute
server, reached with test protocol from an URI perspective, so we need
at least and extra / because  server means local host:
  test:///absolute/path/to/this/dir/testnode.xml

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] [PATCH] lxc: Fix suspend/resume with freezer cgroup

2011-11-29 Thread Jiri Denemark
---
 src/util/cgroup.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index c8d1f33..71dedeb 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -1474,14 +1474,14 @@ int virCgroupGetCpuacctUsage(virCgroupPtr group, 
unsigned long long *usage)
 int virCgroupSetFreezerState(virCgroupPtr group, const char *state)
 {
 return virCgroupSetValueStr(group,
-VIR_CGROUP_CONTROLLER_CPU,
+VIR_CGROUP_CONTROLLER_FREEZER,
 freezer.state, state);
 }
 
 int virCgroupGetFreezerState(virCgroupPtr group, char **state)
 {
 return virCgroupGetValueStr(group,
-VIR_CGROUP_CONTROLLER_CPU,
+VIR_CGROUP_CONTROLLER_FREEZER,
 freezer.state, state);
 }
 
-- 
1.7.8.rc4

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


[libvirt] [libvirt-glib 1/5] Add various missing packages to libvirt-gobject-1.0.pc

2011-11-29 Thread Christophe Fergeau
---
 libvirt-gobject-1.0.pc.in |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libvirt-gobject-1.0.pc.in b/libvirt-gobject-1.0.pc.in
index 5442ba4..3141e87 100644
--- a/libvirt-gobject-1.0.pc.in
+++ b/libvirt-gobject-1.0.pc.in
@@ -6,7 +6,7 @@ includedir=@includedir@
 Name: libvirt-gobject
 Version: @VERSION@
 Description: libvirt GObject library
-Requires: gobject-2.0 libvirt-gconfig-1.0
+Requires: gio-2.0 gobject-2.0 libvirt-gconfig-1.0
 Libs: -L${libdir} -lvirt-gobject-1.0
-Libs.private: @LIBVIRT_LIBS@
+Requires.private: gthread-2.0 libvirt
 Cflags: -I${includedir}/libvirt-gobject-1.0
-- 
1.7.7.3

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


[libvirt] [libvirt-glib 4/5] Cleanup GIR generation rules

2011-11-29 Thread Christophe Fergeau
Remove some redundant arguments (--pkg seems unneeded when
--include is used), most include paths are unneeded, ...
---
 libvirt-gconfig/Makefile.am |8 +++-
 libvirt-glib/Makefile.am|4 +---
 libvirt-gobject/Makefile.am |5 +
 3 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 22259c3..b8f3605 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -116,17 +116,15 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la 
$(G_IR_SCANNER) Makefile.am
 --library=$(builddir)/libvirt-gconfig-1.0.la \
 --output $@ \
 -I$(top_srcdir) \
--I$(top_builddir) \
 $(LIBXML2_CFLAGS) \
 --verbose \
---pkg=gobject-2.0 \
 --c-include=libvirt-gconfig/libvirt-gconfig.h \
 --pkg-export=libvirt-gconfig-1.0 \
-   $(srcdir)/libvirt-gconfig.h \
+$(srcdir)/libvirt-gconfig.h \
 $(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
 $(GCONFIG_HEADER_FILES:%=$(srcdir)/%) \
-   $(builddir)/libvirt-gconfig-enum-types.c \
-   $(builddir)/libvirt-gconfig-enum-types.h
+$(builddir)/libvirt-gconfig-enum-types.c \
+$(builddir)/libvirt-gconfig-enum-types.h
 
 
 girdir = $(datadir)/gir-1.0
diff --git a/libvirt-glib/Makefile.am b/libvirt-glib/Makefile.am
index 0638a64..ae4070f 100644
--- a/libvirt-glib/Makefile.am
+++ b/libvirt-glib/Makefile.am
@@ -47,11 +47,9 @@ LibvirtGLib-1.0.gir: libvirt-glib-1.0.la $(G_IR_SCANNER) 
Makefile.am
 --identifier-prefix=GVir \
 --symbol-prefix=gvir \
 --library=$(builddir)/libvirt-glib-1.0.la \
---add-include-path=$(builddir) \
 --output $@ \
 -I$(top_srcdir) \
--I$(srcdir) \
---pkg=glib-2.0 \
+--verbose \
 --pkg=gthread-2.0 \
 --c-include=libvirt-glib/libvirt-glib.h \
 --pkg-export=libvirt-glib-1.0 \
diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 54907e7..5aa1080 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -130,14 +130,11 @@ LibvirtGObject-1.0.gir: libvirt-gobject-1.0.la 
$(G_IR_SCANNER) Makefile.am
 --identifier-prefix=GVir \
 --symbol-prefix=gvir \
 --library=$(builddir)/libvirt-gobject-1.0.la \
---add-include-path=$(top_builddir)/libvirt-glib \
---add-include-path=$(top_builddir)/libvirt-gconfig \
 --output $@ \
--I$(top_srcdir) \
 -I$(top_builddir) \
+-I$(top_srcdir) \
 $(LIBXML2_CFLAGS) \
 --verbose \
---pkg=gobject-2.0 \
 --pkg=gthread-2.0 \
 --c-include=libvirt-gobject/libvirt-gobject.h \
 --pkg-export=libvirt-gobject-1.0 \
-- 
1.7.7.3

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


[libvirt] [libvirt-glib 5/5] Fix make distcheck

2011-11-29 Thread Christophe Fergeau
libvirt-gconfig genum files are generated in $srcdir but g-ir-scanner
was told to look for them in $builddir which didn't work so well :)
---
 libvirt-gconfig/Makefile.am |6 ++
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index b8f3605..f40d32e 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -121,10 +121,8 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la 
$(G_IR_SCANNER) Makefile.am
 --c-include=libvirt-gconfig/libvirt-gconfig.h \
 --pkg-export=libvirt-gconfig-1.0 \
 $(srcdir)/libvirt-gconfig.h \
-$(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
-$(GCONFIG_HEADER_FILES:%=$(srcdir)/%) \
-$(builddir)/libvirt-gconfig-enum-types.c \
-$(builddir)/libvirt-gconfig-enum-types.h
+$(libvirt_gconfig_1_0_la_HEADERS:%=$(srcdir)/%) \
+$(libvirt_gconfig_1_0_la_SOURCES:%=$(srcdir)/%)
 
 
 girdir = $(datadir)/gir-1.0
-- 
1.7.7.3

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


[libvirt] [libvirt-glib 3/5] Fix GIR generation

2011-11-29 Thread Christophe Fergeau
Overriding PKG_CONFIG_PATH when generating LibvirtGObject-1.0.gir
is wrong since this means that if glib/gio/... are installed in
a prefix that is not one of the default pkg-config paths, then
they won't be found. PKG_CONFIG_PATH is overridden so that
g-ir-scanner can find LibvirtGLib-1.0 and LibvirtGConfig-1.0 in
the build tree. Since g-ir-scanner provides --include-uninstalled
for that purpose, use that instead.
---
 libvirt-gobject/Makefile.am |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 59d9b2d..54907e7 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -118,15 +118,15 @@ CLEANFILES = $(BUILT_SOURCES)
 if WITH_GOBJECT_INTROSPECTION
 
 LibvirtGObject-1.0.gir: libvirt-gobject-1.0.la $(G_IR_SCANNER) Makefile.am
-   $(AM_V_GEN)PKG_CONFIG_PATH=$(top_builddir) $(G_IR_SCANNER) \
+   $(AM_V_GEN)$(G_IR_SCANNER) \
 --quiet \
 --warn-all \
 --namespace LibvirtGObject \
 --nsversion 1.0 \
 --include GObject-2.0 \
 --include Gio-2.0 \
---include LibvirtGLib-1.0 \
---include LibvirtGConfig-1.0 \
+--include-uninstalled 
$(top_builddir)/libvirt-glib/LibvirtGLib-1.0.gir \
+--include-uninstalled 
$(top_builddir)/libvirt-gconfig/LibvirtGConfig-1.0.gir \
 --identifier-prefix=GVir \
 --symbol-prefix=gvir \
 --library=$(builddir)/libvirt-gobject-1.0.la \
-- 
1.7.7.3

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


[libvirt] [PATCH] virsh: Fix typos in man page

2011-11-29 Thread Jiri Denemark
---
 tools/virsh.pod |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index f5183b4..d94e599 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -977,7 +977,7 @@ Change the maximum memory allocation limit for a guest 
domain.
 If I--live is specified, affect a running guest.
 If I--config is specified, affect the next boot of a persistent guest.
 If I--current is specified, affect the current guest state.
-Both I--live and I--current flags may be given, but I--current is
+Both I--live and I--config flags may be given, but I--current is
 exclusive. If no flag is specified, behavior is different depending
 on hypervisor.
 
@@ -1003,7 +1003,7 @@ I--min-guarantee is supported only by ESX hypervisor.
 If I--live is specified, affect a running guest.
 If I--config is specified, affect the next boot of a persistent guest.
 If I--current is specified, affect the current guest state.
-Both I--live and I--current flags may be given, but I--current is
+Both I--live and I--config flags may be given, but I--current is
 exclusive. If no flag is specified, behavior is different depending
 on hypervisor.
 
@@ -1048,7 +1048,7 @@ I--weight is in range [100, 1000].
 If I--live is specified, affect a running guest.
 If I--config is specified, affect the next boot of a persistent guest.
 If I--current is specified, affect the current guest state.
-Both I--live and I--current flags may be given, but I--current is
+Both I--live and I--config flags may be given, but I--current is
 exclusive. If no flag is specified, behavior is different depending
 on hypervisor.
 
-- 
1.7.8.rc4

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


Re: [libvirt] [PATCH] virsh: Fix typos in man page

2011-11-29 Thread Michal Privoznik
On 29.11.2011 12:45, Jiri Denemark wrote:
 ---
  tools/virsh.pod |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)
 

Seems like you caught all occurrences.
ACK

Michal

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


[libvirt] [PATCH 2/3] Make logging async signal safe wrt time stamp generation

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Use the new virTimeStringNow() API for generating log timestamps
in an async signal safe manner

* src/util/logging.c: Use virTimeStringNow
---
 src/util/logging.c |   28 
 1 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/src/util/logging.c b/src/util/logging.c
index 17c7e84..332716e 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -43,6 +43,7 @@
 #include buf.h
 #include threads.h
 #include virfile.h
+#include virtime.h
 
 #define VIR_FROM_THIS VIR_FROM_NONE
 
@@ -618,26 +619,6 @@ cleanup:
 return ret;
 }
 
-static char *
-virLogFormatTimestamp(void)
-{
-struct timeval cur_time;
-struct tm time_info;
-char *str = NULL;
-
-gettimeofday(cur_time, NULL);
-localtime_r(cur_time.tv_sec, time_info);
-time_info.tm_year += 1900;
-time_info.tm_mon += 1;
-
-if (virAsprintf(str, %4d-%02d-%02d %02d:%02d:%02d.%03d,
-time_info.tm_year, time_info.tm_mon, time_info.tm_mday,
-time_info.tm_hour, time_info.tm_min, time_info.tm_sec,
-(int) (cur_time.tv_usec / 1000))  0)
-return NULL;
-
-return str;
-}
 
 static int
 virLogFormatString(char **msg,
@@ -705,7 +686,7 @@ void virLogMessage(const char *category, int priority, 
const char *funcname,
 static bool logVersionStderr = true;
 char *str = NULL;
 char *msg = NULL;
-char *timestamp = NULL;
+char timestamp[VIR_TIME_STRING_BUFLEN];
 int fprio, i, ret;
 int saved_errno = errno;
 int emit = 1;
@@ -746,8 +727,8 @@ void virLogMessage(const char *category, int priority, 
const char *funcname,
 if (ret  0)
 goto cleanup;
 
-if (!(timestamp = virLogFormatTimestamp()))
-goto cleanup;
+if (virTimeStringNow(timestamp)  0)
+timestamp[0] = '\0';
 
 /*
  * Log based on defaults, first store in the history buffer,
@@ -799,7 +780,6 @@ void virLogMessage(const char *category, int priority, 
const char *funcname,
 
 cleanup:
 VIR_FREE(msg);
-VIR_FREE(timestamp);
 errno = saved_errno;
 }
 
-- 
1.7.6.4

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


[libvirt] [PATCH 0/3] Improve async signal safety of timestamp APIs

2011-11-29 Thread Daniel P. Berrange
There are rare reports of libvirt deadlocking itself which show a
fork'd, but not exec'd, child process stuck in localtime_r(). This
is because localtime_r() is not an async signal, so if we happened
to fork() at the exact time another thread was calling localtime_r()
we could get stuck with a stale lock in the child.

Although we go to pains to protect the libvirt logging code by
acquiring the mutex before forking, this is not sufficient, because
some non-logging related code could invoke virTimestamp() which
calls localtime_r() too.

The only sane approach to fix this is to make our timestamp
generation APIs thread safe, by doing a clean impl of gmtime()
and strftime() inside libvirt using static buffers and only async
safe POSIX apis.

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


[libvirt] [PATCH 3/3] Remove time APIs from src/util/util.h

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The virTimestamp and virTimeMs functions in src/util/util.h
duplicate functionality from virtime.h, in a non-async signal
safe manner. Remove them, and convert all code over to the new
APIs.

* src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
* src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
  src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
  src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
  virtime APIs
---
 src/libvirt_private.syms  |2 -
 src/lxc/lxc_driver.c  |3 +-
 src/qemu/qemu_domain.c|5 ++-
 src/qemu/qemu_driver.c|7 +++--
 src/qemu/qemu_migration.c |5 ++-
 src/qemu/qemu_process.c   |9 ---
 src/util/event_poll.c |9 ---
 src/util/util.c   |   53 -
 src/util/util.h   |4 ---
 9 files changed, 22 insertions(+), 75 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c90210d..b910d41 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1133,8 +1133,6 @@ virStrToLong_ul;
 virStrToLong_ull;
 virStrcpy;
 virStrncpy;
-virTimeMs;
-virTimestamp;
 virTrimSpaces;
 virTypedParameterArrayClear;
 virVasprintf;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 6f44d09..16bdfb9 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -56,6 +56,7 @@
 #include domain_nwfilter.h
 #include network/bridge_driver.h
 #include virnetdev.h
+#include virtime.h
 
 #define VIR_FROM_THIS VIR_FROM_LXC
 
@@ -1846,7 +1847,7 @@ static int lxcVmStart(virConnectPtr conn,
 virCommandSetErrorFD(cmd, logfd);
 
 /* Log timestamp */
-if ((timestamp = virTimestamp()) == NULL) {
+if ((timestamp = virTimeStringNewNow()) == NULL) {
 virReportOOMError();
 goto cleanup;
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d33d1d9..b28c734 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -36,6 +36,7 @@
 #include uuid.h
 #include virfile.h
 #include domain_event.h
+#include virtime.h
 
 #include sys/time.h
 #include fcntl.h
@@ -728,7 +729,7 @@ qemuDomainObjBeginJobInternal(struct qemud_driver *driver,
 
 priv-jobs_queued++;
 
-if (virTimeMs(now)  0)
+if (virTimeMillisNow(now)  0)
 return -1;
 then = now + QEMU_JOB_WAIT_TIME;
 
@@ -934,7 +935,7 @@ qemuDomainObjEnterMonitorInternal(struct qemud_driver 
*driver,
 
 qemuMonitorLock(priv-mon);
 qemuMonitorRef(priv-mon);
-ignore_value(virTimeMs(priv-monStart));
+ignore_value(virTimeMillisNow(priv-monStart));
 virDomainObjUnlock(obj);
 if (driver_locked)
 qemuDriverUnlock(driver);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 6cfdd1d..c22b678 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -88,6 +88,7 @@
 #include locking/lock_manager.h
 #include locking/domain_lock.h
 #include virkeycode.h
+#include virtime.h
 
 #define VIR_FROM_THIS VIR_FROM_QEMU
 
@@ -2200,12 +2201,12 @@ qemuDomainGetControlInfo(virDomainPtr dom,
 } else if (priv-job.active) {
 if (!priv-monStart) {
 info-state = VIR_DOMAIN_CONTROL_JOB;
-if (virTimeMs(info-stateTime)  0)
+if (virTimeMillisNow(info-stateTime)  0)
 goto cleanup;
 info-stateTime -= priv-job.start;
 } else {
 info-state = VIR_DOMAIN_CONTROL_OCCUPIED;
-if (virTimeMs(info-stateTime)  0)
+if (virTimeMillisNow(info-stateTime)  0)
 goto cleanup;
 info-stateTime -= priv-monStart;
 }
@@ -8586,7 +8587,7 @@ static int qemuDomainGetJobInfo(virDomainPtr dom,
  * of incoming migration which we don't currently
  * monitor actively in the background thread
  */
-if (virTimeMs(info-timeElapsed)  0)
+if (virTimeMillisNow(info-timeElapsed)  0)
 goto cleanup;
 info-timeElapsed -= priv-job.start;
 } else {
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8ae989a..8c4ecc8 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -42,6 +42,7 @@
 #include datatypes.h
 #include fdstream.h
 #include uuid.h
+#include virtime.h
 #include locking/domain_lock.h
 #include rpc/virnetsocket.h
 
@@ -866,7 +867,7 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver,
 memTotal);
 qemuDomainObjExitMonitorWithDriver(driver, vm);
 
-if (ret  0 || virTimeMs(priv-job.info.timeElapsed)  0) {
+if (ret  0 || virTimeMillisNow(priv-job.info.timeElapsed)  0) {
 priv-job.info.type = VIR_DOMAIN_JOB_FAILED;
 return -1;
 }
@@ -1098,7 +1099,7 @@ qemuMigrationPrepareAny(struct qemud_driver *driver,
 bool tunnel = !!st;
 char *origname = NULL;
 
-if (virTimeMs(now)  0)
+if (virTimeMillisNow(now)  0)
 return 

[libvirt] [PATCH 1/3] Add internal APIs for dealing with time

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The logging APIs need to be able to generate formatted timestamps
using only async signal safe functions. This rules out using
gmtime/localtime/malloc/gettimeday(!) and much more.

Introduce a new internal API which is async signal safe.

  virTimeMillisNow - replacement for gettimeofday. Uses clock_gettime
 where available, otherwise falls back to the unsafe
 gettimeofday

  virTimeFieldsNow  - replacements for gmtime(), convert a timestamp
  virTimeFieldsThen   into a broken out set of fields. No localtime()
  replacement is provided, because converting to
  local time is not practical with only async signal
  safe APIs.

  virTimeStringNow  - replacements for strftime() which print a timestamp
  virTimeStringThen   into a string, using a pre-determined format, with
  a fixed size buffer (VIR_TIME_STRING_BUFLEN)

  virTimeStringNewNow - alternative to above which malloc a string. Not
  virTimeStringNewThen  to be used in async signal safe scenarios.

* src/Makefile.am, src/util/virtime.c, src/util/virtime.h: New files
* src/libvirt_private.syms: New APis
* configure.ac: Check for clock_gettime in -lrt
* tests/virtimetest.c, tests/Makefile.am: Test new APIs
---
 configure.ac |   10 ++
 src/Makefile.am  |7 +-
 src/libvirt_private.syms |   11 ++
 src/util/virtime.c   |  290 ++
 src/util/virtime.h   |   50 
 tests/.gitignore |1 +
 tests/Makefile.am|9 ++-
 tests/virtimetest.c  |  124 
 8 files changed, 499 insertions(+), 3 deletions(-)
 create mode 100644 src/util/virtime.c
 create mode 100644 src/util/virtime.h
 create mode 100644 tests/virtimetest.c

diff --git a/configure.ac b/configure.ac
index e03e401..de2f379 100644
--- a/configure.ac
+++ b/configure.ac
@@ -147,6 +147,16 @@ LIBS=$LIBS $LIB_PTHREAD $LIBMULTITHREAD
 AC_CHECK_FUNCS([pthread_mutexattr_init])
 LIBS=$old_libs
 
+old_LIBS=$LIBS
+RT_LIBS=
+LIBS=$LIBS $LIB_PTHREAD -lrt
+AC_CHECK_FUNC([clock_gettime],[
+ AC_DEFINE([HAVE_CLOCK_GETTIME],[],[Defined if clock_gettime() exists in 
librt.so])
+ RT_LIBS=-lrt
+])
+LIBS=$old_libs
+AC_SUBST(RT_LIBS)
+
 dnl Availability of various common headers (non-fatal if missing).
 AC_CHECK_HEADERS([pwd.h paths.h regex.h sys/un.h \
   sys/poll.h syslog.h mntent.h net/ethernet.h linux/magic.h \
diff --git a/src/Makefile.am b/src/Makefile.am
index 33a32a8..872639f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,7 +97,8 @@ UTIL_SOURCES =
\
util/virnetdevtap.h util/virnetdevtap.c \
util/virnetdevveth.h util/virnetdevveth.c \
util/virnetdevvportprofile.h util/virnetdevvportprofile.c \
-   util/virsocketaddr.h util/virsocketaddr.c
+   util/virsocketaddr.h util/virsocketaddr.c \
+   util/virtime.h util/virtime.c
 
 EXTRA_DIST += $(srcdir)/util/virkeymaps.h $(srcdir)/util/keymaps.csv \
$(srcdir)/util/virkeycode-mapgen.py
@@ -561,7 +562,8 @@ libvirt_util_la_SOURCES =   
\
 libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
$(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS)
 libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
-   $(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS)
+   $(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
+   $(RT_LIBS)
 
 
 noinst_LTLIBRARIES += libvirt_conf.la
@@ -1500,6 +1502,7 @@ libvirt_lxc_LDFLAGS = $(WARN_CFLAGS) $(AM_LDFLAGS)
 libvirt_lxc_LDADD = $(CAPNG_LIBS) $(YAJL_LIBS) \
$(LIBXML_LIBS) $(NUMACTL_LIBS) $(THREAD_LIBS) \
$(LIBNL_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
+   $(RT_LIBS) \
../gnulib/lib/libgnu.la
 if WITH_DTRACE
 libvirt_lxc_LDADD += probes.o
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0b21cdc..c90210d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1380,6 +1380,17 @@ virKeycodeSetTypeFromString;
 virKeycodeValueFromString;
 virKeycodeValueTranslate;
 
+
+# virtime.h
+virTimeMillisNow;
+virTimeFieldsNow;
+virTimeFieldsThen;
+virTimeStringNow;
+virTimeStringThen;
+virTimeStringNewNow;
+virTimeStringNewThen;
+
+
 # xml.h
 virXMLParseHelper;
 virXMLPropString;
diff --git a/src/util/virtime.c b/src/util/virtime.c
new file mode 100644
index 000..c2d907f
--- /dev/null
+++ b/src/util/virtime.c
@@ -0,0 +1,290 @@
+/*
+ * virtime.c: Time handling functions
+ *
+ * Copyright (C) 2006-2011 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; 

Re: [libvirt] [PATCH] lxc: Fix suspend/resume with freezer cgroup

2011-11-29 Thread Michal Privoznik
On 29.11.2011 12:30, Jiri Denemark wrote:
 ---
  src/util/cgroup.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 

ACK

Michal

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


Re: [libvirt] [PATCH v2] virsh: Allow other escape characters for console

2011-11-29 Thread Michal Privoznik
On 24.11.2011 12:03, Michal Privoznik wrote:
 Currently virsh supports only ^] as escape character for console.
 However, some users might want to use something else. This patch
 creates such ability by specifying '-e' switch on virsh command
 line.
 ---
 diff to v1:
 -Eric's review included
 
  tools/console.c |   26 +-
  tools/console.h |4 +++-
  tools/virsh.c   |   40 +++-
  tools/virsh.pod |5 +
  4 files changed, 60 insertions(+), 15 deletions(-)
 

Ping?

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


Re: [libvirt] [libvirt-glib 2/5] Link libvirt-gobject with gthread

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 12:32:45PM +0100, Christophe Fergeau wrote:
 It uses GMutex so it needs to be linked with gthread
 ---
  libvirt-gobject/Makefile.am |   10 ++
  1 files changed, 6 insertions(+), 4 deletions(-)
 
 diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
 index ec7b454..59d9b2d 100644
 --- a/libvirt-gobject/Makefile.am
 +++ b/libvirt-gobject/Makefile.am
 @@ -64,15 +64,17 @@ libvirt_gobject_1_0_la_CFLAGS = \
   -DLIBVIRT_GOBJECT_BUILD \
   $(COVERAGE_CFLAGS) \
   -I$(top_srcdir) \
 - $(LIBVIRT_CFLAGS) \
 - $(GOBJECT2_CFLAGS) \
   $(GIO2_CFLAGS) \
 + $(GOBJECT2_CFLAGS) \
 + $(GTHREAD2_CFLAGS) \
 + $(LIBVIRT_CFLAGS) \
   $(LIBXML2_CFLAGS) \
   $(WARN_CFLAGS)
  libvirt_gobject_1_0_la_LIBADD = \
 - $(LIBVIRT_LIBS) \
 - $(GOBJECT2_LIBS) \
   $(GIO2_LIBS) \
 + $(GOBJECT2_LIBS) \
 + $(GTHREAD2_LIBS) \
 + $(LIBVIRT_LIBS) \
   ../libvirt-glib/libvirt-glib-1.0.la \
   ../libvirt-gconfig/libvirt-gconfig-1.0.la \
   $(CYGWIN_EXTRA_LIBADD)

ACK


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

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


Re: [libvirt] [libvirt-glib 1/5] Add various missing packages to libvirt-gobject-1.0.pc

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 12:32:44PM +0100, Christophe Fergeau wrote:
 ---
  libvirt-gobject-1.0.pc.in |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/libvirt-gobject-1.0.pc.in b/libvirt-gobject-1.0.pc.in
 index 5442ba4..3141e87 100644
 --- a/libvirt-gobject-1.0.pc.in
 +++ b/libvirt-gobject-1.0.pc.in
 @@ -6,7 +6,7 @@ includedir=@includedir@
  Name: libvirt-gobject
  Version: @VERSION@
  Description: libvirt GObject library
 -Requires: gobject-2.0 libvirt-gconfig-1.0
 +Requires: gio-2.0 gobject-2.0 libvirt-gconfig-1.0
  Libs: -L${libdir} -lvirt-gobject-1.0
 -Libs.private: @LIBVIRT_LIBS@
 +Requires.private: gthread-2.0 libvirt
  Cflags: -I${includedir}/libvirt-gobject-1.0

ACK


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

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


Re: [libvirt] [libvirt-glib 4/5] Cleanup GIR generation rules

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 12:32:47PM +0100, Christophe Fergeau wrote:
 Remove some redundant arguments (--pkg seems unneeded when
 --include is used), most include paths are unneeded, ...
 ---
  libvirt-gconfig/Makefile.am |8 +++-
  libvirt-glib/Makefile.am|4 +---
  libvirt-gobject/Makefile.am |5 +
  3 files changed, 5 insertions(+), 12 deletions(-)

ACK


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

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


Re: [libvirt] [libvirt-glib 3/5] Fix GIR generation

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 12:32:46PM +0100, Christophe Fergeau wrote:
 Overriding PKG_CONFIG_PATH when generating LibvirtGObject-1.0.gir
 is wrong since this means that if glib/gio/... are installed in
 a prefix that is not one of the default pkg-config paths, then
 they won't be found. PKG_CONFIG_PATH is overridden so that
 g-ir-scanner can find LibvirtGLib-1.0 and LibvirtGConfig-1.0 in
 the build tree. Since g-ir-scanner provides --include-uninstalled
 for that purpose, use that instead.
 ---
  libvirt-gobject/Makefile.am |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

ACK


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

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


Re: [libvirt] [libvirt-glib 5/5] Fix make distcheck

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 12:32:48PM +0100, Christophe Fergeau wrote:
 libvirt-gconfig genum files are generated in $srcdir but g-ir-scanner
 was told to look for them in $builddir which didn't work so well :)
 ---
  libvirt-gconfig/Makefile.am |6 ++
  1 files changed, 2 insertions(+), 4 deletions(-)
 
 diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
 index b8f3605..f40d32e 100644
 --- a/libvirt-gconfig/Makefile.am
 +++ b/libvirt-gconfig/Makefile.am
 @@ -121,10 +121,8 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la 
 $(G_IR_SCANNER) Makefile.am
  --c-include=libvirt-gconfig/libvirt-gconfig.h \
  --pkg-export=libvirt-gconfig-1.0 \
  $(srcdir)/libvirt-gconfig.h \
 -$(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
 -$(GCONFIG_HEADER_FILES:%=$(srcdir)/%) \
 -$(builddir)/libvirt-gconfig-enum-types.c \
 -$(builddir)/libvirt-gconfig-enum-types.h
 +$(libvirt_gconfig_1_0_la_HEADERS:%=$(srcdir)/%) \
 +$(libvirt_gconfig_1_0_la_SOURCES:%=$(srcdir)/%)

NACK, this isn't correct.

The enum files *are* generated in $builddir. The problem is that the
libvirt-gconfig/Makefile.am rules are causing the generatd files to
be included by make dist, so when you then unpack the dist you get
the enums in $srcdir instead. Take a look at libvirt-gobject/Makefile.am
which handles enums differently thus avoiding including them in the
dist.

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

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


Re: [libvirt] [PATCH 3/3] Remove time APIs from src/util/util.h

2011-11-29 Thread Jiri Denemark
On Tue, Nov 29, 2011 at 12:38:24 +, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The virTimestamp and virTimeMs functions in src/util/util.h
 duplicate functionality from virtime.h, in a non-async signal
 safe manner. Remove them, and convert all code over to the new
 APIs.
 
 * src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
 * src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
   src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
   src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
   virtime APIs
 ---
  src/libvirt_private.syms  |2 -
  src/lxc/lxc_driver.c  |3 +-
  src/qemu/qemu_domain.c|5 ++-
  src/qemu/qemu_driver.c|7 +++--
  src/qemu/qemu_migration.c |5 ++-
  src/qemu/qemu_process.c   |9 ---
  src/util/event_poll.c |9 ---
  src/util/util.c   |   53 
 -
  src/util/util.h   |4 ---
  9 files changed, 22 insertions(+), 75 deletions(-)
 
...
 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
 index d33d1d9..b28c734 100644
 --- a/src/qemu/qemu_domain.c
 +++ b/src/qemu/qemu_domain.c
 @@ -36,6 +36,7 @@
  #include uuid.h
  #include virfile.h
  #include domain_event.h
 +#include virtime.h
  
  #include sys/time.h
  #include fcntl.h
 @@ -728,7 +729,7 @@ qemuDomainObjBeginJobInternal(struct qemud_driver *driver,
  
  priv-jobs_queued++;
  
 -if (virTimeMs(now)  0)
 +if (virTimeMillisNow(now)  0)
  return -1;
  then = now + QEMU_JOB_WAIT_TIME;
  
...

This (and other similar ones in this patch) simple replacement won't work
since virTimeMs used to report libvirt error while virTimeMillisNow doesn't do
that. Thus in case of error (although it's not a frequent one)
qemuDomainObjBeginJobInternal would return -1 without reporting any error.


Jirka

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


Re: [libvirt] [PATCH] lxc: Fix suspend/resume with freezer cgroup

2011-11-29 Thread Jiri Denemark
On Tue, Nov 29, 2011 at 13:48:28 +0100, Michal Privoznik wrote:
 On 29.11.2011 12:30, Jiri Denemark wrote:
  ---
   src/util/cgroup.c |4 ++--
   1 files changed, 2 insertions(+), 2 deletions(-)
  
 
 ACK

Pushed, thanks.

Jirka

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


[libvirt] [PATCH] bandwidth: Fix funky identation

2011-11-29 Thread Michal Privoznik
---
Pushed under trivial rule

 src/util/virnetdevbandwidth.c |   40 
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
index 10db1ff..b9bd2e3 100644
--- a/src/util/virnetdevbandwidth.c
+++ b/src/util/virnetdevbandwidth.c
@@ -90,8 +90,8 @@ virNetDevBandwidthSet(const char *ifname,
 
 virCommandFree(cmd);
 cmd = virCommandNew(TC);
-virCommandAddArgList(cmd,class, add, dev, ifname, parent,
- 1:, classid, 1:1, htb, NULL);
+virCommandAddArgList(cmd,class, add, dev, ifname, parent,
+ 1:, classid, 1:1, htb, NULL);
 virCommandAddArgList(cmd, rate, average, NULL);
 
 if (peak)
@@ -104,9 +104,9 @@ virNetDevBandwidthSet(const char *ifname,
 
 virCommandFree(cmd);
 cmd = virCommandNew(TC);
-virCommandAddArgList(cmd,filter, add, dev, ifname, parent,
- 1:0, protocol, ip, handle, 1, fw,
- flowid, 1, NULL);
+virCommandAddArgList(cmd,filter, add, dev, ifname, parent,
+ 1:0, protocol, ip, handle, 1, fw,
+ flowid, 1, NULL);
 
 if (virCommandRun(cmd, NULL)  0)
 goto cleanup;
@@ -243,23 +243,23 @@ bool
 virNetDevBandwidthEqual(virNetDevBandwidthPtr a,
 virNetDevBandwidthPtr b)
 {
-if (!a  !b)
-return true;
+if (!a  !b)
+return true;
 
-if (!a || !b)
-return false;
+if (!a || !b)
+return false;
 
-/* in */
-if (a-in-average != b-in-average ||
-a-in-peak != b-in-peak ||
-a-in-burst != b-in-burst)
-return false;
+/* in */
+if (a-in-average != b-in-average ||
+a-in-peak != b-in-peak ||
+a-in-burst != b-in-burst)
+return false;
 
-/*out*/
-if (a-out-average != b-out-average ||
-a-out-peak != b-out-peak ||
-a-out-burst != b-out-burst)
-return false;
+/*out*/
+if (a-out-average != b-out-average ||
+a-out-peak != b-out-peak ||
+a-out-burst != b-out-burst)
+return false;
 
-return true;
+return true;
 }
-- 
1.7.3.4

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


Re: [libvirt] [PATCH] virsh: Fix typos in man page

2011-11-29 Thread Jiri Denemark
On Tue, Nov 29, 2011 at 13:00:22 +0100, Michal Privoznik wrote:
 On 29.11.2011 12:45, Jiri Denemark wrote:
  ---
   tools/virsh.pod |6 +++---
   1 files changed, 3 insertions(+), 3 deletions(-)
  
 
 Seems like you caught all occurrences.
 ACK

Thanks, pushed.

Jirka

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


Re: [libvirt] [libvirt-glib] Remove now redundant debug system

2011-11-29 Thread Daniel P. Berrange
On Mon, Nov 28, 2011 at 06:23:02PM +0200, Zeeshan Ali (Khattak) wrote:
 From: Zeeshan Ali (Khattak) zeesha...@gnome.org
 
 GLib = 2.31 filters debug messages by default now[1] and provides ways
 to output debug log from selected domains only. This patch won't be any
 good without defining proper fine-grained log domains though.
 
 http://blogs.gnome.org/mclasen/2011/11/09/better-logging/

NB, this results in all debug messages being enabled by default on any
glib  2.31 (which is basically all existing deployed versions). I have
a followup patch which fixes this problem

ACK

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

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


Re: [libvirt] [libvirt-glib] Ensure 'domain-added' signal on transient domain creation

2011-11-29 Thread Daniel P. Berrange
On Mon, Nov 28, 2011 at 07:37:16PM +0200, Zeeshan Ali (Khattak) wrote:
 From: Zeeshan Ali (Khattak) zeesha...@gnome.org
 
 ---
  libvirt-gobject/libvirt-gobject-connection.c |   10 --
  1 files changed, 8 insertions(+), 2 deletions(-)
 
 diff --git a/libvirt-gobject/libvirt-gobject-connection.c 
 b/libvirt-gobject/libvirt-gobject-connection.c
 index a258847..02b54a1 100644
 --- a/libvirt-gobject/libvirt-gobject-connection.c
 +++ b/libvirt-gobject/libvirt-gobject-connection.c
 @@ -264,6 +264,7 @@ static int domain_event_cb(virConnectPtr conn 
 G_GNUC_UNUSED,
  GVirConnection *gconn = opaque;
  GVirDomain *gdom;
  GVirConnectionPrivate *priv = gconn-priv;
 +gboolean was_unknown = FALSE;
  
  if (virDomainGetUUIDString(dom, uuid)  0) {
  g_warning(Failed to get domain UUID on %p, dom);
 @@ -282,6 +283,8 @@ static int domain_event_cb(virConnectPtr conn 
 G_GNUC_UNUSED,
  g_mutex_lock(priv-lock);
  g_hash_table_insert(priv-domains, 
 (gpointer)gvir_domain_get_uuid(gdom), gdom);
  g_mutex_unlock(priv-lock);
 +
 +was_unknown = TRUE;
  }
  
  switch (event) {
 @@ -307,9 +310,12 @@ static int domain_event_cb(virConnectPtr conn 
 G_GNUC_UNUSED,
  break;
  
  case VIR_DOMAIN_EVENT_STARTED:
 -if (detail == VIR_DOMAIN_EVENT_STARTED_BOOTED)
 +if (detail == VIR_DOMAIN_EVENT_STARTED_BOOTED) {
 +if (was_unknown)
 +/* Most probably a transient domain */
 +g_signal_emit(gconn, signals[VIR_DOMAIN_ADDED], 0, gdom);
  g_signal_emit_by_name(gdom, started::booted);
 -else if (detail == VIR_DOMAIN_EVENT_STARTED_MIGRATED)
 +} else if (detail == VIR_DOMAIN_EVENT_STARTED_MIGRATED)
  g_signal_emit_by_name(gdom, started::migrated);
  else if (detail == VIR_DOMAIN_EVENT_STARTED_RESTORED)
  g_signal_emit_by_name(gdom, started::restored);
 -- 

ACK

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

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


[libvirt] [PATCH libvirt-glib] Ensure debug defaults to off for all glib versions

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The previous patch changed all code to directly call g_debug().
This relies on the fact that glib = 2.31 defaults to not
printing debug messages. The result is that for older glib we
now pollute the stderr with debug messages.

This introduces 3 env vars for controlling libvirt debug,
though on glib = 2.31 the standard G_LOG_MESSAGES env can
be used instead.

* libvirt-glib/libvirt-glib-main.c: Check for LIBVIRT_GLIB_DEBUG
  env var
* libvirt-gobject/libvirt-gobject-main.c: Check for
  LIBVIRT_GOBJECT_DEBUG env var
* libvirt-gconfig/libvirt-gconfig-main.c: Check for
  LIBVIRT_GCONFIG_DEBUG env var
* libvirt-gconfig/libvirt-gconfig-main.h, libvirt-gconfig/libvirt-gconfig.h,
  libvirt-gconfig/libvirt-gconfig.sym: Add new files
* libvirt-gconfig/Makefile.am, libvirt-glib/Makefile.am,
  libvirt-gobject/Makefile.am: Set a default G_LOG_DOMAIN to
  allow filtering the library messages
---
 libvirt-gconfig/Makefile.am|3 +
 libvirt-gconfig/libvirt-gconfig-main.c |   85 
 libvirt-gconfig/libvirt-gconfig-main.h |   41 +++
 libvirt-gconfig/libvirt-gconfig.h  |1 +
 libvirt-gconfig/libvirt-gconfig.sym|5 ++-
 libvirt-glib/Makefile.am   |1 +
 libvirt-glib/libvirt-glib-main.c   |   25 +
 libvirt-gobject/Makefile.am|1 +
 libvirt-gobject/libvirt-gobject-main.c |   27 ++
 9 files changed, 188 insertions(+), 1 deletions(-)
 create mode 100644 libvirt-gconfig/libvirt-gconfig-main.c
 create mode 100644 libvirt-gconfig/libvirt-gconfig-main.h

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 22259c3..55f0aed 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -9,6 +9,7 @@ lib_LTLIBRARIES = libvirt-gconfig-1.0.la
 
 GCONFIG_HEADER_FILES = \
libvirt-gconfig.h \
+   libvirt-gconfig-main.h \
libvirt-gconfig-object.h \
libvirt-gconfig-capabilities.h \
libvirt-gconfig-domain.h \
@@ -37,6 +38,7 @@ noinst_HEADERS = \
libvirt-gconfig-object-private.h
 GCONFIG_SOURCE_FILES = \
libvirt-gconfig-object.c \
+   libvirt-gconfig-main.c \
libvirt-gconfig-capabilities.c \
libvirt-gconfig-domain.c \
libvirt-gconfig-domain-clock.c \
@@ -69,6 +71,7 @@ libvirt_gconfig_1_0_la_SOURCES = \
$(GCONFIG_SOURCE_FILES) \
$(builddir)/libvirt-gconfig-enum-types.c
 libvirt_gconfig_1_0_la_CFLAGS = \
+   -DG_LOG_DOMAIN=\Libvirt.GConfig\ \
-DDATADIR=\$(datadir)\ \
-DLIBVIRT_GCONFIG_BUILD \
$(COVERAGE_CFLAGS) \
diff --git a/libvirt-gconfig/libvirt-gconfig-main.c 
b/libvirt-gconfig/libvirt-gconfig-main.c
new file mode 100644
index 000..eb3732f
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-main.c
@@ -0,0 +1,85 @@
+/*
+ * libvirt-gconfig-main.c: libvirt gconfig integration
+ *
+ * Copyright (C) 2008 Daniel P. Berrange
+ * Copyright (C) 2010 Red Hat
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Author: Daniel P. Berrange berra...@redhat.com
+ */
+
+#include config.h
+
+#include stdlib.h
+#include stdio.h
+
+#include libvirt-glib/libvirt-glib.h
+#include libvirt-gconfig/libvirt-gconfig.h
+
+/**
+ * gvir_init_config:
+ * @argc: (inout): pointer to application's argc
+ * @argv: (inout) (array length=argc) (allow-none): pointer to application's 
argv
+ */
+void gvir_init_config(int *argc,
+  char ***argv)
+{
+GError *err = NULL;
+if (!gvir_init_config_check(argc, argv, err)) {
+g_error(Could not initialize libvirt-gconfig: %s\n,
+err-message);
+}
+}
+
+static void gvir_log_handler(const gchar *log_domain G_GNUC_UNUSED,
+ GLogLevelFlags log_level G_GNUC_UNUSED,
+ const gchar *message,
+ gpointer user_data)
+{
+if (user_data)
+fprintf(stderr, %s\n, message);
+}
+
+
+/**
+ * gvir_init_config_check:
+ * 

Re: [libvirt] [libvirt-glib 5/5] Fix make distcheck

2011-11-29 Thread Christophe Fergeau
On Tue, Nov 29, 2011 at 12:58:33PM +, Daniel P. Berrange wrote:
 On Tue, Nov 29, 2011 at 12:32:48PM +0100, Christophe Fergeau wrote:
  libvirt-gconfig genum files are generated in $srcdir but g-ir-scanner
  was told to look for them in $builddir which didn't work so well :)
  ---
   libvirt-gconfig/Makefile.am |6 ++
   1 files changed, 2 insertions(+), 4 deletions(-)
  
  diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
  index b8f3605..f40d32e 100644
  --- a/libvirt-gconfig/Makefile.am
  +++ b/libvirt-gconfig/Makefile.am
  @@ -121,10 +121,8 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la 
  $(G_IR_SCANNER) Makefile.am
   --c-include=libvirt-gconfig/libvirt-gconfig.h \
   --pkg-export=libvirt-gconfig-1.0 \
   $(srcdir)/libvirt-gconfig.h \
  -$(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
  -$(GCONFIG_HEADER_FILES:%=$(srcdir)/%) \
  -$(builddir)/libvirt-gconfig-enum-types.c \
  -$(builddir)/libvirt-gconfig-enum-types.h
  +$(libvirt_gconfig_1_0_la_HEADERS:%=$(srcdir)/%) \
  +$(libvirt_gconfig_1_0_la_SOURCES:%=$(srcdir)/%)
 
 NACK, this isn't correct.
 
 The enum files *are* generated in $builddir. The problem is that the
 libvirt-gconfig/Makefile.am rules are causing the generatd files to
 be included by make dist, so when you then unpack the dist you get
 the enums in $srcdir instead. Take a look at libvirt-gobject/Makefile.am
 which handles enums differently thus avoiding including them in the
 dist.

Ok, thanks a lot for the explanation. I'll post an updated patch, and
this hunk needs to go from the patch cleaning up gir generation:

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 7f57aa5..b14bd92 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -117,6 +117,7 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la
$(G_IR_SCANNER) Makefile.am
 --symbol-prefix=gvir \
 --library=$(builddir)/libvirt-gconfig-1.0.la \
 --output $@ \
--I$(top_builddir) \
 -I$(top_srcdir) \
 $(LIBXML2_CFLAGS) \
 --verbose \

Christophe



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

Re: [libvirt] [PATCH 3/3] Remove time APIs from src/util/util.h

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 02:10:20PM +0100, Jiri Denemark wrote:
 On Tue, Nov 29, 2011 at 12:38:24 +, Daniel P. Berrange wrote:
  From: Daniel P. Berrange berra...@redhat.com
  
  The virTimestamp and virTimeMs functions in src/util/util.h
  duplicate functionality from virtime.h, in a non-async signal
  safe manner. Remove them, and convert all code over to the new
  APIs.
  
  * src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
  * src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
virtime APIs
  ---
   src/libvirt_private.syms  |2 -
   src/lxc/lxc_driver.c  |3 +-
   src/qemu/qemu_domain.c|5 ++-
   src/qemu/qemu_driver.c|7 +++--
   src/qemu/qemu_migration.c |5 ++-
   src/qemu/qemu_process.c   |9 ---
   src/util/event_poll.c |9 ---
   src/util/util.c   |   53 
  -
   src/util/util.h   |4 ---
   9 files changed, 22 insertions(+), 75 deletions(-)
  
 ...
  diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
  index d33d1d9..b28c734 100644  --- a/src/qemu/qemu_domain.c
  +++ b/src/qemu/qemu_domain.c
  @@ -36,6 +36,7 @@
   #include uuid.h
   #include virfile.h
   #include domain_event.h
  +#include virtime.h
   
   #include sys/time.h
   #include fcntl.h
  @@ -728,7 +729,7 @@ qemuDomainObjBeginJobInternal(struct qemud_driver 
  *driver,
   
   priv-jobs_queued++;
   
  -if (virTimeMs(now)  0)
  +if (virTimeMillisNow(now)  0)
   return -1;
   then = now + QEMU_JOB_WAIT_TIME;
   
 ...
 
 This (and other similar ones in this patch) simple replacement won't work
 since virTimeMs used to report libvirt error while virTimeMillisNow doesn't do
 that. Thus in case of error (although it's not a frequent one)
 qemuDomainObjBeginJobInternal would return -1 without reporting any error.

Oh whoops. I guess I'll create a second variant (which isn't async
signal safe) which raises real errors to use in this scenario


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] [libvirt-glib] Fix make distcheck

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 02:44:19PM +0100, Christophe Fergeau wrote:
 Do not ship autogenerated glib enum definitions in the tarball,
 otherwise they won't get regenerated in the build directory when
 using a tarball, and rules trying to find these files in the build
 directory will fail (eg the gir generation rule)
 ---
  libvirt-gconfig/Makefile.am |6 --
  1 files changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
 index 4828fb9..b14bd92 100644
 --- a/libvirt-gconfig/Makefile.am
 +++ b/libvirt-gconfig/Makefile.am
 @@ -62,11 +62,13 @@ GCONFIG_SOURCE_FILES = \
  
  libvirt_gconfig_1_0_ladir = $(includedir)/libvirt-gconfig-1.0/libvirt-gconfig
  libvirt_gconfig_1_0_la_HEADERS = \
 - $(GCONFIG_HEADER_FILES) \
 + $(GCONFIG_HEADER_FILES)
 +nodist_libvirt_gconfig_1_0_la_HEADERS = \
   $(builddir)/libvirt-gconfig-enum-types.h
  libvirt_gconfig_1_0_la_SOURCES = \
   $(libvirt_gconfig_1_0_la_HEADERS) \
 - $(GCONFIG_SOURCE_FILES) \
 + $(GCONFIG_SOURCE_FILES)
 +nodist_libvirt_gconfig_1_0_la_SOURCES = \
   $(builddir)/libvirt-gconfig-enum-types.c
  libvirt_gconfig_1_0_la_CFLAGS = \
   -DDATADIR=\$(datadir)\ \

ACK looks good now

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

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


Re: [libvirt] Associate a LUN as disk with WWNN/WWPN

2011-11-29 Thread Osier Yang

On 2011年11月29日 05:48, Dave Allan wrote:

On Mon, Nov 28, 2011 at 09:41:12PM +, Daniel P. Berrange wrote:

On Mon, Nov 28, 2011 at 09:01:45AM -0500, Dave Allan wrote:

On Fri, Nov 25, 2011 at 10:49:29AM +, Daniel P. Berrange wrote:

On Fri, Nov 25, 2011 at 06:42:42PM +0800, Osier Yang wrote:

On 2011年11月25日 18:28, Daniel P. Berrange wrote:

On Fri, Nov 25, 2011 at 04:55:02PM +0800, Osier Yang wrote:



quote
AFAIU libvirt needs a way to:

- Associate a virtual adapter WWN with a VM (in the VM xml)
- Learn to start a virtual adapter when the VM is started, and destroy the
   adapter when the VM is stopped.
- Possibly a way to associate a WWN with a scsi pool, to start / stop a
   virtual adapter with the pool.
/quote

But afer thinking more, I'd think it might be not good idea:

As far as I could understand, the requirement of the BZ wants
a way to create/migrate a guest with NPIV. I'm goint to talk
create first,and migration then.


The desire to assocaite WWNN/WWPN with a VM is just one part of a more
general need to expand libvirt's SCSI support. Paulo started a design
thread on the subject a month or so back which sort of converged into
agreement:

https://www.redhat.com/archives/libvir-list/2011-October/msg01253.html



Yes, I read this thread before, but it looks to me Paolo was talking
about LUN, scsi host, and vHBA passthrough. It's a bit different
with what I'm trying to resolve (There is no passthrough here, but
about how to design a good workflow between virt-manager / Boxes
and libvirt for using (creating and migration ) a FC LUN as a normal
disk). The useful thing in the discussion of the thread may be
define the (v)HBA as a controller though.

Or I misunderstood something?


I've found that when people generally talk about associating iSCSI LUNs
with a guest, they have always been expecting SCSI LUN passthrough, or
passthrough of the entire iSCSI vHBA.


Agreed, and IMO we should implement that also, but I think that work
is divisible from the non-passthrough case, which is what we're
considering.


If we're considering a non-passthrough use case, then IMHO the problem
should be generalized to

   How do we associated a storage volume with a VM ?

ie not something that is specific to (i)SCSI.


I like the idea of associating a storage volume with a particular
block device on a VM.

So, what's your vision for how a VM would use storage that's visible
to a virtual WWN?  It sounds like you're saying that we should extend
SCSI pools to take WWNN, WWPN and fabric name, and then instantiate
the vHBA when the pool is started.  We'd then extend the domain disk
XML to take a pool/volume definition.  When the VM is started, we'd
check to see if the pool was active, if not, try to start it, and use
the resulting volume as described in the domain XML.  We'd have to
manage the wait for the volumes to show up, but we have to contend
with that regardless.  That's kind of a nice option in this use case
as it would allow administrators to bring the pool up ahead of domain
start if desired.

Is that right?


That's not really what I had in mind for storage pools. I expect that
the storage pool is configured by the mgmt app prior to creating the
guest. When creating the guest they just refer to a volume within the
pool. We shouldn't be auto-creating storage pools as a side effect of
starting guests IMHO.


I think we're saying the same thing--I was thinking the user/mgmt app
would create the pool, and starting the guest would start the pool if
it wasn't already started, if a volume in it was associated with the
VM.



I'd agree with danpb more, i.e. it shouldn't mix the storage pool
operation in domain's life. Both the storage and domain have public
APIs for use, if we auto-create/start the storage pool as a side
effect of domain starting, it probalbly means we need to call the
storage's public API internally inside domain's public API, another
way is to create some specific inernal storage functions for purpose,
but it doesn't make things any better IMHO. It just could bring
unexpected pain which we might suffer from in future, as the domain
and storage are standalone modules with the original design, though
I could't give an concrete proof now. Could anyone imagine it and
give a proof? :-)

Regards,
Osier

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

[libvirt] [libvirt-glib] Fix make distcheck

2011-11-29 Thread Christophe Fergeau
Do not ship autogenerated glib enum definitions in the tarball,
otherwise they won't get regenerated in the build directory when
using a tarball, and rules trying to find these files in the build
directory will fail (eg the gir generation rule)
---
 libvirt-gconfig/Makefile.am |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 4828fb9..b14bd92 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -62,11 +62,13 @@ GCONFIG_SOURCE_FILES = \
 
 libvirt_gconfig_1_0_ladir = $(includedir)/libvirt-gconfig-1.0/libvirt-gconfig
 libvirt_gconfig_1_0_la_HEADERS = \
-   $(GCONFIG_HEADER_FILES) \
+   $(GCONFIG_HEADER_FILES)
+nodist_libvirt_gconfig_1_0_la_HEADERS = \
$(builddir)/libvirt-gconfig-enum-types.h
 libvirt_gconfig_1_0_la_SOURCES = \
$(libvirt_gconfig_1_0_la_HEADERS) \
-   $(GCONFIG_SOURCE_FILES) \
+   $(GCONFIG_SOURCE_FILES)
+nodist_libvirt_gconfig_1_0_la_SOURCES = \
$(builddir)/libvirt-gconfig-enum-types.c
 libvirt_gconfig_1_0_la_CFLAGS = \
-DDATADIR=\$(datadir)\ \
-- 
1.7.7.3

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


[libvirt] [PATCH 1/2] error: drop old-style error reporting

2011-11-29 Thread Eric Blake
While we still don't want to enable gcc's new -Wformat-literal
warning, I found a rather easy case where the warning could be
reduced, by getting rid of obsolete error-reporting practices.
This is the last place where we were passing the (unused) net
and conn arguments for constructing an error.

* src/util/virterror_internal.h (virErrorMsg): Delete prototype.
(virReportError): Delete macro.
* src/util/virterror.c (virErrorMsg): Make static.
* src/libvirt_private.syms (virterror_internal.h): Drop export.
* src/util/conf.c (virConfError): Convert to macro.
(virConfErrorHelper): New function, and adjust error calls.
* src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
(xenHypervisorGetSchedulerType)
(xenHypervisorGetSchedulerParameters)
(xenHypervisorSetSchedulerParameters)
(xenHypervisorDomainBlockStats)
(xenHypervisorDomainInterfaceStats)
(xenHypervisorDomainGetOSType)
(xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
Update callers.
---
 src/libvirt_private.syms  |1 -
 src/util/conf.c   |   22 ++---
 src/util/virterror.c  |2 +-
 src/util/virterror_internal.h |8 --
 src/xen/xen_hypervisor.c  |  170 +
 5 files changed, 79 insertions(+), 124 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9f2a224..74412b0 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1370,7 +1370,6 @@ virSocketAddrSetPort;

 # virterror_internal.h
 virDispatchError;
-virErrorMsg;
 virRaiseErrorFull;
 virReportErrorHelper;
 virReportOOMErrorFull;
diff --git a/src/util/conf.c b/src/util/conf.c
index c8dcc7f..92bc84a 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -89,27 +89,23 @@ struct _virConf {
  *
  * Handle an error at the xend daemon interface
  */
+#define virConfError(ctxt, error, info) \
+virConfErrorHelper(__FILE__, __FUNCTION__, __LINE__, ctxt, error, info)
 static void
-virConfError(virConfParserCtxtPtr ctxt,
- virErrorNumber error, const char *info)
+virConfErrorHelper(const char *file, const char *func, size_t line,
+   virConfParserCtxtPtr ctxt,
+   virErrorNumber error, const char *info)
 {
-const char *format;
-
 if (error == VIR_ERR_OK)
 return;

 /* Construct the string 'filename:line: info' if we have that. */
 if (ctxt  ctxt-filename) {
-virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
-info, ctxt-filename, NULL,
-ctxt-line, 0,
-%s:%d: %s, ctxt-filename, ctxt-line, info);
+virReportErrorHelper(VIR_FROM_CONF, error, file, func, line,
+ _(%s:%d: %s), ctxt-filename, ctxt-line, info);
 } else {
-format = virErrorMsg(error, info);
-virRaiseError(NULL, NULL, VIR_FROM_CONF, error, VIR_ERR_ERROR,
-info, NULL, NULL,
-ctxt ? ctxt-line : 0, 0,
-format, info);
+virReportErrorHelper(VIR_FROM_CONF, error, file, func, line,
+ %s, info);
 }
 }

diff --git a/src/util/virterror.c b/src/util/virterror.c
index 44a276a..e2a0f3a 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -755,7 +755,7 @@ virRaiseErrorFull(const char *filename ATTRIBUTE_UNUSED,
  *
  * Returns the constant string associated to @error
  */
-const char *
+static const char *
 virErrorMsg(virErrorNumber error, const char *info)
 {
 const char *errmsg = NULL;
diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h
index d61ea0d..b8cb279 100644
--- a/src/util/virterror_internal.h
+++ b/src/util/virterror_internal.h
@@ -47,14 +47,6 @@ void virRaiseErrorFull(const char *filename,
const char *fmt, ...)
 ATTRIBUTE_FMT_PRINTF(12, 13);

-/* Includes 'dom' and 'net' for compatbility, but they're ignored */
-# define virRaiseError(dom, net, domain, code, level,  \
-  str1, str2, str3, int1, int2, msg, ...)   \
-virRaiseErrorFull(__FILE__, __FUNCTION__, __LINE__,   \
-  domain, code, level, str1, str2, str3, int1, int2, \
-  msg, __VA_ARGS__)
-
-const char *virErrorMsg(virErrorNumber error, const char *info);
 void virReportErrorHelper(int domcode, int errcode,
   const char *filename,
   const char *funcname,
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 870bc4f..ef64177 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -827,40 +827,6 @@ struct xenUnifiedDriver xenHypervisorDriver = {
  __FUNCTION__, __LINE__, __VA_ARGS__)

 /**
- * virXenErrorFunc:
- * @error: the error number
- * @func: the function failing
- * @info: extra information string
- * @value: extra information number
- *
- * Handle an error at the xend 

[libvirt] [PATCH 2/2] build: import latest gnulib, for mingw and syntax-check fixes

2011-11-29 Thread Eric Blake
Gnulib has picked up our fixes for openpty on mingw.  It has
also added support for a new gcc warning option,
-Wunsuffixed-float-constants, which was pretty easy to silence
(sometimes, using 'float' is more efficient than the default
of 'double' that you get for an unsuffixed constant).

* .gnulib: Update to latest, for openpty fixes, and improved
'make syntax-check' and compiler warnings.
* gnulib/local/lib/pty.in.h.diff: Delete, no longer needed.
* gnulib/local/lib/openpty.c.diff: Likewise.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS):
Re-silence -Wformat-nonliteral.
* src/fdstream.c (virFDStreamConnectUNIX): Suffix floating point
constants.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorOpenUnix): Likewise.
* src/qemu/qemu_monitor_json.c
(qemuMonitorJSONSetMigrationDowntime): Likewise.
* tools/virsh.c (cmdDomControl, cmdDominfo, cmdVcpuinfo)
(print_job_progress, DIFF_MSEC): Likewise.
* tests/testutils.c (DIFF_MSEC): Likewise.
---

* .gnulib e56e96f...908690c (79):
   hash: mark compute_bucket_size with the pure attribute
   quotearg, propername: correct pragma guard expression
   propername: do not mark proper_name with the const attribute
   propername: mark one more function as const
   mark functions with const and pure attributes
   Remove unused macros from !_LIBC code in glibc-borrowed files.
   getcwd: Fix link error on MSVC 9.
   Don't set REPLACE_FOO to 1 if HAVE_FOO is 0.
   getcwd: Fix bug from 2011-08-17.
   binary-io tests: Avoid test failure on mingw when libtool is used.
   Fix conflict between two instantiations of module 'unistd'.
   pagealign_alloc: Doc and comments.
   test-update-copyright.sh: avoid false-positive failure
   valgrind-tests.m4: Avoid breakage if valgrind on bash fails.
   test-stdalign.c: comment out long double tests
   init.sh: make compare /dev/null FILE output more readable
   init.sh: work around OSF/1 5.1's mishandling of /dev/null
   gnulib-common: Silence warnings against config.h code.
   autoupdate
   getcwd: Work around getcwd bug on AIX 5..7.
   getcwd: Fix bug from 2009-09-10.
   manywarnings: More warnings.
   fma tests: Avoid shadowing local variables.
   copysignf tests: Fix.
   fma: Remove unused code.
   sethostname: Fix doc about AIX.
   sethostname: Mention more portability problems.
   Depend on module fcntl-h when AT_FDCWD is used.
   euidaccess: Update a comment.
   openat: Fix file list.
   fstatat: Simplify.
   Ensure 'inline' can be used in tests/test-utimens-common.h.
   hash: Don't refer to deprecated interfaces.
   readline: Check for readline/history.h.
   test-getcwd: disambiguate exit status
   fstatat: fix configuration bug on mingw, OpenBSD 4, Solaris 8
   hash: deprecate poorly-named hash_insert0: use hash_insert_if_absent
   openat: avoid compilation failure due to lack of errno.h inclusion
   * modules/getcwd (Depends-on): Add fdopendir.
   modules/crypto/gc-*: simplify dependencies and fix stdalign.h bug
   tests: factor out st_ctime-comparison code (a dozen uses)
   test-getcwd: don't leave behind a confdir3/ directory upon interrupt
   gitlog-to-changelog: support multi-author commits.
   Fix some modules' file list.
   maint.mk: fix tight-scope.mk generation in VPATH builds.
   Silence successful tests that use 'compare' on AIX, HP-UX, Solaris.
   Makefile: Tweak indentation.
   Syntax check for copyright statements.
   Fix for last commit.
   git-version-gen: Add --prefix.
   git-version: Improve command line handling.
   revamp the other test-exclude?.sh scripts to use init.sh, too
   test-exclude2.sh, test-exclude5.sh: fail if test-exclude fails
   test-exclude: fix a typo
   autoupdate
   obstack: Fix compilation error on MSVC 9.
   test-exclude: skip tests rather than failing on deficient systems
   ptsname_r test: Avoid gcc warning on glibc systems.
   ptsname_r: Avoid compilation error on OSF/1 5.1.
   fstatat: Make cross-compilation guess succeed everywhere except on AIX.
   ptsname_r tests: Fix bugs.
   fstatat: work with cross-compilation
   Improve MODULES.html output.
   ptsname_r-tests: new test module
   update from texinfo
   ptsname_r: new module
   announce-gen: be more concise when there's only one URL+tarball
   openpty: provide a stub on mingw
   raise: fix mingw handling of SIGPIPE
   More conditional dependencies.
   faccessat: Move AC_LIBOBJ invocation to module description.
   faccessat: Simplify autoconf macro.
   renameat: Fix dependencies.
   mkfifoat: Fix module description.
   fstatat: Remove unused dependency.
   GNUmakefile: behave when Makefile is missing.
   openat: Conditionalize dependencies.
   maint.mk: extract GPG key ID without using a temporary file
   grantpt: fix typo

 .gnulib |2 +-
 gnulib/local/lib/openpty.c.diff |   26 --
 gnulib/local/lib/pty.in.h.diff  |   13 -
 m4/virt-compile-warnings.m4 |8 ++--
 src/fdstream.c  |2 +-
 

[libvirt] [PATCH 0/2] gnulib update

2011-11-29 Thread Eric Blake
The latest gnulib update accidentally reintroduced -Wformat-nonliteral
(by virtue of adding -Wformat=2, understood only by newer gcc), I
almost got sucked into the rathole of fixing all our problems before
I realized the real issue, but by then, I had already written patch 1.

I'd like to get this in before the freeze, and then (hopefully) not
touch .gnulib until after the release (we've been burned too many
times by a .gnulib update after rc1).

Eric Blake (2):
  error: drop old-style error reporting
  build: import latest gnulib, for mingw and syntax-check fixes

 .gnulib |2 +-
 gnulib/local/lib/openpty.c.diff |   26 --
 gnulib/local/lib/pty.in.h.diff  |   13 ---
 m4/virt-compile-warnings.m4 |8 ++-
 src/fdstream.c  |2 +-
 src/libvirt_private.syms|1 -
 src/qemu/qemu_monitor.c |2 +-
 src/qemu/qemu_monitor_json.c|2 +-
 src/util/conf.c |   22 ++---
 src/util/virterror.c|2 +-
 src/util/virterror_internal.h   |8 --
 src/xen/xen_hypervisor.c|  170 ---
 src/xenapi/xenapi_utils.c   |2 +-
 tests/testutils.c   |4 +-
 tools/virsh.c   |   12 ++--
 15 files changed, 98 insertions(+), 178 deletions(-)
 delete mode 100644 gnulib/local/lib/openpty.c.diff
 delete mode 100644 gnulib/local/lib/pty.in.h.diff

-- 
1.7.7.3

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


Re: [libvirt] [PATCH 1/5] block_resize: Define the new API

2011-11-29 Thread Osier Yang

On 2011年11月29日 17:00, Daniel P. Berrange wrote:

On Tue, Nov 29, 2011 at 04:27:32PM +0800, Osier Yang wrote:

The new API is named as virDomainBlockResize, intending to add
support for qemu monitor command block_resize (both HMP and QMP).

Similar with APIs like virDomainSetMemoryFlags, the units for
argument size is kilobytes.
---
  include/libvirt/libvirt.h.in |5 ++-
  src/driver.h |8 -
  src/libvirt.c|   68 ++
  src/libvirt_public.syms  |1 +
  4 files changed, 80 insertions(+), 2 deletions(-)


ACK

Daniel


Thanks, series pushed.

Regards,
Osier

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

[libvirt] [libvirt-glib] gir: Use --pkg=libxml-2.0 instead of LIBXML2_CFLAGS

2011-11-29 Thread Christophe Fergeau
g-ir-scanner has a standard way of getting the flags for libraries
providing .pc files, this commit uses this --pkg flag for libxml
instead of using LIBXML2_CFLAGS we computed ourselves.
---
 libvirt-gconfig/Makefile.am |2 +-
 libvirt-gobject/Makefile.am |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index b14bd92..fe5b1a5 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -119,9 +119,9 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la 
$(G_IR_SCANNER) Makefile.am
 --output $@ \
 -I$(top_builddir) \
 -I$(top_srcdir) \
-$(LIBXML2_CFLAGS) \
 --verbose \
 --c-include=libvirt-gconfig/libvirt-gconfig.h \
+--pkg=libxml-2.0 \
 --pkg-export=libvirt-gconfig-1.0 \
 $(srcdir)/libvirt-gconfig.h \
 $(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 5aa1080..ad746bb 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -133,10 +133,10 @@ LibvirtGObject-1.0.gir: libvirt-gobject-1.0.la 
$(G_IR_SCANNER) Makefile.am
 --output $@ \
 -I$(top_builddir) \
 -I$(top_srcdir) \
-$(LIBXML2_CFLAGS) \
 --verbose \
---pkg=gthread-2.0 \
 --c-include=libvirt-gobject/libvirt-gobject.h \
+--pkg=gthread-2.0 \
+--pkg=libxml-2.0 \
 --pkg-export=libvirt-gobject-1.0 \
 $(srcdir)/libvirt-gobject.h \
 $(GOBJECT_SOURCE_FILES:%=$(srcdir)/%) \
-- 
1.7.7.3

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


Re: [libvirt] [libvirt-glib] gir: Use --pkg=libxml-2.0 instead of LIBXML2_CFLAGS

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 03:19:45PM +0100, Christophe Fergeau wrote:
 g-ir-scanner has a standard way of getting the flags for libraries
 providing .pc files, this commit uses this --pkg flag for libxml
 instead of using LIBXML2_CFLAGS we computed ourselves.
 ---
  libvirt-gconfig/Makefile.am |2 +-
  libvirt-gobject/Makefile.am |4 ++--
  2 files changed, 3 insertions(+), 3 deletions(-)
 
 diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
 index b14bd92..fe5b1a5 100644
 --- a/libvirt-gconfig/Makefile.am
 +++ b/libvirt-gconfig/Makefile.am
 @@ -119,9 +119,9 @@ LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la 
 $(G_IR_SCANNER) Makefile.am
  --output $@ \
  -I$(top_builddir) \
  -I$(top_srcdir) \
 -$(LIBXML2_CFLAGS) \
  --verbose \
  --c-include=libvirt-gconfig/libvirt-gconfig.h \
 +--pkg=libxml-2.0 \
  --pkg-export=libvirt-gconfig-1.0 \
  $(srcdir)/libvirt-gconfig.h \
  $(GCONFIG_SOURCE_FILES:%=$(srcdir)/%) \
 diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
 index 5aa1080..ad746bb 100644
 --- a/libvirt-gobject/Makefile.am
 +++ b/libvirt-gobject/Makefile.am
 @@ -133,10 +133,10 @@ LibvirtGObject-1.0.gir: libvirt-gobject-1.0.la 
 $(G_IR_SCANNER) Makefile.am
  --output $@ \
  -I$(top_builddir) \
  -I$(top_srcdir) \
 -$(LIBXML2_CFLAGS) \
  --verbose \
 ---pkg=gthread-2.0 \
  --c-include=libvirt-gobject/libvirt-gobject.h \
 +--pkg=gthread-2.0 \
 +--pkg=libxml-2.0 \
  --pkg-export=libvirt-gobject-1.0 \
  $(srcdir)/libvirt-gobject.h \
  $(GOBJECT_SOURCE_FILES:%=$(srcdir)/%) \

ACK

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

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


[libvirt] [RFC v3 PATCH 1/5] PowerPC : Use sysfs to gather host topology, in place of /proc/cpuinfo

2011-11-29 Thread Prerna Saxena
From: Prerna Saxena pre...@linux.vnet.ibm.com
Date: Mon, 3 Oct 2011 05:45:30 -0700
Subject: [PATCH 1/5] Use sysfs to gather host topology, in place of
 /proc/cpuinfo

Libvirt at present depends on /proc/cpuinfo to gather host
details such as CPUs, cores, threads, etc. This is an architecture-
dependent approach. An alternative is to use 'Sysfs', which provides
a platform-agnostic interface to parse host CPU topology.

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 src/nodeinfo.c |  114 +++-
 1 files changed, 39 insertions(+), 75 deletions(-)

diff --git a/src/nodeinfo.c b/src/nodeinfo.c
index 6448b79..f70654a 100644
--- a/src/nodeinfo.c
+++ b/src/nodeinfo.c
@@ -30,6 +30,7 @@
 #include errno.h
 #include dirent.h
 #include sys/utsname.h
+#include sched.h
 
 #if HAVE_NUMACTL
 # define NUMA_VERSION1_COMPATIBILITY 1
@@ -67,8 +68,7 @@
 
 /* NB, this is not static as we need to call it from the testsuite */
 int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
- virNodeInfoPtr nodeinfo,
- bool need_hyperthreads);
+ virNodeInfoPtr nodeinfo);
 
 static int linuxNodeGetCPUStats(FILE *procstat,
 int cpuNum,
@@ -191,23 +191,26 @@ static int parse_socket(unsigned int cpu)
 return ret;
 }
 
+static int parse_core(unsigned int cpu)
+{
+return get_cpu_value(cpu, topology/core_id, false);
+}
+
 int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
- virNodeInfoPtr nodeinfo,
- bool need_hyperthreads)
+ virNodeInfoPtr nodeinfo)
 {
 char line[1024];
 DIR *cpudir = NULL;
 struct dirent *cpudirent = NULL;
 unsigned int cpu;
-unsigned long cur_threads;
-int socket;
-unsigned long long socket_mask = 0;
-unsigned int remaining;
+unsigned long core, socket, cur_threads;
+cpu_set_t core_mask;
+cpu_set_t socket_mask;
 int online;
 
 nodeinfo-cpus = 0;
 nodeinfo-mhz = 0;
-nodeinfo-cores = 1;
+nodeinfo-cores = 0;
 
 nodeinfo-nodes = 1;
 # if HAVE_NUMACTL
@@ -221,20 +224,10 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
 /* NOTE: hyperthreads are ignored here; they are parsed out of /sys */
 while (fgets(line, sizeof(line), cpuinfo) != NULL) {
 char *buf = line;
-if (STRPREFIX(buf, processor)) { /* aka a single logical CPU */
-buf += 9;
-while (*buf  c_isspace(*buf))
-buf++;
-if (*buf != ':') {
-nodeReportError(VIR_ERR_INTERNAL_ERROR,
-%s, _(parsing cpuinfo processor));
-return -1;
-}
-nodeinfo-cpus++;
 # if defined(__x86_64__) || \
 defined(__amd64__)  || \
 defined(__i386__)
-} else if (STRPREFIX(buf, cpu MHz)) {
+if (STRPREFIX(buf, cpu MHz)) {
 char *p;
 unsigned int ui;
 buf += 9;
@@ -249,24 +242,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
 /* Accept trailing fractional part.  */
  (*p == '\0' || *p == '.' || c_isspace(*p)))
 nodeinfo-mhz = ui;
-} else if (STRPREFIX(buf, cpu cores)) { /* aka cores */
-char *p;
-unsigned int id;
-buf += 9;
-while (*buf  c_isspace(*buf))
-buf++;
-if (*buf != ':' || !buf[1]) {
-nodeReportError(VIR_ERR_INTERNAL_ERROR,
-_(parsing cpuinfo cpu cores %c), *buf);
-return -1;
-}
-if (virStrToLong_ui(buf+1, p, 10, id) == 0
- (*p == '\0' || c_isspace(*p))
- id  nodeinfo-cores)
-nodeinfo-cores = id;
 # elif defined(__powerpc__) || \
   defined(__powerpc64__)
-} else if (STRPREFIX(buf, clock)) {
+if (STRPREFIX(buf, clock)) {
 char *p;
 unsigned int ui;
 buf += 5;
@@ -281,53 +259,30 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
 /* Accept trailing fractional part.  */
  (*p == '\0' || *p == '.' || c_isspace(*p)))
 nodeinfo-mhz = ui;
-# elif defined(__s390__) || \
-defined(__s390x__)
-} else if (STRPREFIX(buf, # processors)) {
-char *p;
-unsigned int ui;
-buf += 12;
-while (*buf  c_isspace(*buf))
-buf++;
-if (*buf != ':' || !buf[1]) {
-nodeReportError(VIR_ERR_INTERNAL_ERROR,
-_(parsing number of processors %c), *buf);
-return -1;
-}
-if (virStrToLong_ui(buf+1, p, 10, ui) == 0
- (*p == '\0' || c_isspace(*p)))
-nodeinfo-cpus = ui;
 /* No other interesting infos are available in 

[libvirt] [RFC v3 PATCH 0/5] PowerPC : Extend libvirt for the PowerPC-KVM platform

2011-11-29 Thread Prerna Saxena
Recent development in KVM for 64-bit Power ISA Book3S machines, allows
users to run multiple KVM guest instances on POWER7 and PPC970
processor based systems.  Also qemu-system-ppc64 has been enhanced to
support a new machine type pseries suitable for Power Book3S machines.
This addition effectively brings the KVM+qemu combination to run
multiple guest instances on a Power Book3S machine.

Libvirt continues to be the key interface to configure and manage the
KVM guest instances on x86.  This patch set is an effort to enable
libvirt to support KVM guest configuration and management on Power Book3S
machines.

Based on community discussion around the earlier version, this patch
series augments the present 'kvm' driver to support PowerPC-KVM based
guests.Since some of the supported devices vary between architectures,
libvirt must be capable of choosing supported device backends and
defaults for each architecture in qemu.

To check if qemu supports a certain feature, libvirt at present parses
the -help string which is generated by running the qemu binary with the
'-h' argument. This approach is gated by QEMU's inherent limitation. 
When generating the list of allowed options with the '-h' flags, qemu
today blindly lists all options defined for any architecture/platform
instead of doing any arch-specific checking. This tricks libvirt into
assuming a much bigger set of host capabilities than is actually
available.
Ideally, it would be good to have qemu specify a list of devices for a
given architecture and platform which libvirt can parse to understand 
supported capabilities for that guest.

As a part of this patchset, there is an attempt to cleanly bifurcate
libvirt code and to remove x86-specific assumptions from generic qemu
commandline code.

Series Description:
---
This patch series consists of 5 patches :
Patch 1/5 : Use sysfs to gather host topology in place of /proc/cpuinfo.
Patch 2/5 : Add PowerPC CPU Driver
Patch 3/5 : Add support for qemu-system-ppc64
Patch 4/5 : Clean up x86-specific assumptions from generic qemu code.
Patch 5/5 : Add address family spapr-vio

Changelog:
-
** v1-v2 :
* Patches 1,2,3 unchanged ; The hacks in Patch 4 of v1 replaced by a
  new patch to neatly select arch-specific features.

** v2-v3 :
* Patches 1,2,3 have minor cleanups ; Patch 4 no longer has an
  arch-specific handler routine. It is now replaced by a much simpler
  patch that merely removes x86/pc-specific assumptions from libvirt.

** v3-v4 :
* Patches 1,2,3,4 unchanged ; patch 5 is a new addition from Michael Ellerman
  that adds a new device-tree based addressing mechanism for the 'pseries'
  guest.


-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India

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


[libvirt] [RFC v3 PATCH 2/5] PowerPC : Add PPC CPU driver

2011-11-29 Thread Prerna Saxena
From: Prerna Saxena pre...@linux.vnet.ibm.com
Date: Mon, 3 Oct 2011 05:56:20 -0700
Subject: [PATCH 2/5] Add PPC cpu driver.

To add support for running libvirt on PowerPC, a CPU driver for the
PowerPC platform must be added.
Most generic cpu driver routines such as CPU compare, decode, etc
are based on CPUID comparison and are not relevant for non-x86
platforms.
Here, we introduce stubs for relevant PowerPC routines invoked by libvirt.

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
Signed-off-by: Anton Blanchard an...@au.ibm.com
---
 src/Makefile.am   |3 +-
 src/cpu/cpu.c |2 +
 src/cpu/cpu_powerpc.c |   81 +
 src/cpu/cpu_powerpc.h |   32 +++
 4 files changed, 117 insertions(+), 1 deletions(-)
 create mode 100644 src/cpu/cpu_powerpc.c
 create mode 100644 src/cpu/cpu_powerpc.h

diff --git a/src/Makefile.am b/src/Makefile.am
index 33a32a8..aea3ddd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -533,7 +533,8 @@ CPU_SOURCES =   
\
cpu/cpu.h cpu/cpu.c \
cpu/cpu_generic.h cpu/cpu_generic.c \
cpu/cpu_x86.h cpu/cpu_x86.c cpu/cpu_x86_data.h  \
-   cpu/cpu_map.h cpu/cpu_map.c
+   cpu/cpu_map.h cpu/cpu_map.c cpu/cpu_powerpc.h   \
+   cpu/cpu_powerpc.c
 
 VMX_SOURCES =  \
vmx/vmx.c vmx/vmx.h
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index b919b6e..e4149e2 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -28,6 +28,7 @@
 #include xml.h
 #include cpu.h
 #include cpu_x86.h
+#include cpu_powerpc.h
 #include cpu_generic.h
 
 
@@ -36,6 +37,7 @@
 
 static struct cpuArchDriver *drivers[] = {
 cpuDriverX86,
+cpuDriverPowerPC,
 /* generic driver must always be the last one */
 cpuDriverGeneric
 };
diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
new file mode 100644
index 000..ed81694
--- /dev/null
+++ b/src/cpu/cpu_powerpc.c
@@ -0,0 +1,81 @@
+/*
+ * cpu_powerpc.h: CPU driver for PowerPC CPUs
+ *
+ * Copyright (C) Copyright (C) IBM Corporation, 2010
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * Authors:
+ *  Anton Blanchard an...@au.ibm.com
+ *  Prerna Saxena pre...@linux.vnet.ibm.com
+ */
+
+#include config.h
+
+#include memory.h
+#include cpu.h
+
+
+#define VIR_FROM_THIS VIR_FROM_CPU
+
+static const char *archs[] = { ppc64 };
+
+static union cpuData *
+PowerPCNodeData(void)
+{
+union cpuData *data;
+
+if (VIR_ALLOC(data)  0) {
+virReportOOMError();
+return NULL;
+}
+
+return data;
+}
+
+
+static int
+PowerPCDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
+  const union cpuData *data ATTRIBUTE_UNUSED,
+  const char **models ATTRIBUTE_UNUSED,
+  unsigned int nmodels ATTRIBUTE_UNUSED,
+  const char *preferred ATTRIBUTE_UNUSED)
+{
+return 0;
+}
+
+static void
+PowerPCDataFree(union cpuData *data)
+{
+   if (data == NULL)
+   return;
+
+   VIR_FREE(data);
+}
+
+struct cpuArchDriver cpuDriverPowerPC = {
+.name = ppc64,
+.arch = archs,
+.narch = ARRAY_CARDINALITY(archs),
+.compare= NULL,
+.decode = PowerPCDecode,
+.encode = NULL,
+.free   = PowerPCDataFree,
+.nodeData   = PowerPCNodeData,
+.guestData  = NULL,
+.baseline   = NULL,
+.update = NULL,
+.hasFeature = NULL,
+};
diff --git a/src/cpu/cpu_powerpc.h b/src/cpu/cpu_powerpc.h
new file mode 100644
index 000..2e0c1a5
--- /dev/null
+++ b/src/cpu/cpu_powerpc.h
@@ -0,0 +1,32 @@
+/*
+ * cpu_powerpc.h: CPU driver for PowerPC CPUs
+ *
+ * Copyright (C) Copyright (C) IBM Corporation, 2010
+ *
+ * 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
+ * 

[libvirt] [libvirt-glib 2/2] Remove transient domain reference on shutdown

2011-11-29 Thread Zeeshan Ali (Khattak)
From: Zeeshan Ali (Khattak) zeesha...@gnome.org

This patch doesn't work cause virDomainIsPersistent() is returning '1'
on transient domain for some reason. Send it to list to get some help.
---
 libvirt-gobject/libvirt-gobject-connection.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-connection.c 
b/libvirt-gobject/libvirt-gobject-connection.c
index b647bfa..1b0259e 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -362,6 +362,15 @@ static int domain_event_cb(virConnectPtr conn 
G_GNUC_UNUSED,
 g_signal_emit_by_name(gdom, stopped::from-snapshot);
 else
 g_warn_if_reached();
+
+if (!virDomainIsPersistent(dom)) {
+g_mutex_lock(priv-lock);
+g_hash_table_steal(priv-domains, uuid);
+g_mutex_unlock(priv-lock);
+
+g_signal_emit(gconn, signals[VIR_DOMAIN_REMOVED], 0, gdom);
+g_object_unref(gdom);
+}
 break;
 
 default:
-- 
1.7.7.3

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


[libvirt] [RFC v3 PATCH 4/5] PowerPC : Clean up qemuBuildCommandLine to remove x86-specific assumptions from generic code.

2011-11-29 Thread Prerna Saxena
From: Prerna Saxena pre...@linux.vnet.ibm.com
Date: Mon, 21 Nov 2011 18:20:42 +0530
Subject: [PATCH 4/5] Clean up qemuBuildCommandLine to remove x86-specific
 assumptions from generic code.

This implements the minimal set of changes needed in libvirt to launch a
PowerPC-KVM based guest.
It removes x86-specific assumptions about choice of serial driver backend
from generic qemu guest commandline generation code.
It also restricts the ACPI capability to be available for an x86 or
x86_64 domain.
This is not a complete solution -- it still does not guarantee libvirt
the capability to flag non-supported options in guest XML. (Eg, an ACPI
specification in a PowerPC guest XML will still get processed, even
though qemu-system-ppc64 does not support it while qemu-system-x86_64 does.)
This drawback exists because libvirt falls back on qemu to query supported
features, and qemu '-h' blindly lists all capabilities -- irrespective
of whether they are available while emulating a given architecture or not.
The long-term solution would be for qemu to list out capabilities based
on architecture and platform -- so that libvirt can cleanly make out what
devices are supported on an arch (say 'ppc64') and platform (say, 'mac99').

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 src/qemu/qemu_command.c |   39 ---
 src/qemu/qemu_command.h |6 ++
 2 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 85b34bb..57b25d6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4550,8 +4550,11 @@ qemuBuildCommandLine(virConnectPtr conn,
 VIR_FREE(devstr);
 
 virCommandAddArg(cmd, -device);
-virCommandAddArgFormat(cmd, isa-serial,chardev=char%s,id=%s,
-   serial-info.alias, serial-info.alias);
+if (!(devstr = qemuBuildChrDeviceStr(serial, def-os.arch,
+ def-os.machine)))
+   goto error;
+virCommandAddArg(cmd, devstr);
+VIR_FREE(devstr);
 } else {
 virCommandAddArg(cmd, -serial);
 if (!(devstr = qemuBuildChrArgStr(serial-source, NULL)))
@@ -5438,6 +5441,34 @@ qemuBuildCommandLine(virConnectPtr conn,
 return NULL;
 }
 
+/* This function generates the correct '-device' string for character
+ * devices of each architecture.
+ */
+char *
+qemuBuildChrDeviceStr (virDomainChrDefPtr serial,
+   char *os_arch,
+   char *machine)
+{
+virBuffer cmd = VIR_BUFFER_INITIALIZER;
+
+if (STREQ(os_arch, ppc64)  STREQ(machine, pseries))
+virBufferAsprintf(cmd, spapr-vty,chardev=char%s,
+  serial-info.alias);
+else
+virBufferAsprintf(cmd, isa-serial,chardev=char%s,id=%s,
+  serial-info.alias, serial-info.alias);
+
+if (virBufferError(cmd)) {
+virReportOOMError();
+goto error;
+}
+
+return virBufferContentAndReset(cmd);
+
+ error:
+virBufferFreeAndReset(cmd);
+return NULL;
+}
 
 /*
  * This method takes a string representing a QEMU command line ARGV set
@@ -6649,7 +6680,9 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr caps,
 def-maxvcpus = 1;
 def-vcpus = 1;
 def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
-def-features = (1  VIR_DOMAIN_FEATURE_ACPI)
+
+if (STREQ(def-os.arch, i686)||STREQ(def-os.arch, x86_64))
+def-features = (1  VIR_DOMAIN_FEATURE_ACPI)
 /*| (1  VIR_DOMAIN_FEATURE_APIC)*/;
 def-onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
 def-onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index dbe2fb2..1fe0394 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -53,6 +53,12 @@ virCommandPtr qemuBuildCommandLine(virConnectPtr conn,
enum virNetDevVPortProfileOp vmop)
 ATTRIBUTE_NONNULL(1);
 
+/* Generate string for arch-specific '-device' parameter */
+char *
+qemuBuildChrDeviceStr (virDomainChrDefPtr serial,
+   char *os_arch,
+   char *machine);
+
 /* With vlan == -1, use netdev syntax, else old hostnet */
 char * qemuBuildHostNetStr(virDomainNetDefPtr net,
char type_sep,
-- 
1.7.7



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India

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


[libvirt] [RFC v3 PATCH 3/5] PowerPC : Add support for ppc64 qemu

2011-11-29 Thread Prerna Saxena
From: Prerna Saxena pre...@linux.vnet.ibm.com
Date: Mon, 3 Oct 2011 06:01:33 -0700
Subject: [PATCH 3/5] Add support for ppc64 qemu

This enables libvirt to select the correct qemu binary (qemu-system-ppc64)
for a guest vm based on arch 'ppc64'.
Also, libvirt is enabled to correctly parse the list of supported PowerPC
CPUs, generated by running 'qemu-system-ppc64 -cpu ?'

Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 src/qemu/qemu_capabilities.c |   64 ++
 1 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c5fe41d..c2d3d93 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -185,6 +185,7 @@ static const struct qemu_arch_info const arch_info_hvm[] = {
 {  mipsel, 32, NULL, qemu-system-mipsel, NULL, NULL, 0 },
 {  sparc,  32, NULL, qemu-system-sparc,  NULL, NULL, 0 },
 {  ppc,32, NULL, qemu-system-ppc,NULL, NULL, 0 },
+{  ppc64,64, NULL, qemu-system-ppc64,NULL, NULL, 0 },
 {  itanium, 64, NULL, qemu-system-ia64,  NULL, NULL, 0 },
 {  s390x,  64, NULL, qemu-system-s390x,  NULL, NULL, 0 },
 };
@@ -477,6 +478,67 @@ error:
 return -1;
 }
 
+/* ppc64 parser.
+ * Format : PowerPC machine description
+ */
+static int
+qemuCapsParsePPCModels(const char *output,
+   unsigned int *retcount,
+   const char ***retcpus)
+{
+const char *p = output;
+const char *next;
+unsigned int count = 0;
+const char **cpus = NULL;
+int i;
+do {
+const char *t;
+
+if ((next = strchr(p, '\n')))
+next++;
+
+if (!STRPREFIX(p, PowerPC ))
+continue;
+
+/* Skip the preceding sub-string PowerPC  */
+p += 8;
+
+/*Malformed string, does not obey the format 'PowerPC model desc'*/
+if (!(t = strchr(p, ' ')) || (next  t = next))
+continue;
+
+if (*p == '\0' || *p == '\n')
+continue;
+
+if (retcpus) {
+unsigned int len;
+
+if (VIR_REALLOC_N(cpus, count + 1)  0)
+goto error;
+
+if (t)
+len = t - p - 1;
+
+if (!(cpus[count] = strndup(p, len)))
+goto error;
+}
+count++;
+} while ((p = next));
+
+if (retcount)
+*retcount = count;
+if (retcpus)
+*retcpus = cpus;
+return 0;
+
+error:
+if (cpus) {
+for (i = 0; i  count; i++)
+VIR_FREE(cpus[i]);
+}
+VIR_FREE(cpus);
+return -1;
+}
 
 int
 qemuCapsProbeCPUModels(const char *qemu,
@@ -497,6 +559,8 @@ qemuCapsProbeCPUModels(const char *qemu,
 
 if (STREQ(arch, i686) || STREQ(arch, x86_64))
 parse = qemuCapsParseX86Models;
+else if (STREQ(arch, ppc64))
+parse = qemuCapsParsePPCModels;
 else {
 VIR_DEBUG(don't know how to parse %s CPU models, arch);
 return 0;
-- 
1.7.7



-- 
Prerna Saxena

Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India

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


[libvirt] [libvirt-glib 1/2] Rely on libvirt API to detect transient domains

2011-11-29 Thread Zeeshan Ali (Khattak)
From: Zeeshan Ali (Khattak) zeesha...@gnome.org

---
 libvirt-gobject/libvirt-gobject-connection.c |6 +-
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-connection.c 
b/libvirt-gobject/libvirt-gobject-connection.c
index c9985b2..b647bfa 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -260,7 +260,6 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
 GVirConnection *gconn = opaque;
 GVirDomain *gdom;
 GVirConnectionPrivate *priv = gconn-priv;
-gboolean was_unknown = FALSE;
 
 if (virDomainGetUUIDString(dom, uuid)  0) {
 g_warning(Failed to get domain UUID on %p, dom);
@@ -279,8 +278,6 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
 g_mutex_lock(priv-lock);
 g_hash_table_insert(priv-domains, 
(gpointer)gvir_domain_get_uuid(gdom), gdom);
 g_mutex_unlock(priv-lock);
-
-was_unknown = TRUE;
 }
 
 switch (event) {
@@ -307,8 +304,7 @@ static int domain_event_cb(virConnectPtr conn G_GNUC_UNUSED,
 
 case VIR_DOMAIN_EVENT_STARTED:
 if (detail == VIR_DOMAIN_EVENT_STARTED_BOOTED) {
-if (was_unknown)
-/* Most probably a transient domain */
+if (!virDomainIsPersistent(dom))
 g_signal_emit(gconn, signals[VIR_DOMAIN_ADDED], 0, gdom);
 g_signal_emit_by_name(gdom, started::booted);
 } else if (detail == VIR_DOMAIN_EVENT_STARTED_MIGRATED)
-- 
1.7.7.3

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


[libvirt] [RFC v3 PATCH 5/5] PowerPC : Add address-type spapr-vio

2011-11-29 Thread Prerna Saxena
From: Michael Ellerman mich...@ellerman.id.au
Date: Tue, 29 Nov 2011 13:48:09 +0530
Subject: [PATCH 5/5] Add address-type spapr-vio for devices based on
the same bus.

 For QEMU PPC64 we have a machine type (pseries) which
 has a virtual bus called spapr-vio. We need to be
 able to create devices on this bus, and as such need a
 way to specify the address for those devices.

This patch adds a new address type spapr-vio, which achieves this.

The addressing is specified with a reg property in the address
definition. The reg is optional, if it is not specified QEMU will
auto-assign an address for the device.

Additionally, this patch forces an spapr-vscsi controller to be
selected for a guest running on architecture 'ppc64' and platform
'pseries'.

Signed-off-by: Michael Ellerman mich...@ellerman.id.au
Signed-off-by: Prerna Saxena pre...@linux.vnet.ibm.com
---
 src/conf/domain_conf.c  |   42 +-
 src/conf/domain_conf.h  |9 +
 src/qemu/qemu_command.c |   18 ++
 src/qemu/qemu_command.h |3 ++-
 src/qemu/qemu_hotplug.c |2 +-
 5 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3ea99f7..5c3809e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -139,7 +139,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, 
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
   drive,
   virtio-serial,
   ccid,
-  usb)
+  usb,
+  spapr-vio)
 
 VIR_ENUM_IMPL(virDomainDeviceAddressPciMulti,
   VIR_DOMAIN_DEVICE_ADDRESS_PCI_MULTI_LAST,
@@ -1844,6 +1845,11 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
   info-addr.usb.port);
 break;
 
+case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
+if (info-addr.spaprvio.has_reg)
+virBufferAsprintf(buf,  reg='%#llx', info-addr.spaprvio.reg);
+break;
+
 default:
 virDomainReportError(VIR_ERR_INTERNAL_ERROR,
  _(unknown address type '%d'), info-type);
@@ -2103,6 +2109,34 @@ cleanup:
 }
 
 static int
+virDomainDeviceSpaprVioAddressParseXML(xmlNodePtr node,
+  virDomainDeviceSpaprVioAddressPtr addr)
+{
+char *reg;
+int ret;
+
+memset(addr, 0, sizeof(*addr));
+addr-has_reg = false;
+
+reg = virXMLPropString(node, reg);
+if (reg) {
+if (virStrToLong_ull(reg, NULL, 16, addr-reg)  0) {
+virDomainReportError(VIR_ERR_INTERNAL_ERROR, %s,
+ _(Cannot parse address 'reg' attribute));
+ret = -1;
+goto cleanup;
+}
+
+addr-has_reg = true;
+}
+
+ret = 0;
+cleanup:
+VIR_FREE(reg);
+return ret;
+}
+
+static int
 virDomainDeviceUSBMasterParseXML(xmlNodePtr node,
  virDomainDeviceUSBMasterPtr master)
 {
@@ -2215,6 +2249,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
 goto cleanup;
 break;
 
+case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO:
+if (virDomainDeviceSpaprVioAddressParseXML(address, 
info-addr.spaprvio)  0)
+goto cleanup;
+break;
+
 default:
 /* Should not happen */
 virDomainReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3048,6 +3087,7 @@ virDomainControllerDefParseXML(xmlNodePtr node,
 }
 
 if (def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
+def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO 
 def-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
 virDomainReportError(VIR_ERR_INTERNAL_ERROR, %s,
  _(Controllers must use the 'pci' address type));
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4439f55..b1f9260 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -69,6 +69,7 @@ enum virDomainDeviceAddressType {
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
+VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
 
 VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
 };
@@ -121,6 +122,13 @@ struct _virDomainDeviceUSBAddress {
 char *port;
 };
 
+typedef struct _virDomainDeviceSpaprVioAddress virDomainDeviceSpaprVioAddress;
+typedef virDomainDeviceSpaprVioAddress *virDomainDeviceSpaprVioAddressPtr;
+struct _virDomainDeviceSpaprVioAddress {
+unsigned long long reg;
+bool has_reg;
+};
+
 enum virDomainControllerMaster {
 VIR_DOMAIN_CONTROLLER_MASTER_NONE,
 VIR_DOMAIN_CONTROLLER_MASTER_USB,
@@ -145,6 +153,7 @@ struct _virDomainDeviceInfo {
 virDomainDeviceVirtioSerialAddress vioserial;
 virDomainDeviceCcidAddress ccid;
 virDomainDeviceUSBAddress usb;
+virDomainDeviceSpaprVioAddress spaprvio;
 } addr;
 int mastertype;
 union {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 

[libvirt] [PATCH 04/14] Move the virHostPMCapability enum helpers into capabilities.c

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The virHostPMCapability enum helper was declared in util.h
but implemented in capabilities.c, which is in a completely
separate library at link time. Move the declaration into the
capabilities.c file and rename it to match normal conventions

* src/util/util.h: Remove virHostPMCapability enum decl
* src/conf/capabilities.c: Add virCapsHostPMTarget enm
---
 src/conf/capabilities.c |5 +++--
 src/util/util.h |2 --
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index ecb1dcd..df5ff23 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -36,7 +36,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_CAPABILITIES
 
-VIR_ENUM_IMPL(virHostPMCapability, VIR_NODE_SUSPEND_TARGET_LAST,
+VIR_ENUM_DECL(virCapsHostPMTarget)
+VIR_ENUM_IMPL(virCapsHostPMTarget, VIR_NODE_SUSPEND_TARGET_LAST,
   suspend_mem, suspend_disk, suspend_hybrid);
 
 /**
@@ -704,7 +705,7 @@ virCapabilitiesFormatXML(virCapsPtr caps)
 while (pm) {
 int bit = ffs(pm) - 1;
 virBufferAsprintf(xml,   %s/\n,
-virHostPMCapabilityTypeToString(bit));
+virCapsHostPMTargetTypeToString(bit));
 pm = ~(1U  bit);
 }
 virBufferAddLit(xml, /power_management\n);
diff --git a/src/util/util.h b/src/util/util.h
index 690fca0..204e2b9 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -263,8 +263,6 @@ void virTypedParameterArrayClear(virTypedParameterPtr 
params, int nparams);
 
 /* Power Management Capabilities of the host system */
 
-VIR_ENUM_DECL(virHostPMCapability)
-
 int virDiscoverHostPMFeature(unsigned int *bitmask, unsigned int feature);
 int virGetPMCapabilities(unsigned int *bitmask);
 
-- 
1.7.6.4

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


[libvirt] [PATCH 0/5] Interface pools and passthrough mode

2011-11-29 Thread Shradha Shah
Interface Pools and Passthrough mode:

Current Method:
The passthrough mode uses a macvtap a direct connection to connect each guest 
to the network. The physical interface to be used is picked from among those 
listed in interface sub elements of the forward element.

The current specification for forward extends to allow 0 or more interface 
sub-elements:
Example:
forward mode='passthrough' dev='eth10'/
interface dev='eth10'/
interface dev='eth12'/
interface dev='eth18'/
interface dev='eth20'/
/forward

However with an ethernet card with 64 VF's or more, the above method gets 
tedious on the system.

On the other hand, just parameterizing a string (eth%d) is inadequate, eg, when 
there are multiple non-contiguous ranges.

Proposed Method:
The 5 patches provided along with this introductory e-mail 

i) Introduce a structure to store the state of all the virtual functions 
attached to each physical function  
ii) Find a free virtual function given the physical function.

The forward specification will hence only mention the physical function as the 
interface sub element:
Example:
forward mode='passthrough' dev='eth2'/
interface dev='eth2'/
/forward

Shradha Shah (5):
  Moving the declaration of _pciDevice and _pciDeviceList to pci.h
  Added function pciSysfsFile to enable access to the PCI SYSFS files.
  Adding functions virNetDevGetVirtualFunctions and virNetDevGetNetName
virNetDevGetVirtualFunctions: Gets the BDF of all the Virtual
Functions given a physical function virNetDevGetNetName: Gets
the interface name of the PCI Device.
  Addition of a new device structure to store the state of a Virtual
Function Modifications to the Physical Device Structure to
store state of its Virtual Functions
  If a system has 64 or more VF's, it is quite tedious to mention each
VF in the interface pool. The following modification find a
Free VF given a Physical Function when mode=passthrough. We
also save the state of each VF. Hence modifications to
networkAllocateActualDevice, networkNotifyActualDevice and
networkReleaseActualDevice were required. The following
patch does just that.

 src/conf/network_conf.c |   19 -
 src/conf/network_conf.h |   10 ++
 src/network/bridge_driver.c |  208 +--
 src/util/pci.c  |   52 ---
 src/util/pci.h  |   36 
 src/util/virnetdev.c|   89 ++
 src/util/virnetdev.h|   10 ++
 7 files changed, 359 insertions(+), 65 deletions(-)

-- 
1.7.4.4

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


[libvirt] [PATCH 00/14] Cleanup node suspend code

2011-11-29 Thread Daniel P. Berrange
This patch series does a large number of pretty small / trivial
cleanups of the recently committed node suspend code.

There are a few important changes though

 - Patch 1 changes public API enum values
 - Patch 3 changes the capabilities XML schema
 - Patch 11 ensures we don't probe suspend info unles we need it
 - Patch 14 fixes a bug


Obviously due to 1  3 we need to do this before the next release


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


[libvirt] [PATCH 2/5] Added function pciSysfsFile to enable access to the PCI SYSFS files.

2011-11-29 Thread Shradha Shah
---
 src/util/pci.c |   17 +
 src/util/pci.h |2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/util/pci.c b/src/util/pci.c
index 857078d..89a9d12 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -39,6 +39,7 @@
 #include command.h
 #include virterror_internal.h
 #include virfile.h
+#include virnetdev.h
 
 /* avoid compilation breakage on some systems */
 #ifndef MODPROBE
@@ -1991,6 +1992,22 @@ out:
 return ret;
 }
 
+ /*
+  * Returns a path to the PCI sysfs file given the BDF of the PCI function
+  */
+
+int
+pciSysfsFile(char **pci_sysfs_device_link, char *pciDeviceName)
+{
+if (virAsprintf(pci_sysfs_device_link, PCI_SYSFS devices/%s,
+pciDeviceName)  0) {
+virReportOOMError();
+return -1;
+}
+
+return 0;
+}
+
 /*
  * Returns the network device name of a pci device
  */
diff --git a/src/util/pci.h b/src/util/pci.h
index 8e47fc2..3800d98 100644
--- a/src/util/pci.h
+++ b/src/util/pci.h
@@ -143,4 +143,6 @@ int pciGetVirtualFunctionIndex(const char 
*pf_sysfs_device_link,
 
 int pciDeviceNetName(char *device_link_sysfs_path, char **netname);
 
+int pciSysfsFile(char **pci_sysfs_device_link, char *pciDeviceName);
+
 #endif /* __VIR_PCI_H__ */
-- 
1.7.4.4


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


[libvirt] [PATCH 07/14] Move suspend capabilities APIs out of util.h into virnodesuspend.c

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The node suspend capabilities APIs should not have been put into
util.[ch]. Instead move them into virnodesuspend.[ch]

* src/util/util.c, src/util/util.h: Remove suspend capabilities APIs
* src/util/virnodesuspend.c, src/util/virnodesuspend.h: Add
  suspend capabilities APIs
* src/qemu/qemu_capabilities.c: Include virnodesuspend.h
---
 src/qemu/qemu_capabilities.c |1 +
 src/util/util.c  |   96 -
 src/util/util.h  |5 --
 src/util/virnodesuspend.c|   97 ++
 src/util/virnodesuspend.h|2 +
 5 files changed, 100 insertions(+), 101 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 4bbfd78..64ab8a8 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -34,6 +34,7 @@
 #include domain_conf.h
 #include qemu_conf.h
 #include command.h
+#include virnodesuspend.h
 
 #include sys/stat.h
 #include unistd.h
diff --git a/src/util/util.c b/src/util/util.c
index 72fbdac..9ecfa9d 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2621,99 +2621,3 @@ virTypedParameterArrayClear(virTypedParameterPtr params, 
int nparams)
 VIR_FREE(params[i].value.s);
 }
 }
-
-/**
- * virNodeSuspendSupportsTarget:
- * @target: The power management target to check whether it is supported
- *   by the host. Values could be:
- *   VIR_NODE_SUSPEND_TARGET_MEM
- *   VIR_NODE_SUSPEND_TARGET_DISK
- *   VIR_NODE_SUSPEND_TARGET_HYBRID
- * @supported: set to true if supported, false otherwise
- *
- * Run the script 'pm-is-supported' (from the pm-utils package)
- * to find out if @target is supported by the host.
- *
- * Returns 0 if the query was successful, -1 on failure.
- */
-int
-virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
-{
-virCommandPtr cmd;
-int status;
-int ret = -1;
-
-*supported = false;
-
-switch (target) {
-case VIR_NODE_SUSPEND_TARGET_MEM:
-cmd = virCommandNewArgList(pm-is-supported, --suspend, NULL);
-break;
-case VIR_NODE_SUSPEND_TARGET_DISK:
-cmd = virCommandNewArgList(pm-is-supported, --hibernate, NULL);
-break;
-case VIR_NODE_SUSPEND_TARGET_HYBRID:
-cmd = virCommandNewArgList(pm-is-supported, --suspend-hybrid, 
NULL);
-break;
-default:
-return ret;
-}
-
-if (virCommandRun(cmd, status)  0)
-goto cleanup;
-
-   /*
-* Check return code of command == 0 for success
-* (i.e., the PM capability is supported)
-*/
-*supported = (status == 0);
-ret = 0;
-
-cleanup:
-virCommandFree(cmd);
-return ret;
-}
-
-/**
- * virNodeSuspendGetTargetMask:
- *
- * Get the Power Management Capabilities that the host system supports,
- * such as Suspend-to-RAM (S3), Suspend-to-Disk (S4) and Hybrid-Suspend
- * (a combination of S3 and S4).
- *
- * @bitmask: Pointer to the bitmask which will be set appropriately to
- *   indicate all the supported host power management targets.
- *
- * Returns 0 if the query was successful, -1 on failure.
- */
-int
-virNodeSuspendGetTargetMask(unsigned int *bitmask)
-{
-int ret;
-bool supported;
-
-*bitmask = 0;
-
-/* Check support for Suspend-to-RAM (S3) */
-ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_MEM, 
supported);
-if (ret  0)
-return -1;
-if (supported)
-*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_MEM);
-
-/* Check support for Suspend-to-Disk (S4) */
-ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_DISK, 
supported);
-if (ret  0)
-return -1;
-if (supported)
-*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_DISK);
-
-/* Check support for Hybrid-Suspend */
-ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_HYBRID, 
supported);
-if (ret  0)
-return -1;
-if (supported)
-*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_HYBRID);
-
-return 0;
-}
diff --git a/src/util/util.h b/src/util/util.h
index 6713547..ee53b84 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -261,9 +261,4 @@ int virEmitXMLWarning(int fd,
 
 void virTypedParameterArrayClear(virTypedParameterPtr params, int nparams);
 
-/* Power Management Capabilities of the host system */
-
-int virNodeSuspendSupportsTarget(unsigned int target, bool *supported);
-int virNodeSuspendGetTargetMask(unsigned int *bitmask);
-
 #endif /* __VIR_UTIL_H__ */
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 0814c36..4ac0d45 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -269,3 +269,100 @@ cleanup:
 VIR_FREE(cmdString);
 return -1;
 }
+
+
+/**
+ * virNodeSuspendSupportsTarget:
+ * @target: The power management target to check whether it is supported
+ *   by the host. Values could be:
+ *   VIR_NODE_SUSPEND_TARGET_MEM
+ *   

[libvirt] [PATCH 4/5] Addition of a new device structure to store the state of a Virtual Function Modifications to the Physical Device Structure to store state of its Virtual Functions

2011-11-29 Thread Shradha Shah
---
 src/conf/network_conf.c |   19 ++-
 src/conf/network_conf.h |   10 ++
 2 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 10afcde..d30d757 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -43,6 +43,7 @@
 #include buf.h
 #include c-ctype.h
 #include virfile.h
+#include logging.h
 
 #define MAX_BRIDGE_ID 256
 #define VIR_FROM_THIS VIR_FROM_NETWORK
@@ -103,6 +104,12 @@ virNetworkForwardIfDefClear(virNetworkForwardIfDefPtr def)
 VIR_FREE(def-dev);
 }
 
+static void
+virNetworkForwardVfDefClear(virNetworkForwardVfDefPtr def)
+{
+VIR_FREE(def-dev);
+}
+
 static void virNetworkIpDefClear(virNetworkIpDefPtr def)
 {
 int ii;
@@ -144,7 +151,7 @@ static void virNetworkDNSDefFree(virNetworkDNSDefPtr def)
 
 void virNetworkDefFree(virNetworkDefPtr def)
 {
-int ii;
+int ii, jj;
 
 if (!def)
 return;
@@ -154,6 +161,10 @@ void virNetworkDefFree(virNetworkDefPtr def)
 VIR_FREE(def-domain);
 
 for (ii = 0 ; ii  def-nForwardIfs  def-forwardIfs ; ii++) {
+for (jj = 0 ; jj  (def-forwardIfs[ii]).nForwardVfs ; jj++) {
+virNetworkForwardVfDefClear((def-forwardIfs[ii].forwardVfs[jj]));
+}
+VIR_FREE(def-forwardIfs[ii].forwardVfs); 
 virNetworkForwardIfDefClear(def-forwardIfs[ii]);
 }
 VIR_FREE(def-forwardIfs);
@@ -979,6 +990,9 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
 
 if (forwardDev) {
 def-forwardIfs[0].usageCount = 0;
+def-forwardIfs[0].vfs_in_use_count = 0;
+def-forwardIfs[0].nForwardVfs = 0;
+def-forwardIfs[0].forwardVfs = NULL;
 def-forwardIfs[0].dev = forwardDev;
 forwardDev = NULL;
 def-nForwardIfs++;
@@ -1011,6 +1025,9 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
 def-forwardIfs[ii].dev = forwardDev;
 forwardDev = NULL;
 def-forwardIfs[ii].usageCount = 0;
+def-forwardIfs[ii].vfs_in_use_count = 0;
+def-forwardIfs[ii].nForwardVfs = 0;
+def-forwardIfs[ii].forwardVfs = NULL;
 def-nForwardIfs++;
 }
 }
diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h
index 1be20f8..d1dba94 100644
--- a/src/conf/network_conf.h
+++ b/src/conf/network_conf.h
@@ -112,11 +112,21 @@ struct _virNetworkIpDef {
 virSocketAddr bootserver;
};
 
+typedef struct _virNetworkForwardVfDef virNetworkForwardVfDef;
+typedef virNetworkForwardVfDef *virNetworkForwardVfDefPtr;
+struct _virNetworkForwardVfDef {
+char *dev;
+int usageCount;
+};
+
 typedef struct _virNetworkForwardIfDef virNetworkForwardIfDef;
 typedef virNetworkForwardIfDef *virNetworkForwardIfDefPtr;
 struct _virNetworkForwardIfDef {
 char *dev;  /* name of device */
 int usageCount; /* how many guest interfaces are bound to this device? */
+int vfs_in_use_count; /*if SRIOV, Are any of the Vf's on the dev in use? */
+size_t nForwardVfs;
+virNetworkForwardVfDefPtr forwardVfs;
 };
 
 typedef struct _virPortGroupDef virPortGroupDef;
-- 
1.7.4.4


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


[libvirt] [PATCH 3/5] Adding functions virNetDevGetVirtualFunctions and virNetDevGetNetName virNetDevGetVirtualFunctions: Gets the BDF of all the Virtual Functions given a physical function virNetDevG

2011-11-29 Thread Shradha Shah
---
 src/util/virnetdev.c |   89 ++
 src/util/virnetdev.h |   10 ++
 2 files changed, 99 insertions(+), 0 deletions(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 86196a1..d07d8fa 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -968,6 +968,76 @@ virNetDevSysfsDeviceFile(char **pf_sysfs_device_link, 
const char *ifname,
 }
 
 /**
+ * virNetDevGetVirtualFunctions:
+ *
+ * @pfname : name of the physical function interface name
+ * @virt_fns: array that will hold the pointers to the virtual_functions
+ * @num_virt_fns: number of virtual functions
+ *
+ * Returns 0 on success and -1 on failure
+ */
+
+int
+virNetDevGetVirtualFunctions(const char *pfname, 
+ struct pci_config_address ***virt_fns,
+ unsigned int *num_virt_fns)
+{
+int ret = -1;
+char *pf_sysfs_device_link = NULL;
+
+
+if (virNetDevSysfsFile(pf_sysfs_device_link, pfname, device)  0)
+return ret;
+
+if (pciGetVirtualFunctions(pf_sysfs_device_link, virt_fns,
+   num_virt_fns)  0) 
+goto out;
+ret = 0;
+
+out:
+VIR_FREE(pf_sysfs_device_link);
+return ret;
+}
+
+/**
+ * virNetDevGetNetName:
+ *
+ * @vf : pci address (BDF) of the Virtual Function
+ * @vfname: interface name of the virtual function returned by this function
+ *
+ * Returns 0 on success and -1 on failure
+ */
+
+int 
+virNetDevGetNetName(struct pci_config_address *vf, char **vfname)
+{
+int ret = -1;
+pciDevice *dev = NULL;
+char *pci_sysfs_device_link = NULL;
+
+dev = pciGetDevice(vf-domain, vf-bus, vf-slot, vf-function);
+if (dev != NULL) {
+if (pciSysfsFile(pci_sysfs_device_link, dev-name)  0) {
+virReportSystemError(ENOSYS, %s,
+ _(Failed to get PCI SYSFS file));
+goto out;
+} 
+
+if (pciDeviceNetName(pci_sysfs_device_link, vfname)  0) {
+virReportSystemError(ENOSYS, %s,
+ _(Failed to get interface name of the VF));
+goto out;
+}
+}
+ret = 0;
+
+out:
+VIR_FREE(pci_sysfs_device_link);
+pciFreeDevice(dev);
+return ret;
+}
+
+/**
  * virNetDevIsVirtualFunction:
  * @ifname : name of the interface
  *
@@ -1055,6 +1125,25 @@ virNetDevGetPhysicalFunction(const char *ifname, char 
**pfname)
 }
 #else /* !__linux__ */
 int
+virNetDevGetVirtualFunctions(const char *pfname ATTRIBUTE_UNUSED, 
+ struct pci_config_address ***virt_fns 
ATTRIBUTE_UNUSED,
+ unsigned int *num_virt_fns ATTRIBUTE_UNUSED)
+{
+virReportSystemError(ENOSYS, %s,
+ _(Unable to get virtual functions on this 
platfornm));
+return -1;
+}
+
+int 
+virNetDevGetNetName(struct pci_config_address *vf ATTRIBUTE_UNUSED,
+char **vfname ATTRIBUTE_UNUSED)
+{
+virReportSystemError(ENOSYS, %s,
+ _(Unable to get Device name on this platfornm));
+return -1;
+}
+
+int
 virNetDevIsVirtualFunction(const char *ifname ATTRIBUTE_UNUSED)
 {
 virReportSystemError(ENOSYS, %s,
diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
index 13ba1da..4d1573a 100644
--- a/src/util/virnetdev.h
+++ b/src/util/virnetdev.h
@@ -24,6 +24,7 @@
 # define __VIR_NETDEV_H__
 
 # include virsocketaddr.h
+# include pci.h
 
 int virNetDevExists(const char *brname)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
@@ -99,4 +100,13 @@ int virNetDevGetVirtualFunctionIndex(const char *pfname, 
const char *vfname,
 int virNetDevGetPhysicalFunction(const char *ifname, char **pfname)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
 
+int virNetDevGetVirtualFunctions(const char *pfname, 
+ struct pci_config_address ***virt_fns,
+ unsigned int *num_virt_fns)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
+ATTRIBUTE_RETURN_CHECK;
+
+int virNetDevGetNetName(struct pci_config_address *vf, char **vfname)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+
 #endif /* __VIR_NETDEV_H__ */
-- 
1.7.4.4


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


[libvirt] [PATCH 02/14] Remove internal only virHostPMCapability enum

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The internal virHostPMCapability enum just duplicates the
public virNodeSuspendTarget enum, but with different names.

* src/util/util.c: Use VIR_NODE_SUSPEND_TARGET constants
* src/util/util.h: Remove virHostPMCapability enum
* src/conf/capabilities.c: Use VIR_NODE_SUSPEND_TARGET_LAST
---
 src/conf/capabilities.c |2 +-
 src/util/util.c |   18 +-
 src/util/util.h |8 
 3 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 70f9ab0..a2ca46b 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -36,7 +36,7 @@
 
 #define VIR_FROM_THIS VIR_FROM_CAPABILITIES
 
-VIR_ENUM_IMPL(virHostPMCapability, VIR_HOST_PM_LAST,
+VIR_ENUM_IMPL(virHostPMCapability, VIR_NODE_SUSPEND_TARGET_LAST,
   S3, S4, Hybrid-Suspend)
 
 /**
diff --git a/src/util/util.c b/src/util/util.c
index 34541ec..5bd8c91 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2628,9 +2628,9 @@ virTypedParameterArrayClear(virTypedParameterPtr params, 
int nparams)
  *   the query
  * @feature: The power management feature to check whether it is supported
  *   by the host. Values could be:
- *   VIR_HOST_PM_S3 for Suspend-to-RAM
- *   VIR_HOST_PM_S4 for Suspend-to-Disk
- *   VIR_HOST_PM_HYBRID_SUSPEND for Hybrid-Suspend
+ *   VIR_NODE_SUSPEND_TARGET_MEM
+ *   VIR_NODE_SUSPEND_TARGET_DISK
+ *   VIR_NODE_SUSPEND_TARGET_HYBRID
  *
  * Run the script 'pm-is-supported' (from the pm-utils package)
  * to find out if @feature is supported by the host.
@@ -2645,13 +2645,13 @@ virDiscoverHostPMFeature(unsigned int *bitmask, 
unsigned int feature)
 int ret = -1;
 
 switch (feature) {
-case VIR_HOST_PM_S3:
+case VIR_NODE_SUSPEND_TARGET_MEM:
 cmd = virCommandNewArgList(pm-is-supported, --suspend, NULL);
 break;
-case VIR_HOST_PM_S4:
+case VIR_NODE_SUSPEND_TARGET_DISK:
 cmd = virCommandNewArgList(pm-is-supported, --hibernate, NULL);
 break;
-case VIR_HOST_PM_HYBRID_SUSPEND:
+case VIR_NODE_SUSPEND_TARGET_HYBRID:
 cmd = virCommandNewArgList(pm-is-supported, --suspend-hybrid, 
NULL);
 break;
 default:
@@ -2695,17 +2695,17 @@ virGetPMCapabilities(unsigned int *bitmask)
 *bitmask = 0;
 
 /* Check support for Suspend-to-RAM (S3) */
-ret = virDiscoverHostPMFeature(bitmask, VIR_HOST_PM_S3);
+ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_MEM);
 if (ret  0)
 return -1;
 
 /* Check support for Suspend-to-Disk (S4) */
-ret = virDiscoverHostPMFeature(bitmask, VIR_HOST_PM_S4);
+ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_DISK);
 if (ret  0)
 return -1;
 
 /* Check support for Hybrid-Suspend */
-ret = virDiscoverHostPMFeature(bitmask, VIR_HOST_PM_HYBRID_SUSPEND);
+ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_HYBRID);
 if (ret  0)
 return -1;
 
diff --git a/src/util/util.h b/src/util/util.h
index eda60d2..690fca0 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -263,14 +263,6 @@ void virTypedParameterArrayClear(virTypedParameterPtr 
params, int nparams);
 
 /* Power Management Capabilities of the host system */
 
-enum virHostPMCapability {
-VIR_HOST_PM_S3,  /* Suspend-to-RAM */
-VIR_HOST_PM_S4,  /* Suspend-to-Disk */
-VIR_HOST_PM_HYBRID_SUSPEND,  /* Hybrid-Suspend */
-
-VIR_HOST_PM_LAST
-};
-
 VIR_ENUM_DECL(virHostPMCapability)
 
 int virDiscoverHostPMFeature(unsigned int *bitmask, unsigned int feature);
-- 
1.7.6.4

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


[libvirt] [PATCH 12/14] Remove pointless strdup in node suspend code

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The command name for the suspend action does not need to be
strdup'd. The constant string can be used directly. This
also means the code can be trivially rearranged to make the
switch clearer

* src/util/virnodesuspend.c: Remove strdup of cmdString
---
 src/util/virnodesuspend.c |   49 +++-
 1 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 75a8c2f..3805e9c 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -127,9 +127,7 @@ cleanup:
  */
 static void virNodeSuspend(void *cmdString)
 {
-virCommandPtr suspendCmd = virCommandNew((char *)cmdString);
-
-VIR_FREE(cmdString);
+virCommandPtr suspendCmd = virCommandNew((const char *)cmdString);
 
 /*
  * Delay for sometime so that the function nodeSuspendForDuration()
@@ -183,7 +181,7 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
unsigned int flags)
 {
 static virThread thread;
-char *cmdString = NULL;
+const char *cmdString = NULL;
 int ret = -1;
 unsigned int supported;
 
@@ -209,40 +207,28 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 /* Check if the host supports the requested suspend target */
 switch (target) {
 case VIR_NODE_SUSPEND_TARGET_MEM:
-if (supported  (1  VIR_NODE_SUSPEND_TARGET_MEM)) {
-cmdString = strdup(pm-suspend);
-if (cmdString == NULL) {
-virReportOOMError();
-goto cleanup;
-}
-break;
+if (!(supported  (1  VIR_NODE_SUSPEND_TARGET_MEM))) {
+virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, 
_(Suspend-to-RAM));
+goto cleanup;
 }
-virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, 
_(Suspend-to-RAM));
-goto cleanup;
+cmdString = pm-suspend;
+break;
 
 case VIR_NODE_SUSPEND_TARGET_DISK:
-if (supported  (1  VIR_NODE_SUSPEND_TARGET_DISK)) {
-cmdString = strdup(pm-hibernate);
-if (cmdString == NULL) {
-virReportOOMError();
-goto cleanup;
-}
-break;
+if (!(supported  (1  VIR_NODE_SUSPEND_TARGET_DISK))) {
+virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, 
_(Suspend-to-Disk));
+goto cleanup;
 }
-virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, 
_(Suspend-to-Disk));
-goto cleanup;
+cmdString = pm-hibernate;
+break;
 
 case VIR_NODE_SUSPEND_TARGET_HYBRID:
-if (supported  (1  VIR_NODE_SUSPEND_TARGET_HYBRID)) {
-cmdString = strdup(pm-suspend-hybrid);
-if (cmdString == NULL) {
-virReportOOMError();
-goto cleanup;
-}
-break;
+if (!(supported  (1  VIR_NODE_SUSPEND_TARGET_HYBRID))) {
+virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, 
_(Hybrid-Suspend));
+goto cleanup;
 }
-virNodeSuspendError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s, 
_(Hybrid-Suspend));
-goto cleanup;
+cmdString = pm-suspend-hybrid;
+break;
 
 default:
 virNodeSuspendError(VIR_ERR_INVALID_ARG, %s, _(Invalid suspend 
target));
@@ -262,7 +248,6 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 ret = 0;
 cleanup:
 virNodeSuspendUnlock();
-VIR_FREE(cmdString);
 return ret;
 }
 
-- 
1.7.6.4

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


[libvirt] [PATCH 14/14] Don't mark suspend as active until we know it is running

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

If suspend failed for some reason (eg too short duration) then
susquent attempts to trigger suspend were rejected because we
had already marked a suspend as being in progress

* src/util/virnodesuspend.c: Don't mark suspend as active
  until we've successfully triggered it
---
 src/util/virnodesuspend.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 3805e9c..f585847 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -202,7 +202,6 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 _(Suspend operation already in progress));
 goto cleanup;
 }
-aboutToSuspend = true;
 
 /* Check if the host supports the requested suspend target */
 switch (target) {
@@ -245,6 +244,7 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 goto cleanup;
 }
 
+aboutToSuspend = true;
 ret = 0;
 cleanup:
 virNodeSuspendUnlock();
-- 
1.7.6.4

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


[libvirt] [PATCH 10/14] Remove powerMgmt_valid field from capabilities struct

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

If we ensure that virNodeSuspendGetTargetMask always resets
*bitmask to zero upon failure, there is no need for the
powerMgmt_valid field.

* src/util/virnodesuspend.c: Ensure *bitmask is zero upon
  failure
* src/conf/capabilities.c, src/conf/capabilities.h: Remove
  powerMgmt_valid field
* src/qemu/qemu_capabilities.c: Remove powerMgmt_valid
---
 src/conf/capabilities.c  |   30 ++
 src/conf/capabilities.h  |1 -
 src/qemu/qemu_capabilities.c |5 +
 src/util/virnodesuspend.c|   10 +++---
 4 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index df5ff23..ac050df 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -696,23 +696,21 @@ virCapabilitiesFormatXML(virCapsPtr caps)
 
 virBufferAddLit(xml, /cpu\n);
 
-if (caps-host.powerMgmt_valid) {
-/* The PM query was successful. */
-if (caps-host.powerMgmt) {
-/* The host supports some PM features. */
-unsigned int pm = caps-host.powerMgmt;
-virBufferAddLit(xml, power_management\n);
-while (pm) {
-int bit = ffs(pm) - 1;
-virBufferAsprintf(xml,   %s/\n,
-virCapsHostPMTargetTypeToString(bit));
-pm = ~(1U  bit);
-}
-virBufferAddLit(xml, /power_management\n);
-} else {
-/* The host does not support any PM feature. */
-virBufferAddLit(xml, power_management/\n);
+/* The PM query was successful. */
+if (caps-host.powerMgmt) {
+/* The host supports some PM features. */
+unsigned int pm = caps-host.powerMgmt;
+virBufferAddLit(xml, power_management\n);
+while (pm) {
+int bit = ffs(pm) - 1;
+virBufferAsprintf(xml,   %s/\n,
+  virCapsHostPMTargetTypeToString(bit));
+pm = ~(1U  bit);
 }
+virBufferAddLit(xml, /power_management\n);
+} else {
+/* The host does not support any PM feature. */
+virBufferAddLit(xml, power_management/\n);
 }
 
 if (caps-host.offlineMigrate) {
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 148c7cc..7f35c17 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -105,7 +105,6 @@ struct _virCapsHost {
 size_t nfeatures;
 size_t nfeatures_max;
 char **features;
-bool powerMgmt_valid;
 unsigned int powerMgmt;/* Bitmask of the PM capabilities.
 * See enum virHostPMCapability.
 */
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 64ab8a8..deef0ea 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -851,11 +851,8 @@ virCapsPtr qemuCapsInit(virCapsPtr old_caps)
 
 /* Add the power management features of the host */
 
-if (virNodeSuspendGetTargetMask(caps-host.powerMgmt)  0) {
+if (virNodeSuspendGetTargetMask(caps-host.powerMgmt)  0)
 VIR_WARN(Failed to get host power management capabilities);
-caps-host.powerMgmt_valid = false;
-} else
-caps-host.powerMgmt_valid = true; /* The PM query succeeded. */
 
 virCapabilitiesAddHostMigrateTransport(caps,
tcp);
diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 4eb5439..6420f5b 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -346,23 +346,27 @@ virNodeSuspendGetTargetMask(unsigned int *bitmask)
 /* Check support for Suspend-to-RAM (S3) */
 ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_MEM, 
supported);
 if (ret  0)
-return -1;
+goto error;
 if (supported)
 *bitmask |= (1  VIR_NODE_SUSPEND_TARGET_MEM);
 
 /* Check support for Suspend-to-Disk (S4) */
 ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_DISK, 
supported);
 if (ret  0)
-return -1;
+goto error;
 if (supported)
 *bitmask |= (1  VIR_NODE_SUSPEND_TARGET_DISK);
 
 /* Check support for Hybrid-Suspend */
 ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_HYBRID, 
supported);
 if (ret  0)
-return -1;
+goto error;
 if (supported)
 *bitmask |= (1  VIR_NODE_SUSPEND_TARGET_HYBRID);
 
 return 0;
+
+error:
+*bitmask = 0;
+return -1;
 }
-- 
1.7.6.4

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


[libvirt] [PATCH 03/14] Fix capabilities XML to use generic terms for suspend targets

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The capabilities XML uses the x86 specific terms 'S3', 'S4'
and 'Hybrid-Syspend'. Switch it to use the same terminology
as the API constants and virsh options, eg 'suspend_mem'
'suspend_disk' and 'syspend_hybrid'

* docs/formatcaps.html.in, docs/schemas/capability.rng,
  src/conf/capabilities.c: Rename suspend constants
---
 docs/formatcaps.html.in |6 +++---
 docs/schemas/capability.rng |6 +++---
 src/conf/capabilities.c |2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
index c1bc2f5..8792533 100644
--- a/docs/formatcaps.html.in
+++ b/docs/formatcaps.html.in
@@ -29,9 +29,9 @@ BIOS you will see/p
   ...
 lt;/cpugt;
 lt;power_managementgt;
-  lt;S3/gt;
-  lt;S4/gt;
-  lt;Hybrid-Suspend/gt;
+  lt;suspend-mem/gt;
+  lt;suspend-disk/gt;
+  lt;suspend-hybrid/gt;
 lt;power_management/gt;
   lt;/hostgt;/span
 
diff --git a/docs/schemas/capability.rng b/docs/schemas/capability.rng
index 6cf2188..3af95e9 100644
--- a/docs/schemas/capability.rng
+++ b/docs/schemas/capability.rng
@@ -112,17 +112,17 @@
 element name='power_management'
   interleave
 optional
-  element name='S3'
+  element name='suspend_mem'
 empty/
   /element
 /optional
 optional
-  element name='S4'
+  element name='suspend_disk'
 empty/
   /element
 /optional
 optional
-  element name='Hybrid-Suspend'
+  element name='suspend_hybrid'
 empty/
   /element
 /optional
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index a2ca46b..ecb1dcd 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -37,7 +37,7 @@
 #define VIR_FROM_THIS VIR_FROM_CAPABILITIES
 
 VIR_ENUM_IMPL(virHostPMCapability, VIR_NODE_SUSPEND_TARGET_LAST,
-  S3, S4, Hybrid-Suspend)
+  suspend_mem, suspend_disk, suspend_hybrid);
 
 /**
  * virCapabilitiesNew:
-- 
1.7.6.4

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


[libvirt] [PATCH 11/14] Do lazy init of host PM features

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

To avoid probing the host power management features on any
call to virInitialize, only initialize the mutex in
virNodeSuspendInit. Do lazy load of the supported PM target
mask when it is actually needed

* src/util/virnodesuspend.c: Lazy init of supported features
---
 src/util/virnodesuspend.c |   99 +++--
 1 files changed, 50 insertions(+), 49 deletions(-)

diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
index 6420f5b..75a8c2f 100644
--- a/src/util/virnodesuspend.c
+++ b/src/util/virnodesuspend.c
@@ -46,9 +46,10 @@
  * Bitmask to hold the Power Management features supported by the host,
  * such as Suspend-to-RAM, Suspend-to-Disk, Hybrid-Suspend etc.
  */
-static unsigned int hostPMFeatures;
+static unsigned int nodeSuspendTargetMask = 0;
+static bool nodeSuspendTargetMaskInit = false;
 
-virMutex virNodeSuspendMutex;
+static virMutex virNodeSuspendMutex;
 
 static bool aboutToSuspend;
 
@@ -75,17 +76,9 @@ static void virNodeSuspendUnlock(void)
  */
 int virNodeSuspendInit(void)
 {
-
 if (virMutexInit(virNodeSuspendMutex)  0)
 return -1;
 
-/* Get the power management capabilities supported by the host */
-hostPMFeatures = 0;
-if (virNodeSuspendGetTargetMask(hostPMFeatures)  0) {
-if (geteuid() == 0)
-VIR_ERROR(_(Failed to get host power management features));
-}
-
 return 0;
 }
 
@@ -191,9 +184,14 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 {
 static virThread thread;
 char *cmdString = NULL;
+int ret = -1;
+unsigned int supported;
 
 virCheckFlags(0, -1);
 
+if (virNodeSuspendGetTargetMask(supported)  0)
+return -1;
+
 /*
  * Ensure that we are the only ones trying to suspend.
  * Fail if somebody has already initiated a suspend.
@@ -202,18 +200,16 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 if (aboutToSuspend) {
 /* A suspend operation is already in progress */
-virNodeSuspendUnlock();
-return -1;
-} else {
-aboutToSuspend = true;
+virNodeSuspendError(VIR_ERR_OPERATION_INVALID, %s,
+_(Suspend operation already in progress));
+goto cleanup;
 }
-
-virNodeSuspendUnlock();
+aboutToSuspend = true;
 
 /* Check if the host supports the requested suspend target */
 switch (target) {
 case VIR_NODE_SUSPEND_TARGET_MEM:
-if (hostPMFeatures  (1  VIR_NODE_SUSPEND_TARGET_MEM)) {
+if (supported  (1  VIR_NODE_SUSPEND_TARGET_MEM)) {
 cmdString = strdup(pm-suspend);
 if (cmdString == NULL) {
 virReportOOMError();
@@ -225,7 +221,7 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 goto cleanup;
 
 case VIR_NODE_SUSPEND_TARGET_DISK:
-if (hostPMFeatures  (1  VIR_NODE_SUSPEND_TARGET_DISK)) {
+if (supported  (1  VIR_NODE_SUSPEND_TARGET_DISK)) {
 cmdString = strdup(pm-hibernate);
 if (cmdString == NULL) {
 virReportOOMError();
@@ -237,7 +233,7 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 goto cleanup;
 
 case VIR_NODE_SUSPEND_TARGET_HYBRID:
-if (hostPMFeatures  (1  VIR_NODE_SUSPEND_TARGET_HYBRID)) {
+if (supported  (1  VIR_NODE_SUSPEND_TARGET_HYBRID)) {
 cmdString = strdup(pm-suspend-hybrid);
 if (cmdString == NULL) {
 virReportOOMError();
@@ -263,11 +259,11 @@ int nodeSuspendForDuration(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 goto cleanup;
 }
 
-return 0;
-
+ret = 0;
 cleanup:
+virNodeSuspendUnlock();
 VIR_FREE(cmdString);
-return -1;
+return ret;
 }
 
 
@@ -338,35 +334,40 @@ cleanup:
 int
 virNodeSuspendGetTargetMask(unsigned int *bitmask)
 {
-int ret;
-bool supported;
+int ret = -1;
 
 *bitmask = 0;
 
-/* Check support for Suspend-to-RAM (S3) */
-ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_MEM, 
supported);
-if (ret  0)
-goto error;
-if (supported)
-*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_MEM);
-
-/* Check support for Suspend-to-Disk (S4) */
-ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_DISK, 
supported);
-if (ret  0)
-goto error;
-if (supported)
-*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_DISK);
-
-/* Check support for Hybrid-Suspend */
-ret = virNodeSuspendSupportsTarget(VIR_NODE_SUSPEND_TARGET_HYBRID, 
supported);
-if (ret  0)
-goto error;
-if (supported)
-*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_HYBRID);
-
-return 0;
+virNodeSuspendLock();
+/* Get the power management capabilities supported by the host */
+if (!nodeSuspendTargetMaskInit) {
+bool supported;
+nodeSuspendTargetMask = 0;
+
+/* Check support for Suspend-to-RAM 

[libvirt] [PATCH 13/14] Add suspend info to Xen, LXC and UML hypervisor capabilities

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

* src/lxc/lxc_conf.c, src/uml/uml_conf.c,
  src/xen/xen_hypervisor.c: Initialize suspend capabilities
* tests/xencapsdata/*xml: Add empty powermgmt capabilities
---
 src/lxc/lxc_conf.c |5 +
 src/uml/uml_conf.c |5 +
 src/xen/xen_hypervisor.c   |4 
 tests/xencapsdata/xen-i686-pae-hvm.xml |1 +
 tests/xencapsdata/xen-i686-pae.xml |1 +
 tests/xencapsdata/xen-i686.xml |1 +
 tests/xencapsdata/xen-ia64-be-hvm.xml  |1 +
 tests/xencapsdata/xen-ia64-be.xml  |1 +
 tests/xencapsdata/xen-ia64-hvm.xml |1 +
 tests/xencapsdata/xen-ia64.xml |1 +
 tests/xencapsdata/xen-ppc64.xml|1 +
 tests/xencapsdata/xen-x86_64-hvm.xml   |1 +
 tests/xencapsdata/xen-x86_64.xml   |1 +
 13 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index 52e99ca..e842736 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -37,6 +37,8 @@
 #include uuid.h
 #include configmake.h
 #include lxc_container.h
+#include virnodesuspend.h
+
 
 #define VIR_FROM_THIS VIR_FROM_LXC
 
@@ -71,6 +73,9 @@ virCapsPtr lxcCapsInit(void)
 VIR_WARN(Failed to query host NUMA topology, disabling NUMA 
capabilities);
 }
 
+if (virNodeSuspendGetTargetMask(caps-host.powerMgmt)  0)
+VIR_WARN(Failed to get host power management capabilities);
+
 if (virGetHostUUID(caps-host.host_uuid)) {
 lxcError(VIR_ERR_INTERNAL_ERROR,
  %s, _(cannot get the host uuid));
diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c
index d4cb12b..a576047 100644
--- a/src/uml/uml_conf.c
+++ b/src/uml/uml_conf.c
@@ -47,6 +47,8 @@
 #include virfile.h
 #include command.h
 #include virnetdevtap.h
+#include virnodesuspend.h
+
 
 #define VIR_FROM_THIS VIR_FROM_UML
 
@@ -81,6 +83,9 @@ virCapsPtr umlCapsInit(void) {
 VIR_WARN(Failed to query host NUMA topology, disabling NUMA 
capabilities);
 }
 
+if (virNodeSuspendGetTargetMask(caps-host.powerMgmt)  0)
+VIR_WARN(Failed to get host power management capabilities);
+
 if (virGetHostUUID(caps-host.host_uuid)) {
 umlReportError(VIR_ERR_INTERNAL_ERROR,
%s, _(cannot get the host uuid));
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 870bc4f..6c71b65 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -66,6 +66,7 @@
 #include capabilities.h
 #include memory.h
 #include virfile.h
+#include virnodesuspend.h
 
 #define VIR_FROM_THIS VIR_FROM_XEN
 
@@ -2743,6 +2744,9 @@ xenHypervisorMakeCapabilities(virConnectPtr conn)
  cpuinfo,
  capabilities);
 
+if (virNodeSuspendGetTargetMask(caps-host.powerMgmt)  0)
+VIR_WARN(Failed to get host power management capabilities);
+
 VIR_FORCE_FCLOSE(cpuinfo);
 VIR_FORCE_FCLOSE(capabilities);
 
diff --git a/tests/xencapsdata/xen-i686-pae-hvm.xml 
b/tests/xencapsdata/xen-i686-pae-hvm.xml
index 42b099c..872e5f6 100644
--- a/tests/xencapsdata/xen-i686-pae-hvm.xml
+++ b/tests/xencapsdata/xen-i686-pae-hvm.xml
@@ -7,6 +7,7 @@
 vmx/
   /features
 /cpu
+power_management/
 migration_features
   live/
   uri_transports
diff --git a/tests/xencapsdata/xen-i686-pae.xml 
b/tests/xencapsdata/xen-i686-pae.xml
index a6cec8a..3dba6eb 100644
--- a/tests/xencapsdata/xen-i686-pae.xml
+++ b/tests/xencapsdata/xen-i686-pae.xml
@@ -7,6 +7,7 @@
 vmx/
   /features
 /cpu
+power_management/
 migration_features
   live/
   uri_transports
diff --git a/tests/xencapsdata/xen-i686.xml b/tests/xencapsdata/xen-i686.xml
index 9071212..22d7685 100644
--- a/tests/xencapsdata/xen-i686.xml
+++ b/tests/xencapsdata/xen-i686.xml
@@ -4,6 +4,7 @@
 cpu
   archi686/arch
 /cpu
+power_management/
 migration_features
   live/
   uri_transports
diff --git a/tests/xencapsdata/xen-ia64-be-hvm.xml 
b/tests/xencapsdata/xen-ia64-be-hvm.xml
index 732b693..222de1d 100644
--- a/tests/xencapsdata/xen-ia64-be-hvm.xml
+++ b/tests/xencapsdata/xen-ia64-be-hvm.xml
@@ -4,6 +4,7 @@
 cpu
   archia64/arch
 /cpu
+power_management/
 migration_features
   live/
   uri_transports
diff --git a/tests/xencapsdata/xen-ia64-be.xml 
b/tests/xencapsdata/xen-ia64-be.xml
index 4f133ec..017816c 100644
--- a/tests/xencapsdata/xen-ia64-be.xml
+++ b/tests/xencapsdata/xen-ia64-be.xml
@@ -4,6 +4,7 @@
 cpu
   archia64/arch
 /cpu
+power_management/
 migration_features
   live/
   uri_transports
diff --git a/tests/xencapsdata/xen-ia64-hvm.xml 
b/tests/xencapsdata/xen-ia64-hvm.xml
index ef48a95..33c4946 100644
--- a/tests/xencapsdata/xen-ia64-hvm.xml
+++ b/tests/xencapsdata/xen-ia64-hvm.xml
@@ -4,6 +4,7 @@
 cpu
   archia64/arch
 /cpu
+

[libvirt] [PATCH 05/14] Sanitize virDiscoverHostPMFeature to return a boolean

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

Since virDiscoverHostPMFeature is just checking one feature,
there is no reason for it to return a bitmask. Change it to
return a boolean

* src/util/util.c, src/util/util.h: Make virDiscoverHostPMFeature
  return a boolean
---
 src/util/util.c |   24 +++-
 src/util/util.h |2 +-
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 5bd8c91..badfa3a 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -2624,13 +2624,12 @@ virTypedParameterArrayClear(virTypedParameterPtr 
params, int nparams)
 
 /**
  * virDiscoverHostPMFeature:
- * @bitmask: The bitmask which should be populated with the result of
- *   the query
  * @feature: The power management feature to check whether it is supported
  *   by the host. Values could be:
  *   VIR_NODE_SUSPEND_TARGET_MEM
  *   VIR_NODE_SUSPEND_TARGET_DISK
  *   VIR_NODE_SUSPEND_TARGET_HYBRID
+ * @supported: set to true if supported, false otherwise
  *
  * Run the script 'pm-is-supported' (from the pm-utils package)
  * to find out if @feature is supported by the host.
@@ -2638,12 +2637,14 @@ virTypedParameterArrayClear(virTypedParameterPtr 
params, int nparams)
  * Returns 0 if the query was successful, -1 on failure.
  */
 int
-virDiscoverHostPMFeature(unsigned int *bitmask, unsigned int feature)
+virDiscoverHostPMFeature(unsigned int feature, bool *supported)
 {
 virCommandPtr cmd;
 int status;
 int ret = -1;
 
+*supported = false;
+
 switch (feature) {
 case VIR_NODE_SUSPEND_TARGET_MEM:
 cmd = virCommandNewArgList(pm-is-supported, --suspend, NULL);
@@ -2665,9 +2666,7 @@ virDiscoverHostPMFeature(unsigned int *bitmask, unsigned 
int feature)
 * Check return code of command == 0 for success
 * (i.e., the PM capability is supported)
 */
-if (status == 0)
-*bitmask |= 1U  feature;
-
+*supported = (status == 0);
 ret = 0;
 
 cleanup:
@@ -2691,23 +2690,30 @@ int
 virGetPMCapabilities(unsigned int *bitmask)
 {
 int ret;
+bool supported;
 
 *bitmask = 0;
 
 /* Check support for Suspend-to-RAM (S3) */
-ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_MEM);
+ret = virDiscoverHostPMFeature(VIR_NODE_SUSPEND_TARGET_MEM, supported);
 if (ret  0)
 return -1;
+if (supported)
+*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_MEM);
 
 /* Check support for Suspend-to-Disk (S4) */
-ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_DISK);
+ret = virDiscoverHostPMFeature(VIR_NODE_SUSPEND_TARGET_DISK, supported);
 if (ret  0)
 return -1;
+if (supported)
+*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_DISK);
 
 /* Check support for Hybrid-Suspend */
-ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_HYBRID);
+ret = virDiscoverHostPMFeature(VIR_NODE_SUSPEND_TARGET_HYBRID, supported);
 if (ret  0)
 return -1;
+if (supported)
+*bitmask |= (1  VIR_NODE_SUSPEND_TARGET_HYBRID);
 
 return 0;
 }
diff --git a/src/util/util.h b/src/util/util.h
index 204e2b9..6a9de7e 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -263,7 +263,7 @@ void virTypedParameterArrayClear(virTypedParameterPtr 
params, int nparams);
 
 /* Power Management Capabilities of the host system */
 
-int virDiscoverHostPMFeature(unsigned int *bitmask, unsigned int feature);
+int virDiscoverHostPMFeature(unsigned int feature, bool *supported);
 int virGetPMCapabilities(unsigned int *bitmask);
 
 #endif /* __VIR_UTIL_H__ */
-- 
1.7.6.4

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


[libvirt] [PATCH 08/14] Add export of node suspend capabilities APIs

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

* src/libvirt_private.syms: Export virNodeSuspendSupportsTarget
  and virNodeSuspendGetTargetMask
---
 src/libvirt_private.syms |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 9f2a224..a0754f2 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1332,6 +1332,8 @@ virNetTLSContextNewServerPath;
 # virnodesuspend.h
 nodeSuspendForDuration;
 virNodeSuspendInit;
+virNodeSuspendGetTargetMask;
+virNodeSuspendSupportsTarget;
 
 
 # virpidfile.h
-- 
1.7.6.4

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


[libvirt] [PATCH 5/5] If a system has 64 or more VF's, it is quite tedious to mention each VF in the interface pool. The following modification find a Free VF given a Physical Function when mode=passt

2011-11-29 Thread Shradha Shah
---
 src/network/bridge_driver.c |  208 +--
 1 files changed, 179 insertions(+), 29 deletions(-)

diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index c49c25b..a2e3119 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -55,6 +55,7 @@
 #include memory.h
 #include uuid.h
 #include iptables.h
+#include pci.h
 #include logging.h
 #include dnsmasq.h
 #include configmake.h
@@ -2823,8 +2824,11 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
 goto cleanup;
 } else {
 int ii;
-virNetworkForwardIfDefPtr dev = NULL;
-
+virNetworkForwardVfDefPtr dev = NULL;
+unsigned int vf_found = 0;
+unsigned int num_virt_fns = 0;
+struct pci_config_address **virt_fns = NULL;
+  
 /* pick an interface from the pool */
 
 /* PASSTHROUGH mode, and PRIVATE Mode + 802.1Qbh both require
@@ -2832,32 +2836,105 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
  * 0.  Other modes can share, so just search for the one with
  * the lowest usageCount.
  */
-if ((netdef-forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) ||
-((netdef-forwardType == VIR_NETWORK_FORWARD_PRIVATE) 
- iface-data.network.actual-data.direct.virtPortProfile 
- 
(iface-data.network.actual-data.direct.virtPortProfile-virtPortType
-  == VIR_NETDEV_VPORT_PROFILE_8021QBH))) {
-/* pick first dev with 0 usageCount */
 
+if (netdef-forwardType == VIR_NETWORK_FORWARD_PASSTHROUGH) {  
   
+if (netdef-nForwardIfs == 1) {
+if (netdef-forwardIfs[0].vfs_in_use_count == 0) {
+if 
((virNetDevGetVirtualFunctions(netdef-forwardIfs[0].dev, 
+  virt_fns, 
num_virt_fns))  0){
+networkReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Could not get Virtual 
functions on %s),
+   netdef-forwardIfs[0].dev);
+goto out;
+}
+
+netdef-forwardIfs[0].nForwardVfs = num_virt_fns;
+
+if ((VIR_ALLOC_N(netdef-forwardIfs[0].forwardVfs, 
+ netdef-forwardIfs[0].nForwardVfs))  
0) {
+virReportOOMError();
+goto out;
+}
+
+for (ii = 0; ii  netdef-forwardIfs[0].nForwardVfs; 
ii++) {
+if ((virNetDevGetNetName(virt_fns[ii], 
+ 
netdef-forwardIfs[0].forwardVfs[ii].dev))  0) {
+networkReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Could not get Interface 
name));
+goto out;
+}
+netdef-forwardIfs[0].forwardVfs[ii].usageCount = 
0;
+}
+}
+
+for (ii = 0; ii  netdef-forwardIfs[0].nForwardVfs; ii++) 
{
+if (netdef-forwardIfs[0].forwardVfs[ii].usageCount == 
0) {
+netdef-forwardIfs[0].vfs_in_use_count++;
+dev = netdef-forwardIfs[0].forwardVfs[ii];
+vf_found = 1;
+break;
+}
+}
+/* If No Vf's are present or if Vf's are in use 
+ * check whether the PF is free and assign PF
+ * to dev 
+ */
+if(vf_found == 0) {
+networkReportError(VIR_ERR_INTERNAL_ERROR,
+   _(No Free Vf's on %s, checking if 
PF is free),
+   netdef-forwardIfs[0].dev);
+if (netdef-forwardIfs[0].usageCount == 0) {
+dev = (virNetworkForwardVfDef 
*)netdef-forwardIfs[0];
+}
+}
+vf_found = 0;
+}
+/* If more than 1 ForwardIfs are present check usagecount of 
each
+ * find the one that is free
+ */
+else {
+for (ii = 0; ii  netdef-nForwardIfs; ii++) {
+if (netdef-forwardIfs[ii].usageCount == 0) {
+dev = (virNetworkForwardVfDef 
*)netdef-forwardIfs[ii];
+break;
+}
+}
+   

[libvirt] [PATCH 1/5] Moving the declaration of _pciDevice and _pciDeviceList to pci.h

2011-11-29 Thread Shradha Shah
---
 src/util/pci.c |   35 ---
 src/util/pci.h |   34 ++
 2 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/src/util/pci.c b/src/util/pci.c
index cd82b43..857078d 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -45,45 +45,10 @@
 # define MODPROBE modprobe
 #endif
 
-#define PCI_SYSFS /sys/bus/pci/
-#define PCI_ID_LEN 10   /*   */
-#define PCI_ADDR_LEN 13 /* :XX:XX.X */
-
 #define SRIOV_FOUND 0
 #define SRIOV_NOT_FOUND 1
 #define SRIOV_ERROR -1
 
-struct _pciDevice {
-unsigned  domain;
-unsigned  bus;
-unsigned  slot;
-unsigned  function;
-
-char  name[PCI_ADDR_LEN]; /* domain:bus:slot.function */
-char  id[PCI_ID_LEN]; /* product vendor */
-char  *path;
-const char*used_by;   /* The domain which uses the device */
-int   fd;
-
-unsigned  initted;
-unsigned  pcie_cap_pos;
-unsigned  pci_pm_cap_pos;
-unsigned  has_flr : 1;
-unsigned  has_pm_reset : 1;
-unsigned  managed : 1;
-
-/* used by reattach function */
-unsigned  unbind_from_stub : 1;
-unsigned  remove_slot : 1;
-unsigned  reprobe : 1;
-};
-
-struct _pciDeviceList {
-unsigned count;
-pciDevice **devs;
-};
-
-
 /* For virReportOOMError()  and virReportSystemError() */
 #define VIR_FROM_THIS VIR_FROM_NONE
 
diff --git a/src/util/pci.h b/src/util/pci.h
index 76e37e3..8e47fc2 100644
--- a/src/util/pci.h
+++ b/src/util/pci.h
@@ -24,9 +24,43 @@
 
 # include internal.h
 
+#define PCI_SYSFS /sys/bus/pci/
+#define PCI_ID_LEN 10   /*   */
+#define PCI_ADDR_LEN 13 /* :XX:XX.X */
+
 typedef struct _pciDevice pciDevice;
 typedef struct _pciDeviceList pciDeviceList;
 
+struct _pciDevice {
+unsigned  domain;
+unsigned  bus;
+unsigned  slot;
+unsigned  function;
+
+char  name[PCI_ADDR_LEN]; /* domain:bus:slot.function */
+char  id[PCI_ID_LEN]; /* product vendor */
+char  *path;
+const char*used_by;   /* The domain which uses the device */
+int   fd;
+
+unsigned  initted;
+unsigned  pcie_cap_pos;
+unsigned  pci_pm_cap_pos;
+unsigned  has_flr : 1;
+unsigned  has_pm_reset : 1;
+unsigned  managed : 1;
+
+/* used by reattach function */
+unsigned  unbind_from_stub : 1;
+unsigned  remove_slot : 1;
+unsigned  reprobe : 1;
+};
+
+struct _pciDeviceList {
+unsigned count;
+pciDevice **devs;
+};
+
 struct pci_config_address {
 unsigned int domain;
 unsigned int bus;
-- 
1.7.4.4


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


[libvirt] [PATCH 0/5] Interface pools and passthrough mode

2011-11-29 Thread Shradha Shah
Interface Pools and Passthrough mode:

Current Method:
The passthrough mode uses a macvtap “direct” connection to connect each 
guest to the network. The physical interface to be used is picked from among 
those listed in interface sub elements of the forward element.

The current specification for forward extends to allow 0 or more interface 
sub-elements:
Example:
forward mode='passthrough' dev='eth10'/
interface dev='eth10'/
interface dev='eth12'/
interface dev='eth18'/
interface dev='eth20'/
/forward

However with an ethernet card with 64 VF's or more, the above method gets 
tedious on the system.

On the other hand, just parameterizing a string (eth%d) is inadequate, eg, when 
there are multiple non-contiguous ranges.

Proposed Method:
The 5 patches provided along with this introductory e-mail 

i) Introduce a structure to store the state of all the virtual functions 
attached to each physical function  
ii) Find a free virtual function given the physical function.

The forward specification will hence only mention the physical function as the 
interface sub element:
Example:
forward mode='passthrough' dev='eth2'/
interface dev='eth2'/
/forward

Shradha Shah (5):
  Moving the declaration of _pciDevice and _pciDeviceList to pci.h
  Added function pciSysfsFile to enable access to the PCI SYSFS files.
  Adding functions virNetDevGetVirtualFunctions and virNetDevGetNetName
virNetDevGetVirtualFunctions: Gets the BDF of all the Virtual
Functions given a physical function virNetDevGetNetName: Gets
the interface name of the PCI Device.
  Addition of a new device structure to store the state of a Virtual
Function Modifications to the Physical Device Structure to
store state of its Virtual Functions
  If a system has 64 or more VF's, it is quite tedious to mention each
VF in the interface pool. The following modification find a
Free VF given a Physical Function when mode=passthrough. We
also save the state of each VF. Hence modifications to
networkAllocateActualDevice, networkNotifyActualDevice and
networkReleaseActualDevice were required. The following
patch does just that.

 src/conf/network_conf.c |   19 -
 src/conf/network_conf.h |   10 ++
 src/network/bridge_driver.c |  208 +--
 src/util/pci.c  |   52 ---
 src/util/pci.h  |   36 
 src/util/virnetdev.c|   89 ++
 src/util/virnetdev.h|   10 ++
 7 files changed, 359 insertions(+), 65 deletions(-)

-- 
1.7.4.4

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

Re: [libvirt] [PATCH 02/14] Remove internal only virHostPMCapability enum

2011-11-29 Thread Eric Blake
On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The internal virHostPMCapability enum just duplicates the
 public virNodeSuspendTarget enum, but with different names.
 
 * src/util/util.c: Use VIR_NODE_SUSPEND_TARGET constants
 * src/util/util.h: Remove virHostPMCapability enum
 * src/conf/capabilities.c: Use VIR_NODE_SUSPEND_TARGET_LAST
 ---
  src/conf/capabilities.c |2 +-
  src/util/util.c |   18 +-
  src/util/util.h |8 
  3 files changed, 10 insertions(+), 18 deletions(-)
 

 +++ b/src/util/util.h
 @@ -263,14 +263,6 @@ void virTypedParameterArrayClear(virTypedParameterPtr 
 params, int nparams);
  
  /* Power Management Capabilities of the host system */
  
 -enum virHostPMCapability {
 -VIR_HOST_PM_S3,  /* Suspend-to-RAM */
 -VIR_HOST_PM_S4,  /* Suspend-to-Disk */
 -VIR_HOST_PM_HYBRID_SUSPEND,  /* Hybrid-Suspend */
 -
 -VIR_HOST_PM_LAST
 -};
 -
  VIR_ENUM_DECL(virHostPMCapability)

Also drop the VIR_ENUM_DECL(virHostPMCapability).

ACK to the intent, but this is incomplete.

-- 
Eric Blake   ebl...@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 04/14] Move the virHostPMCapability enum helpers into capabilities.c

2011-11-29 Thread Eric Blake
On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The virHostPMCapability enum helper was declared in util.h
 but implemented in capabilities.c, which is in a completely
 separate library at link time. Move the declaration into the
 capabilities.c file and rename it to match normal conventions
 
 * src/util/util.h: Remove virHostPMCapability enum decl
 * src/conf/capabilities.c: Add virCapsHostPMTarget enm

s/enm/enum/

ACK, and fixes my comment from patch 2/14 :)

-- 
Eric Blake   ebl...@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 03/14] Fix capabilities XML to use generic terms for suspend targets

2011-11-29 Thread Eric Blake
On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The capabilities XML uses the x86 specific terms 'S3', 'S4'
 and 'Hybrid-Syspend'. Switch it to use the same terminology
 as the API constants and virsh options, eg 'suspend_mem'
 'suspend_disk' and 'syspend_hybrid'

s/syspend/suspend/

 
 * docs/formatcaps.html.in, docs/schemas/capability.rng,
   src/conf/capabilities.c: Rename suspend constants
 ---
  docs/formatcaps.html.in |6 +++---
  docs/schemas/capability.rng |6 +++---
  src/conf/capabilities.c |2 +-
  3 files changed, 7 insertions(+), 7 deletions(-)
 

 diff --git a/docs/formatcaps.html.in b/docs/formatcaps.html.in
 index c1bc2f5..8792533 100644
 --- a/docs/formatcaps.html.in
 +++ b/docs/formatcaps.html.in
 @@ -29,9 +29,9 @@ BIOS you will see/p
...
  lt;/cpugt;
  lt;power_managementgt;
 -  lt;S3/gt;
 -  lt;S4/gt;
 -  lt;Hybrid-Suspend/gt;
 +  lt;suspend-mem/gt;
 +  lt;suspend-disk/gt;
 +  lt;suspend-hybrid/gt;
  lt;power_management/gt;

3 typos - per the .rng, this should be suspend_mem, not suspend-mem, and
so forth for the other '-'.

 +++ b/src/conf/capabilities.c
 @@ -37,7 +37,7 @@
  #define VIR_FROM_THIS VIR_FROM_CAPABILITIES
  
  VIR_ENUM_IMPL(virHostPMCapability, VIR_NODE_SUSPEND_TARGET_LAST,
 -  S3, S4, Hybrid-Suspend)
 +  suspend_mem, suspend_disk, suspend_hybrid);

ACK with nit fixed.

-- 
Eric Blake   ebl...@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 01/14] Fix values of PM target type constants

2011-11-29 Thread Eric Blake
On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 The VIR_NODE_SUSPEND_TARGET constants are not flags, so they
 should just be assigned straightforward incrementing values.
 
 * include/libvirt/libvirt.h.in: Change VIR_NODE_SUSPEND_TARGET
   values
 ---
  include/libvirt/libvirt.h.in |9 ++---
  1 files changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
 index f8ca5cf..f32b197 100644
 --- a/include/libvirt/libvirt.h.in
 +++ b/include/libvirt/libvirt.h.in
 @@ -257,9 +257,12 @@ typedef enum {
   * transitioned to.
   */
  typedef enum {
 -VIR_NODE_SUSPEND_TARGET_MEM = (1  0),
 -VIR_NODE_SUSPEND_TARGET_DISK= (1  1),
 -VIR_NODE_SUSPEND_TARGET_HYBRID  = (1  2),
 +VIR_NODE_SUSPEND_TARGET_MEM = 0,
 +VIR_NODE_SUSPEND_TARGET_DISK= 1,
 +VIR_NODE_SUSPEND_TARGET_HYBRID  = 2,
 +
 +/* This constant is subject to change */
 +VIR_NODE_SUSPEND_TARGET_LAST,

ACK.  And agree that it is an API-changer, so it must go in now before
we release and solidify the API.

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



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

[libvirt] [PATCH] Fix leak build config file path

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

* src/libvirt.c: Free user directory path
---
 src/libvirt.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index cdd111c..55ef743 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -974,8 +974,11 @@ virConnectConfigFile(void)
 goto error;
 
 if (virAsprintf(path, %s/.libvirt/libvirt.conf,
-userdir)  0)
+userdir)  0) {
+VIR_FREE(userdir);
 goto no_memory;
+}
+VIR_FREE(userdir);
 }
 
 return path;
-- 
1.7.6.4

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


Re: [libvirt] [PATCH 06/14] Rename suspend capabilities APIs

2011-11-29 Thread Srivatsa S. Bhat
On 11/29/2011 09:14 PM, Daniel P. Berrange wrote:

 From: Daniel P. Berrange berra...@redhat.com
 
 Rename virGetPMCapabilities to virNodeSuspendGetTargetMask and
 virDiscoverHostPMFeature to virNodeSuspendSupportsTarget.
 
 * src/util/util.c, src/util/util.h: Rename APIs
 * src/qemu/qemu_capabilities.c, src/util/virnodesuspend.c: Adjust
   for new names
 ---
  src/qemu/qemu_capabilities.c |2 +-
  src/util/util.c  |   22 +++---
  src/util/util.h  |4 ++--
  src/util/virnodesuspend.c|2 +-
  4 files changed, 15 insertions(+), 15 deletions(-)
 
 diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
 index c5fe41d..4bbfd78 100644
 --- a/src/qemu/qemu_capabilities.c
 +++ b/src/qemu/qemu_capabilities.c
 @@ -850,7 +850,7 @@ virCapsPtr qemuCapsInit(virCapsPtr old_caps)
 
  /* Add the power management features of the host */
 
 -if (virGetPMCapabilities(caps-host.powerMgmt)  0) {
 +if (virNodeSuspendGetTargetMask(caps-host.powerMgmt)  0) {
  VIR_WARN(Failed to get host power management capabilities);
  caps-host.powerMgmt_valid = false;
  } else
 diff --git a/src/util/util.c b/src/util/util.c
 index badfa3a..72fbdac 100644
 --- a/src/util/util.c
 +++ b/src/util/util.c
 @@ -2623,8 +2623,8 @@ virTypedParameterArrayClear(virTypedParameterPtr 
 params, int nparams)
  }
 
  /**
 - * virDiscoverHostPMFeature:
 - * @feature: The power management feature to check whether it is supported
 + * virNodeSuspendSupportsTarget:
 + * @target: The power management target to check whether it is supported
   *   by the host. Values could be:
   *   VIR_NODE_SUSPEND_TARGET_MEM
   *   VIR_NODE_SUSPEND_TARGET_DISK
 @@ -2632,12 +2632,12 @@ virTypedParameterArrayClear(virTypedParameterPtr 
 params, int nparams)
   * @supported: set to true if supported, false otherwise
   *
   * Run the script 'pm-is-supported' (from the pm-utils package)
 - * to find out if @feature is supported by the host.
 + * to find out if @target is supported by the host.
   *
   * Returns 0 if the query was successful, -1 on failure.
   */
  int
 -virDiscoverHostPMFeature(unsigned int feature, bool *supported)
 +virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
  {
  virCommandPtr cmd;
  int status;
 @@ -2645,7 +2645,7 @@ virDiscoverHostPMFeature(unsigned int feature, bool 
 *supported)
 
  *supported = false;
 
 -switch (feature) {
 +switch (target) {
  case VIR_NODE_SUSPEND_TARGET_MEM:
  cmd = virCommandNewArgList(pm-is-supported, --suspend, NULL);
  break;
 @@ -2675,19 +2675,19 @@ cleanup:
  }
 
  /**
 - * virGetPMCapabilities:
 + * virNodeSuspendGetTargetMask:
   *
   * Get the Power Management Capabilities that the host system supports,
   * such as Suspend-to-RAM (S3), Suspend-to-Disk (S4) and Hybrid-Suspend
   * (a combination of S3 and S4).
   *


You might want to remove the terminology S3, S4 etc from here, perhaps?

-- 
Regards,
Srivatsa S. Bhat
IBM Linux Technology Center

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


Re: [libvirt] [PATCH 05/14] Sanitize virDiscoverHostPMFeature to return a boolean

2011-11-29 Thread Eric Blake
On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
 From: Daniel P. Berrange berra...@redhat.com
 
 Since virDiscoverHostPMFeature is just checking one feature,
 there is no reason for it to return a bitmask. Change it to
 return a boolean
 
 * src/util/util.c, src/util/util.h: Make virDiscoverHostPMFeature
   return a boolean
 ---
  src/util/util.c |   24 +++-
  src/util/util.h |2 +-
  2 files changed, 16 insertions(+), 10 deletions(-)

ACK.

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



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

[libvirt] [PATCH 01/14] Fix values of PM target type constants

2011-11-29 Thread Daniel P. Berrange
From: Daniel P. Berrange berra...@redhat.com

The VIR_NODE_SUSPEND_TARGET constants are not flags, so they
should just be assigned straightforward incrementing values.

* include/libvirt/libvirt.h.in: Change VIR_NODE_SUSPEND_TARGET
  values
---
 include/libvirt/libvirt.h.in |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index f8ca5cf..f32b197 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -257,9 +257,12 @@ typedef enum {
  * transitioned to.
  */
 typedef enum {
-VIR_NODE_SUSPEND_TARGET_MEM = (1  0),
-VIR_NODE_SUSPEND_TARGET_DISK= (1  1),
-VIR_NODE_SUSPEND_TARGET_HYBRID  = (1  2),
+VIR_NODE_SUSPEND_TARGET_MEM = 0,
+VIR_NODE_SUSPEND_TARGET_DISK= 1,
+VIR_NODE_SUSPEND_TARGET_HYBRID  = 2,
+
+/* This constant is subject to change */
+VIR_NODE_SUSPEND_TARGET_LAST,
 } virNodeSuspendTarget;
 
 /**
-- 
1.7.6.4

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


Re: [libvirt] [PATCH 02/14] Remove internal only virHostPMCapability enum

2011-11-29 Thread Daniel P. Berrange
On Tue, Nov 29, 2011 at 09:13:57AM -0700, Eric Blake wrote:
 On 11/29/2011 08:44 AM, Daniel P. Berrange wrote:
  From: Daniel P. Berrange berra...@redhat.com
  
  The internal virHostPMCapability enum just duplicates the
  public virNodeSuspendTarget enum, but with different names.
  
  * src/util/util.c: Use VIR_NODE_SUSPEND_TARGET constants
  * src/util/util.h: Remove virHostPMCapability enum
  * src/conf/capabilities.c: Use VIR_NODE_SUSPEND_TARGET_LAST
  ---
   src/conf/capabilities.c |2 +-
   src/util/util.c |   18 +-
   src/util/util.h |8 
   3 files changed, 10 insertions(+), 18 deletions(-)
  
 
  +++ b/src/util/util.h
  @@ -263,14 +263,6 @@ void virTypedParameterArrayClear(virTypedParameterPtr 
  params, int nparams);
   
   /* Power Management Capabilities of the host system */
   
  -enum virHostPMCapability {
  -VIR_HOST_PM_S3,  /* Suspend-to-RAM */
  -VIR_HOST_PM_S4,  /* Suspend-to-Disk */
  -VIR_HOST_PM_HYBRID_SUSPEND,  /* Hybrid-Suspend */
  -
  -VIR_HOST_PM_LAST
  -};
  -
   VIR_ENUM_DECL(virHostPMCapability)
 
 Also drop the VIR_ENUM_DECL(virHostPMCapability).
 
 ACK to the intent, but this is incomplete.

See patch 4 :-)


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


  1   2   >