[libvirt] [PATCH] LXC: remove duplicate controller check code

2014-07-07 Thread Chen Hanxiao
We invoked virCgroupHasController twice for checking
VIR_CGROUP_CONTROLLER_DEVICES
in lxcDomainAttachDeviceDiskLive.

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
 src/lxc/lxc_driver.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index fce16f2..9c006e9 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -4052,12 +4052,6 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
 goto cleanup;
 }
 
-if (!virCgroupHasController(priv-cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) {
-virReportError(VIR_ERR_OPERATION_INVALID, %s,
-   _(devices cgroup isn't mounted));
-goto cleanup;
-}
-
 perms = (def-readonly ?
  VIR_CGROUP_DEVICE_READ :
  VIR_CGROUP_DEVICE_RW) |
-- 
1.9.0

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


[libvirt] [PATCH] Free the return value of virFileFindResource

2014-07-07 Thread Ján Tomko
Commits e18a80a and 57e5c3c switched from a getenv wrapper which
does not allocate a string to virFileFindResource which does not,
without freeing it.

https://bugzilla.redhat.com/show_bug.cgi?id=1116427
---
 src/locking/lock_driver_lockd.c | 2 ++
 src/remote/remote_driver.c  | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index c67bda6..1ca7772 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -273,11 +273,13 @@ static virNetClientPtr 
virLockManagerLockDaemonConnectionNew(bool privileged,
 if (virNetClientAddProgram(client, *prog)  0)
 goto error;
 
+VIR_FREE(daemonPath);
 VIR_FREE(lockdpath);
 
 return client;
 
  error:
+VIR_FREE(daemonPath);
 VIR_FREE(lockdpath);
 virNetClientClose(client);
 virObjectUnref(client);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 88fc977..9d8120f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1068,6 +1068,9 @@ doRemoteOpen(virConnectPtr conn,
 VIR_FREE(pkipath);
 VIR_FREE(knownHostsVerify);
 VIR_FREE(knownHosts);
+#ifndef WIN32
+VIR_FREE(daemonPath);
+#endif
 
 return retcode;
 
-- 
1.8.5.5

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


Re: [libvirt] [PATCH] Free the return value of virFileFindResource

2014-07-07 Thread Peter Krempa
On 07/07/14 08:33, Ján Tomko wrote:
 Commits e18a80a and 57e5c3c switched from a getenv wrapper which
 does not allocate a string to virFileFindResource which does not,
 without freeing it.
 
 https://bugzilla.redhat.com/show_bug.cgi?id=1116427
 ---
  src/locking/lock_driver_lockd.c | 2 ++
  src/remote/remote_driver.c  | 3 +++
  2 files changed, 5 insertions(+)


The bug talks just about the defect in src/remote/remote_driver.c but
definitely worth fixing both places.

ACK

Peter




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

Re: [libvirt] [PATCH] Free the return value of virFileFindResource

2014-07-07 Thread Martin Kletzander

On Mon, Jul 07, 2014 at 08:33:37AM +0200, Ján Tomko wrote:

Commits e18a80a and 57e5c3c switched from a getenv wrapper which
does not allocate a string to virFileFindResource which does not,
without freeing it.

https://bugzilla.redhat.com/show_bug.cgi?id=1116427
---
src/locking/lock_driver_lockd.c | 2 ++
src/remote/remote_driver.c  | 3 +++
2 files changed, 5 insertions(+)

diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index c67bda6..1ca7772 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -273,11 +273,13 @@ static virNetClientPtr 
virLockManagerLockDaemonConnectionNew(bool privileged,
if (virNetClientAddProgram(client, *prog)  0)
goto error;

+VIR_FREE(daemonPath);
VIR_FREE(lockdpath);

return client;

 error:
+VIR_FREE(daemonPath);
VIR_FREE(lockdpath);
virNetClientClose(client);
virObjectUnref(client);
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 88fc977..9d8120f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1068,6 +1068,9 @@ doRemoteOpen(virConnectPtr conn,
VIR_FREE(pkipath);
VIR_FREE(knownHostsVerify);
VIR_FREE(knownHosts);
+#ifndef WIN32
+VIR_FREE(daemonPath);
+#endif



Would this compile on windows without warning if this free was ran
unconditionally and the conditional around its declaration was removed
as well?

ACK either way,

Martin


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

Re: [libvirt] [PATCH] LXC: remove duplicate controller check code

2014-07-07 Thread Martin Kletzander

On Mon, Jul 07, 2014 at 02:26:57PM +0800, Chen Hanxiao wrote:

We invoked virCgroupHasController twice for checking
VIR_CGROUP_CONTROLLER_DEVICES
in lxcDomainAttachDeviceDiskLive.

Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
---
src/lxc/lxc_driver.c | 6 --
1 file changed, 6 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index fce16f2..9c006e9 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -4052,12 +4052,6 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
goto cleanup;
}

-if (!virCgroupHasController(priv-cgroup, VIR_CGROUP_CONTROLLER_DEVICES)) {
-virReportError(VIR_ERR_OPERATION_INVALID, %s,
-   _(devices cgroup isn't mounted));
-goto cleanup;
-}
-
perms = (def-readonly ?
 VIR_CGROUP_DEVICE_READ :
 VIR_CGROUP_DEVICE_RW) |
--
1.9.0



ACK  Pushed.

Martin


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

[libvirt] [PATCH] qemu: dump: Report better error when dumping VM with passthrough devices

2014-07-07 Thread Peter Krempa
For the regular dump operation we migrate the VM to a file. This won't
work when the VM has passthrough devices assigned. Rather than reporting
a cryptic error from qemu run our check whether it can be migrated.

This does not influence the memory-only dump that is allowed with
passthrough devices.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=874418
---
 src/qemu/qemu_driver.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d1aa9e..fe76d55 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3481,6 +3481,10 @@ doCoreDump(virQEMUDriverPtr driver,
  memory-only dump));
 goto cleanup;
 }
+
+if (!qemuMigrationIsAllowed(driver, vm, vm-def, false, false))
+goto cleanup;
+
 ret = qemuMigrationToFile(driver, vm, fd, 0, path,
   qemuCompressProgramName(compress), false,
   QEMU_ASYNC_JOB_DUMP);
-- 
2.0.0

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


[libvirt] Where to get precompiled qga-vss.dll from ?

2014-07-07 Thread Puneet Bakshi
Hi,

I want to work with guest-fsfreeze-* commands in Windows 2008 guest VM.
Host is CentOS 6.4.

Windows 2008 is running QEMU VSS provider. When guest-fsfreeze-* commands
are invoked from host, response received is This is not supported.

I am following
http://lists.gnu.org/archive/html/qemu-devel/2013-02/msg01963.html.

Regards,
~Puneet
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] qemu: dump: Report better error when dumping VM with passthrough devices

2014-07-07 Thread Martin Kletzander

On Mon, Jul 07, 2014 at 10:05:22AM +0200, Peter Krempa wrote:

For the regular dump operation we migrate the VM to a file. This won't
work when the VM has passthrough devices assigned. Rather than reporting
a cryptic error from qemu run our check whether it can be migrated.

This does not influence the memory-only dump that is allowed with
passthrough devices.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=874418
---
src/qemu/qemu_driver.c | 4 
1 file changed, 4 insertions(+)



ACK,

Martin


diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d1aa9e..fe76d55 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3481,6 +3481,10 @@ doCoreDump(virQEMUDriverPtr driver,
 memory-only dump));
goto cleanup;
}
+
+if (!qemuMigrationIsAllowed(driver, vm, vm-def, false, false))
+goto cleanup;
+
ret = qemuMigrationToFile(driver, vm, fd, 0, path,
  qemuCompressProgramName(compress), false,
  QEMU_ASYNC_JOB_DUMP);
--
2.0.0

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


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

Re: [libvirt] [PATCH] qemu: dump: Report better error when dumping VM with passthrough devices

2014-07-07 Thread Peter Krempa
On 07/07/14 10:41, Martin Kletzander wrote:
 On Mon, Jul 07, 2014 at 10:05:22AM +0200, Peter Krempa wrote:
 For the regular dump operation we migrate the VM to a file. This won't
 work when the VM has passthrough devices assigned. Rather than reporting
 a cryptic error from qemu run our check whether it can be migrated.

 This does not influence the memory-only dump that is allowed with
 passthrough devices.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=874418
 ---
 src/qemu/qemu_driver.c | 4 
 1 file changed, 4 insertions(+)

 
 ACK,
 

Pushed; Thanks.

Peter




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

Re: [libvirt] [PATCH] virsh: domain: Use inactive XML when unplugging interface with --config

2014-07-07 Thread Ján Tomko
On 07/04/2014 03:08 PM, Peter Krempa wrote:
 Similary to cmdDetachDisk fetch the inactive definition when --config

*Similarly

 is specified as the active may not contain the network interface
 if it was plugged with --config.
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1056902
 ---
  tools/virsh-domain.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)

ACK

Jan



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

Re: [libvirt] [libvirt-glib] [PATCH v4 1/3] libvirt-gobject-domain: Add _fetch_snapshots

2014-07-07 Thread Christophe Fergeau
On Mon, Jun 30, 2014 at 07:50:14PM +0200, Timm Bäder wrote:
 This function can be used to fetch the snapshots of a domain (according
 to the given GVirDomainSnapshotListFlags) and save them in a
 domain-internal GHashTable. A function to access them from outside will
 be added in a later patch.
 ---
  libvirt-gobject/libvirt-gobject-domain.c | 83 
 
  libvirt-gobject/libvirt-gobject-domain.h | 37 ++
  libvirt-gobject/libvirt-gobject.sym  |  2 +
  3 files changed, 122 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
 b/libvirt-gobject/libvirt-gobject-domain.c
 index c6e30e5..180a206 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -38,6 +38,8 @@ struct _GVirDomainPrivate
  {
  virDomainPtr handle;
  gchar uuid[VIR_UUID_STRING_BUFLEN];
 +GHashTable *snapshots;
 +GMutex *lock;
  };
  
  G_DEFINE_TYPE(GVirDomain, gvir_domain, G_TYPE_OBJECT);
 @@ -121,6 +123,11 @@ static void gvir_domain_finalize(GObject *object)
  
  g_debug(Finalize GVirDomain=%p, domain);
  
 +if (priv-snapshots) {
 +g_hash_table_unref(priv-snapshots);
 +}
 +g_mutex_free(priv-lock);
 +
  virDomainFree(priv-handle);
  
  G_OBJECT_CLASS(gvir_domain_parent_class)-finalize(object);
 @@ -237,6 +244,7 @@ static void gvir_domain_init(GVirDomain *domain)
  g_debug(Init GVirDomain=%p, domain);
  
  domain-priv = GVIR_DOMAIN_GET_PRIVATE(domain);
 +domain-priv-lock = g_mutex_new();
  }
  
  typedef struct virDomain GVirDomainHandle;
 @@ -1514,3 +1522,78 @@ gvir_domain_create_snapshot(GVirDomain *dom,
  g_free(custom_xml);
  return dom_snapshot;
  }
 +
 +
 +
 +/**
 + * gvir_domain_fetch_snapshots:
 + * @dom: The domain
 + * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
 + * @cancellable: (allow-none)(transfer-none): cancellation object
 + * @error: (allow-none): Place-holder for error or NULL
 + *
 + * Returns: TRUE on success, FALSE otherwise.
 + */
 +gboolean gvir_domain_fetch_snapshots(GVirDomain *dom,
 + guint list_flags,
 + GCancellable *cancellable,
 + GError **error)
 +{
 +GVirDomainPrivate *priv;
 +virDomainSnapshotPtr *snapshots = NULL;
 +GVirDomainSnapshot *snap;
 +GHashTable *snap_table;
 +int n_snaps = 0;
 +int i;
 +gboolean ret = TRUE;
 +
 +g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
 +g_return_val_if_fail((error == NULL) || (*error == NULL), FALSE);
 +
 +priv = dom-priv;
 +
 +snap_table = g_hash_table_new_full(g_str_hash,
 +   g_str_equal,
 +   NULL,
 +   g_object_unref);
 +
 +
 +n_snaps = virDomainListAllSnapshots(priv-handle, snapshots, 
 list_flags);
 +
 +if (g_cancellable_set_error_if_cancelled(cancellable, error)) {
 +ret = FALSE;
 +goto cleanup;
 +}
 +
 +if (n_snaps  0) {
 +gvir_set_error(error, GVIR_DOMAIN_ERROR, 0,
 +   Unable to fetch snapshots of %s,
 +   gvir_domain_get_name(dom));
 +ret = FALSE;
 +goto cleanup;
 +}
 +
 +for (i = 0; i  n_snaps; i ++) {
 +if (g_cancellable_set_error_if_cancelled(cancellable, error)) {
 +ret = FALSE;
 +goto cleanup;
 +}
 +snap = GVIR_DOMAIN_SNAPSHOT(g_object_new(GVIR_TYPE_DOMAIN_SNAPSHOT,
 + handle, snapshots[i],
 + NULL));
 +g_hash_table_insert(snap_table,
 +(gpointer)gvir_domain_snapshot_get_name(snap),
 +snap);
 +}
 +
 +
 +g_mutex_lock(priv-lock);
 +if (priv-snapshots != NULL)
 +g_hash_table_unref(priv-snapshots);
 +priv-snapshots = snap_table;
 +g_mutex_unlock(priv-lock);
 +
 +cleanup:

This is leaking 'snap_table' in error cases. You can have a if
(snap_table != NULL) { g_hash_table_unref (snap_table); } here, and set
snap_table to NULL right before the cleanup: label.


 +free(snapshots);
 +return ret;
 +}
 diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
 b/libvirt-gobject/libvirt-gobject-domain.h
 index 38d3458..8c1a8e5 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.h
 +++ b/libvirt-gobject/libvirt-gobject-domain.h
 @@ -183,6 +183,39 @@ typedef enum {
  GVIR_DOMAIN_REBOOT_GUEST_AGENT= VIR_DOMAIN_REBOOT_GUEST_AGENT,
  } GVirDomainRebootFlags;
  
 +/**
 + * GVirDomainSnapshotListFlags:
 + * @GVIR_DOMAIN_SNAPSHOT_LIST_ALL: List all snapshots
 + * @GVIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS: List all descendants, not just
 + * children, when listing a snapshot.
 + * For historical reasons, 

Re: [libvirt] [libvirt-glib] [PATCH v4 2/3] libvirt-gobject-domain: Add _get_snapshots

2014-07-07 Thread Christophe Fergeau
Hey,

On Mon, Jun 30, 2014 at 07:50:15PM +0200, Timm Bäder wrote:
 ... which returns a GList of GVirDomainSnapshots, i.e. without any tree
 structure or other relationship between the snapshots.

Looks good, ACK. Any plans to return the snapshots as a tree at some
point? Or can the library user reconstruct this tree information from
the current API?

Christophe


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

Re: [libvirt] [PATCHv2 0/2] smartcard/serial/parallel/console/channel auditing

2014-07-07 Thread Ján Tomko
On 07/04/2014 02:25 PM, Peter Krempa wrote:
 V2 adds docs to docs/auditlog.html.in and doesn't log the shared 
 serial/console
 def twice. Sending for sanity review of language :)
 
 Peter Krempa (2):
   audit: Add auditing for serial/parallel/channel/console character devs
   audit: Audit smartcard devices
 
  docs/auditlog.html.in| 35 +++
  src/conf/domain_audit.c  | 90 
 
  src/conf/domain_audit.h  |  7 
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_hotplug.c  | 17 +
  5 files changed, 144 insertions(+), 6 deletions(-)
 

ACK series, the language looks sane to me.

Jan



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

Re: [libvirt] [PATCH] LXC: introduce lxcDomainSetMemoryFlags

2014-07-07 Thread Ján Tomko
On 07/04/2014 10:21 AM, Chen Hanxiao wrote:
 In lxc, we could not use setmem command
 with --config options.
 This patch will add support for this.
 
 Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
 ---
  src/lxc/lxc_driver.c | 52 
 ++--
  1 file changed, 42 insertions(+), 10 deletions(-)
 
 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
 index 79c3b4a..68795cb 100644
 --- a/src/lxc/lxc_driver.c
 +++ b/src/lxc/lxc_driver.c
 @@ -706,11 +706,19 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, 
 unsigned long newmax)
  return ret;
  }
  
 -static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
 +static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
 +unsigned int flags)

Indentation looks off.

  {
  virDomainObjPtr vm;
 +virDomainDefPtr persistentDef = NULL;
 +virCapsPtr caps = NULL;
  int ret = -1;
  virLXCDomainObjPrivatePtr priv;
 +virLXCDriverPtr driver = dom-conn-privateData;
 +virLXCDriverConfigPtr cfg = NULL;
 +
 +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
 +  VIR_DOMAIN_AFFECT_CONFIG, -1);
  
  if (!(vm = lxcDomObjFromDomain(dom)))
  goto cleanup;
 @@ -720,22 +728,38 @@ static int lxcDomainSetMemory(virDomainPtr dom, 
 unsigned long newmem)
  if (virDomainSetMemoryEnsureACL(dom-conn, vm-def)  0)
  goto cleanup;

'make check' complains about a mismatched ACL check:
./lxc/lxc_driver.c:728 Mismatch check 'virDomainSetMemoryEnsureACL' for
function 'lxcDomainSetMemoryFlags'


  
 +if (!(caps = virLXCDriverGetCapabilities(driver, false)))
 +goto cleanup;
 +
 +if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
 +persistentDef)  0)
 +goto cleanup;
 +

  if (newmem  vm-def-mem.max_balloon) {
  virReportError(VIR_ERR_INVALID_ARG,
 %s, _(Cannot set memory higher than max memory));
  goto cleanup;
  }

This check is only valid for AFFECT_LIVE. For AFFECT_CONFIG, a separate check
is needed.

  
 -if (!virDomainObjIsActive(vm)) {
 -virReportError(VIR_ERR_OPERATION_INVALID,
 -   %s, _(Domain is not running));
 -goto cleanup;
 -}
 + if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
 + cfg = virLXCDriverGetConfig(driver);
 + persistentDef-mem.cur_balloon = newmem;
 + if (virDomainSaveConfig(cfg-configDir, persistentDef)  0)
 + goto cleanup;
 + }
  
 -if (virCgroupSetMemory(priv-cgroup, newmem)  0) {
 -virReportError(VIR_ERR_OPERATION_FAILED,
 -   %s, _(Failed to set memory for domain));
 -goto cleanup;
 +if (flags  VIR_DOMAIN_AFFECT_LIVE) {

 +if (!virDomainObjIsActive(vm)) {
 +virReportError(VIR_ERR_OPERATION_INVALID,
 +   %s, _(Domain is not running));
 +goto cleanup;
 +}

virDomainLiveConfigHelperMethod already checked if the domain is running when
AFFECT_LIVE is specified.

 +
 +if (virCgroupSetMemory(priv-cgroup, newmem)  0) {
 +virReportError(VIR_ERR_OPERATION_FAILED,
 +   %s, _(Failed to set memory for domain));
 +goto cleanup;
 +}
  }
  
  ret = 0;


Jan




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] virt-lxc-convert: make free return values in bytes

2014-07-07 Thread Ján Tomko
On 07/04/2014 03:58 PM, Cédric Bosdonnat wrote:
 Tiny fix for virt-lxc-convert: we are setting memory values in bytes, while
 free may give us values in a different unit by default: force free to output
 bytes with -b flag.
 
 ---
  examples/lxcconvert/virt-lxc-convert | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 

ACK; pushed.

Jan




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

Re: [libvirt] [libvirt-glib] [PATCH v4 3/3] GVirDomain: Add async version of _fetch_snapshots

2014-07-07 Thread Christophe Fergeau
Hey,

On Mon, Jun 30, 2014 at 07:50:16PM +0200, Timm Bäder wrote:
 ---
  libvirt-gobject/libvirt-gobject-domain.c | 60 
 
  libvirt-gobject/libvirt-gobject-domain.h | 10 ++
  libvirt-gobject/libvirt-gobject.sym  |  2 ++
  3 files changed, 72 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
 b/libvirt-gobject/libvirt-gobject-domain.c
 index b12a4a0..6b53d25 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -1618,3 +1618,63 @@ GList *gvir_domain_get_snapshots(GVirDomain *dom)
  
  return snapshots;
  }
 +
 +
 +
 +static void _fetch_snapshots_async_thread(GTask *task,
 +  gpointer source_object,
 +  gpointer task_data,
 +  GCancellable *cancellable) {
 +GError *error = NULL;
 +gboolean status;
 +
 +status = gvir_domain_fetch_snapshots(source_object,
 + GPOINTER_TO_UINT(task_data),
 + cancellable,
 + error);
 +if (status)
 +g_task_return_boolean(task, TRUE);
 +else
 +g_task_return_error(task, error);
 +}
 +
 +
 +/**
 + *
 + * @dom: The domain
 + * @list_flags: bitwise-OR of #GVirDomainSnapshotListFlags
 + * @cancellable: (allow-none)(transfer-none): cancellation object
 + * @callback: (scope async): completion callback
 + * @user_data: (closure): opaque data for callback
 + */
 +void gvir_domain_fetch_snapshots_async(GVirDomain *dom,
 +   guint list_flags,
 +   GCancellable *cancellable,
 +   GAsyncReadyCallback callback,
 +   gpointer user_data) {
 +GTask *task;
 +
 +g_return_if_fail(GVIR_IS_DOMAIN(dom));
 +g_return_if_fail((cancellable == NULL) || G_IS_CANCELLABLE(cancellable));
 +
 +task = g_task_new(dom, cancellable, callback, user_data);

GTask was introduced in glib 2.36, so configure.ac needs to be updated
to reflect that. glib 2.36 was released in March 2013, and is available
in RHEL7, so using this would be fine with me. Others may want to
disagree though :)

 +g_task_set_task_data(task, GUINT_TO_POINTER(list_flags), NULL);
 +g_task_run_in_thread(task, _fetch_snapshots_async_thread);

I'm a bit unclear as how the initial ref obtained through g_task_new()
is handled. Have you checked it's correctly freed after _finish() has
been called and that it's not leaked?

Looks good otherwise.

Christophe


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

Re: [libvirt] [libvirt-glib 2/3] Add GVirConfigDomainCpuModel class

2014-07-07 Thread Christophe Fergeau
On Fri, Jul 04, 2014 at 02:51:27PM +0100, Zeeshan Ali (Khattak) wrote:
 diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c 
 b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c
 new file mode 100644
 index 000..514a2e3
 --- /dev/null
 +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.c
 @@ -0,0 +1,94 @@
 +/*
 + * libvirt-gconfig-domain-cpu-model.c: libvirt domain CPU model
 + *
 + * Copyright (C) 2014 Red Hat, Inc.
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library. If not, see
 + * http://www.gnu.org/licenses/.
 + *
 + * Authors: Zeeshan Ali zee...@redhat.com
 + */
 +
 +#include config.h
 +
 +#include libvirt-gconfig/libvirt-gconfig.h
 +#include libvirt-gconfig/libvirt-gconfig-private.h
 +
 +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_PRIVATE(obj)
  \
 +(G_TYPE_INSTANCE_GET_PRIVATE((obj), 
 GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, GVirConfigDomainCpuModelPrivate))
 +
 +struct _GVirConfigDomainCpuModelPrivate
 +{
 +gboolean unused;
 +};
 +
 +G_DEFINE_TYPE(GVirConfigDomainCpuModel, gvir_config_domain_cpu_model, 
 GVIR_CONFIG_TYPE_OBJECT);

Here this inherits from GVirConfigObject...

 diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h 
 b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h
 new file mode 100644
 index 000..5ae9d14
 --- /dev/null
 +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h
 @@ -0,0 +1,72 @@
 +/*
 + * libvirt-gconfig-domain-cpu-model.h: libvirt domain CPU model
 + *
 + * Copyright (C) 2014 Red Hat, Inc.
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library. If not, see
 + * http://www.gnu.org/licenses/.
 + *
 + * Authors: Zeeshan Ali zee...@redhat.com
 + */
 +
 +#if !defined(__LIBVIRT_GCONFIG_H__)  !defined(LIBVIRT_GCONFIG_BUILD)
 +#error Only libvirt-gconfig/libvirt-gconfig.h can be included directly.
 +#endif
 +
 +#ifndef __LIBVIRT_GCONFIG_DOMAIN_CPU_MODEL_H__
 +#define __LIBVIRT_GCONFIG_DOMAIN_CPU_MODEL_H__
 +
 +G_BEGIN_DECLS
 +
 +#define GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL
 (gvir_config_domain_cpu_model_get_type ())
 +#define GVIR_CONFIG_DOMAIN_CPU_MODEL(obj)
 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, 
 GVirConfigDomainCpuModel))
 +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_CLASS(klass)
 (G_TYPE_CHECK_CLASS_CAST ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, 
 GVirConfigDomainCpuModelClass))
 +#define GVIR_CONFIG_IS_DOMAIN_CPU_MODEL(obj) 
 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL))
 +#define GVIR_CONFIG_IS_DOMAIN_CPU_MODEL_CLASS(klass) 
 (G_TYPE_CHECK_CLASS_TYPE ((klass), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL))
 +#define GVIR_CONFIG_DOMAIN_CPU_MODEL_GET_CLASS(obj)  
 (G_TYPE_INSTANCE_GET_CLASS ((obj), GVIR_CONFIG_TYPE_DOMAIN_CPU_MODEL, 
 GVirConfigDomainCpuModelClass))
 +
 +typedef struct _GVirConfigDomainCpuModel GVirConfigDomainCpuModel;
 +typedef struct _GVirConfigDomainCpuModelPrivate 
 GVirConfigDomainCpuModelPrivate;
 +typedef struct _GVirConfigDomainCpuModelClass GVirConfigDomainCpuModelClass;
 +
 +struct _GVirConfigDomainCpuModel
 +{
 +GVirConfigCapabilitiesCpu parent;

... and here from GVirConfigCapabilitiesCpu.

 +
 +GVirConfigDomainCpuModelPrivate *priv;
 +
 +/* Do not add fields to this struct */
 +};
 +
 +struct _GVirConfigDomainCpuModelClass
 +{
 +GVirConfigCapabilitiesCpuClass parent_class;

(here too)

 +
 +gpointer padding[20];
 +};
 +
 +GType gvir_config_domain_cpu_model_get_type(void);
 +GVirConfigDomainCpuModel *gvir_config_domain_cpu_model_new(void);
 +GVirConfigDomainCpuModel *
 +gvir_config_domain_cpu_model_new_from_xml(const gchar *xml, GError **error);
 +
 +void
 +gvir_config_domain_cpu_model_set_name(GVirConfigDomainCpuModel *model,
 +  const gchar *name);
 +const gchar *
 

Re: [libvirt] [PATCHv2 0/2] smartcard/serial/parallel/console/channel auditing

2014-07-07 Thread Peter Krempa
On 07/07/14 12:36, Ján Tomko wrote:
 On 07/04/2014 02:25 PM, Peter Krempa wrote:
 V2 adds docs to docs/auditlog.html.in and doesn't log the shared 
 serial/console
 def twice. Sending for sanity review of language :)

 Peter Krempa (2):
   audit: Add auditing for serial/parallel/channel/console character devs
   audit: Audit smartcard devices

  docs/auditlog.html.in| 35 +++
  src/conf/domain_audit.c  | 90 
 
  src/conf/domain_audit.h  |  7 
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_hotplug.c  | 17 +
  5 files changed, 144 insertions(+), 6 deletions(-)

 
 ACK series, the language looks sane to me.
 

Thanks; Pushed.

Peter




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

Re: [libvirt] [libvirt-glib 3/3] Add gvir_config_domain_cpu_set_model()

2014-07-07 Thread Christophe Fergeau
On Fri, Jul 04, 2014 at 02:51:28PM +0100, Zeeshan Ali (Khattak) wrote:
 Add a method to set model of domain CPU.
 ---
  libvirt-gconfig/libvirt-gconfig-domain-cpu.c | 11 +++
  libvirt-gconfig/libvirt-gconfig-domain-cpu.h |  4 
  libvirt-gconfig/libvirt-gconfig.sym  |  2 ++
  3 files changed, 17 insertions(+)
 
 diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu.c 
 b/libvirt-gconfig/libvirt-gconfig-domain-cpu.c
 index e7b9575..0037763 100644
 --- a/libvirt-gconfig/libvirt-gconfig-domain-cpu.c
 +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu.c
 @@ -136,3 +136,14 @@ void gvir_config_domain_cpu_set_mode(GVirConfigDomainCpu 
 *cpu,
   mode, GVIR_CONFIG_TYPE_DOMAIN_CPU_MODE, mode,
   NULL);
  }
 +
 +void gvir_config_domain_cpu_set_model(GVirConfigDomainCpu *cpu,
 +  GVirConfigDomainCpuModel *model)
 +{
 +g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_CPU(cpu));
 +g_return_if_fail(model == NULL || 
 GVIR_CONFIG_IS_DOMAIN_CPU_MODEL(model));
 +
 +gvir_config_object_attach_replace(GVIR_CONFIG_OBJECT(cpu),
 +  model,
 +  GVIR_CONFIG_OBJECT(model));
 +}
 diff --git a/libvirt-gconfig/libvirt-gconfig-domain-cpu.h 
 b/libvirt-gconfig/libvirt-gconfig-domain-cpu.h
 index 7efb7eb..f7c0a93 100644
 --- a/libvirt-gconfig/libvirt-gconfig-domain-cpu.h
 +++ b/libvirt-gconfig/libvirt-gconfig-domain-cpu.h
 @@ -28,6 +28,8 @@
  #ifndef __LIBVIRT_GCONFIG_DOMAIN_CPU_H__
  #define __LIBVIRT_GCONFIG_DOMAIN_CPU_H__
  
 +#include libvirt-gconfig/libvirt-gconfig-domain-cpu-model.h
 +
  G_BEGIN_DECLS
  
  #define GVIR_CONFIG_TYPE_DOMAIN_CPU
 (gvir_config_domain_cpu_get_type ())
 @@ -80,6 +82,8 @@ GVirConfigDomainCpuMatchPolicy
  gvir_config_domain_cpu_get_match_policy(GVirConfigDomainCpu *cpu);
  void gvir_config_domain_cpu_set_mode(GVirConfigDomainCpu *cpu,
   GVirConfigDomainCpuMode mode);
 +void gvir_config_domain_cpu_set_model(GVirConfigDomainCpu *cpu,
 +  GVirConfigDomainCpuModel *model);
  GVirConfigDomainCpuMode
  gvir_config_domain_cpu_get_mode(GVirConfigDomainCpu *cpu);
  
 diff --git a/libvirt-gconfig/libvirt-gconfig.sym 
 b/libvirt-gconfig/libvirt-gconfig.sym
 index 1ad7e18..072e9b8 100644
 --- a/libvirt-gconfig/libvirt-gconfig.sym
 +++ b/libvirt-gconfig/libvirt-gconfig.sym
 @@ -703,6 +703,8 @@ global:
   gvir_config_domain_chardev_source_spiceport_new_from_xml;
   gvir_config_domain_chardev_source_spiceport_set_channel;
  
 + gvir_config_domain_cpu_set_model;
 +

Same comment about this breaking make syntax-check, looks good
otherwise.

   gvir_config_domain_cpu_model_get_type;
   gvir_config_domain_cpu_model_new;
   gvir_config_domain_cpu_model_get_name;
 -- 
 1.9.3
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [libvirt-glib 1/3] Add gvir_config_capabilities_cpu_get_model()

2014-07-07 Thread Christophe Fergeau
This is returning a char * 
capabilities
  host
cpu
  modelxxx/model
/cpu
  /host
/capabilities
while the next patch exposes the model from the /domain/cpu/model node
as an actual object, why the difference?

Christophe

On Fri, Jul 04, 2014 at 02:51:26PM +0100, Zeeshan Ali (Khattak) wrote:
 Add a method to get the model of the CPU from capabilities.
 ---
  libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c | 6 ++
  libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h | 2 ++
  libvirt-gconfig/libvirt-gconfig.sym| 2 ++
  3 files changed, 10 insertions(+)
 
 diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c 
 b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
 index f4753ff..255c4d7 100644
 --- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
 +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
 @@ -60,6 +60,12 @@ 
 gvir_config_capabilities_cpu_get_arch(GVirConfigCapabilitiesCpu *cpu)
  return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(cpu), 
 arch);
  }
  
 +const gchar *
 +gvir_config_capabilities_cpu_get_model(GVirConfigCapabilitiesCpu *cpu)
 +{
 +return gvir_config_object_get_node_content(GVIR_CONFIG_OBJECT(cpu), 
 model);
 +}
 +
  /**
   * gvir_config_capabilities_cpu_add_feature:
   *
 diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h 
 b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
 index ce3613f..c6c152f 100644
 --- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
 +++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
 @@ -66,6 +66,8 @@ GType gvir_config_capabilities_cpu_get_type(void);
  
  const gchar *
  gvir_config_capabilities_cpu_get_arch(GVirConfigCapabilitiesCpu *cpu);
 +const gchar *
 +gvir_config_capabilities_cpu_get_model(GVirConfigCapabilitiesCpu *cpu);
  void gvir_config_capabilities_cpu_add_feature(GVirConfigCapabilitiesCpu *cpu,

 GVirConfigCapabilitiesCpuFeature *feature);
  GList *
 diff --git a/libvirt-gconfig/libvirt-gconfig.sym 
 b/libvirt-gconfig/libvirt-gconfig.sym
 index 0d33fdb..86dada6 100644
 --- a/libvirt-gconfig/libvirt-gconfig.sym
 +++ b/libvirt-gconfig/libvirt-gconfig.sym
 @@ -689,6 +689,8 @@ global:
  
  LIBVIRT_GCONFIG_0.1.9 {
  global:
 + gvir_config_capabilities_cpu_get_model;
 +
   gvir_config_capabilities_host_get_secmodels;
  
   gvir_config_capabilities_host_secmodel_get_doi;
 -- 
 1.9.3
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [PATCH] virsh: domain: Use inactive XML when unplugging interface with --config

2014-07-07 Thread Peter Krempa
On 07/07/14 12:24, Ján Tomko wrote:
 On 07/04/2014 03:08 PM, Peter Krempa wrote:
 Similary to cmdDetachDisk fetch the inactive definition when --config
 
 *Similarly
 
 is specified as the active may not contain the network interface
 if it was plugged with --config.

 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1056902
 ---
  tools/virsh-domain.c | 7 ++-
  1 file changed, 6 insertions(+), 1 deletion(-)
 
 ACK
 

Oops I've pushed it without fixing the commit message. Now everybody
will now that I'm terrible at spelling :(

Thanks.

Peter




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

[libvirt] [PATCH] LXC: Allow setting max mem lower than current mem

2014-07-07 Thread Ján Tomko
For inactive domains, set both current and maximum memory
to the specified 'maximum memory' value.

This matches the behavior of QEMU driver's SetMaxMemory.

https://bugzilla.redhat.com/show_bug.cgi?id=1091132
---
 src/lxc/lxc_driver.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9c006e9..b47ac5e 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -692,9 +692,14 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, 
unsigned long newmax)
 goto cleanup;
 
 if (newmax  vm-def-mem.cur_balloon) {
-virReportError(VIR_ERR_INVALID_ARG,
-   %s, _(Cannot set max memory lower than current 
memory));
-goto cleanup;
+if (!virDomainObjIsActive(vm)) {
+vm-def-mem.cur_balloon = newmax;
+} else {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(Cannot set max memory lower than current
+  memory for an active domain));
+goto cleanup;
+}
 }
 
 vm-def-mem.max_balloon = newmax;
-- 
1.8.5.5

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


[libvirt] [PATCH] properly set video ram size for qemu VGA video device

2014-07-07 Thread Pavel Hrdina
https://bugzilla.redhat.com/show_bug.cgi?id=1076098

We support vram option for video devices in domain xml, but so far
only for QXL it had some effect. VGA video device in QEMU can also
accept the size of video ram and we should pass it.

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 src/qemu/qemu_command.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fb64cda..09e29c9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4800,6 +4800,9 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
 
 /* QEMU accepts bytes for vram_size. */
 virBufferAsprintf(buf, ,vram_size=%u, video-vram * 1024);
+} else if (video-type == VIR_DOMAIN_VIDEO_TYPE_VGA) {
+/* QEMU accepts megabytes for vgamem_mb. */
+virBufferAsprintf(buf, ,vgamem_mb=%u, video-vram / 1024);
 }
 
 if (qemuBuildDeviceAddressStr(buf, def, video-info, qemuCaps)  0)
-- 
1.8.5.5

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


[libvirt] [PATCH 3/4] storage: gluster: Optimize header reader functions

2014-07-07 Thread Peter Krempa
The gluster code had two functions for reading volume headers, remove
one and reuse the second one.
---
 src/storage/storage_backend_gluster.c | 43 ++-
 1 file changed, 2 insertions(+), 41 deletions(-)

diff --git a/src/storage/storage_backend_gluster.c 
b/src/storage/storage_backend_gluster.c
index 5ecc098..76d2461 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -651,9 +651,6 @@ virStorageFileBackendGlusterReadHeader(virStorageSourcePtr 
src,
 {
 virStorageFileBackendGlusterPrivPtr priv = src-drv-priv;
 glfs_fd_t *fd = NULL;
-size_t alloc = 0;
-size_t size = 0;
-int save_errno;
 ssize_t ret = -1;

 *buf = NULL;
@@ -661,47 +658,11 @@ 
virStorageFileBackendGlusterReadHeader(virStorageSourcePtr src,
 if (!(fd = glfs_open(priv-vol, src-path, O_RDONLY))) {
 virReportSystemError(errno, _(Failed to open file '%s'),
  src-path);
-goto cleanup;
-}
-
-/* code below is shamelessly stolen from saferead_lim */
-for (;;) {
-int count;
-int requested;
-
-if (size + BUFSIZ + 1  alloc) {
-alloc += alloc / 2;
-if (alloc  size + BUFSIZ + 1)
-alloc = size + BUFSIZ + 1;
-
-if (VIR_REALLOC_N(*buf, alloc)  0) {
-save_errno = errno;
-break;
-}
-}
-
-/* Ensure that (size + requested = max_len); */
-requested = MIN(size  max_len ? max_len - size : 0,
-alloc - size - 1);
-count = glfs_read(fd, *buf + size, requested, 0);
-size += count;
-
-if (count != requested || requested == 0) {
-save_errno = errno;
-if (count  0) {
-virReportSystemError(errno,
- _(cannot read header '%s'), src-path);
-break;
-}
-ret = size;
-goto cleanup;
-}
+return -1;
 }

-VIR_FREE(*buf);
-errno = save_errno;
+ret = virStorageBackendGlusterReadHeader(fd, src-path, max_len, buf);

- cleanup:
 if (fd)
 glfs_close(fd);

-- 
2.0.0

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


[libvirt] [PATCH 0/4] qemu: Support qemuDomainGetBlockInfo on remote storage

2014-07-07 Thread Peter Krempa
And a few refactors.

Peter Krempa (4):
  util: storage: Inline use of virStorageFileGetMetadataFromFDInternal
  util: storage: Allow specifying format for
virStorageFileGetMetadataFromBuf
  storage: gluster: Optimize header reader functions
  qemu: refactor qemuDomainGetBlockInfo to work with remote storage

 src/libvirt_private.syms  |   1 +
 src/qemu/qemu_driver.c|  84 ++-
 src/storage/storage_backend_gluster.c |  48 ++---
 src/util/virstoragefile.c | 124 +++---
 src/util/virstoragefile.h |   5 +-
 5 files changed, 118 insertions(+), 144 deletions(-)

-- 
2.0.0

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


[libvirt] [PATCH 1/4] util: storage: Inline use of virStorageFileGetMetadataFromFDInternal

2014-07-07 Thread Peter Krempa
There was just one callsite left. Integrate the body to the only calling
function.
---
 src/util/virstoragefile.c | 91 ---
 1 file changed, 39 insertions(+), 52 deletions(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 9208b77..01d4a7e 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -973,16 +973,31 @@ virStorageFileGetMetadataFromBuf(const char *path,
 }


-/* Internal version that also supports a containing directory name.  */
-static int
-virStorageFileGetMetadataFromFDInternal(virStorageSourcePtr meta,
-int fd,
-int *backingFormat)
+/**
+ * virStorageFileGetMetadataFromFD:
+ *
+ * Extract metadata about the storage volume with the specified
+ * image format. If image format is VIR_STORAGE_FILE_AUTO, it
+ * will probe to automatically identify the format.  Does not recurse.
+ *
+ * Callers are advised never to use VIR_STORAGE_FILE_AUTO as a
+ * format, since a malicious guest can turn a raw file into any
+ * other non-raw format at will.
+ *
+ * Caller MUST free the result after use via virStorageSourceFree.
+ */
+virStorageSourcePtr
+virStorageFileGetMetadataFromFD(const char *path,
+int fd,
+int format,
+int *backingFormat)
+
 {
+virStorageSourcePtr ret = NULL;
+virStorageSourcePtr meta = NULL;
 char *buf = NULL;
 ssize_t len = VIR_STORAGE_MAX_HEADER;
 struct stat sb;
-int ret = -1;
 int dummy;

 if (!backingFormat)
@@ -992,17 +1007,20 @@ 
virStorageFileGetMetadataFromFDInternal(virStorageSourcePtr meta,

 if (fstat(fd, sb)  0) {
 virReportSystemError(errno,
- _(cannot stat file '%s'),
- meta-relPath);
-return -1;
+ _(cannot stat file '%s'), path);
+return NULL;
 }

+if (!(meta = virStorageFileMetadataNew(path, format)))
+return NULL;
+
 if (S_ISDIR(sb.st_mode)) {
 /* No header to probe for directories, but also no backing file. Just
  * update the metadata.*/
 meta-type = VIR_STORAGE_TYPE_DIR;
 meta-format = VIR_STORAGE_FILE_DIR;
-ret = 0;
+ret = meta;
+meta = NULL;
 goto cleanup;
 }

@@ -1016,51 +1034,20 @@ 
virStorageFileGetMetadataFromFDInternal(virStorageSourcePtr meta,
 goto cleanup;
 }

-ret = virStorageFileGetMetadataInternal(meta, buf, len, backingFormat);
-
-if (ret == 0) {
-if (S_ISREG(sb.st_mode))
-meta-type = VIR_STORAGE_TYPE_FILE;
-else if (S_ISBLK(sb.st_mode))
-meta-type = VIR_STORAGE_TYPE_BLOCK;
-}
- cleanup:
-VIR_FREE(buf);
-return ret;
-}
-
-
-/**
- * virStorageFileGetMetadataFromFD:
- *
- * Extract metadata about the storage volume with the specified
- * image format. If image format is VIR_STORAGE_FILE_AUTO, it
- * will probe to automatically identify the format.  Does not recurse.
- *
- * Callers are advised never to use VIR_STORAGE_FILE_AUTO as a
- * format, since a malicious guest can turn a raw file into any
- * other non-raw format at will.
- *
- * Caller MUST free the result after use via virStorageSourceFree.
- */
-virStorageSourcePtr
-virStorageFileGetMetadataFromFD(const char *path,
-int fd,
-int format,
-int *backingFormat)
-
-{
-virStorageSourcePtr ret;
-
-if (!(ret = virStorageFileMetadataNew(path, format)))
-return NULL;
+if (virStorageFileGetMetadataInternal(meta, buf, len, backingFormat)  0)
+goto cleanup;

+if (S_ISREG(sb.st_mode))
+meta-type = VIR_STORAGE_TYPE_FILE;
+else if (S_ISBLK(sb.st_mode))
+meta-type = VIR_STORAGE_TYPE_BLOCK;

-if (virStorageFileGetMetadataFromFDInternal(ret, fd, backingFormat)  0) {
-virStorageSourceFree(ret);
-return NULL;
-}
+ret = meta;
+meta = NULL;

+ cleanup:
+virStorageSourceFree(meta);
+VIR_FREE(buf);
 return ret;
 }

-- 
2.0.0

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


[libvirt] [PATCH 2/4] util: storage: Allow specifying format for virStorageFileGetMetadataFromBuf

2014-07-07 Thread Peter Krempa
To allow reusing this function in the qemu driver we need to allow to
specify the storage format. Also separate return of the backing store
path now isn't necessary.
---
 src/storage/storage_backend_gluster.c |  5 -
 src/util/virstoragefile.c | 31 ++-
 src/util/virstoragefile.h |  2 +-
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/storage/storage_backend_gluster.c 
b/src/storage/storage_backend_gluster.c
index 1a2b4ec..5ecc098 100644
--- a/src/storage/storage_backend_gluster.c
+++ b/src/storage/storage_backend_gluster.c
@@ -294,10 +294,13 @@ 
virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
 goto cleanup;

 if (!(meta = virStorageFileGetMetadataFromBuf(name, header, len,
-  vol-backingStore.path,
+  VIR_STORAGE_FILE_AUTO,
   vol-backingStore.format)))
 goto cleanup;

+vol-backingStore.path = meta-backingStoreRaw;
+meta-backingStoreRaw = NULL;
+
 vol-target.format = meta-format;
 if (vol-backingStore.path 
 vol-backingStore.format  0)
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 01d4a7e..7ae4642 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -930,13 +930,15 @@ virStorageFileMetadataNew(const char *path,
  * @path: name of file, for error messages
  * @buf: header bytes from @path
  * @len: length of @buf
- * @backing: output malloc'd name of backing image, if any
+ * @format: format of the storage file
  * @backingFormat: format of @backing
  *
- * Extract metadata about the storage volume, including probing its
- * format.  Does not recurse.  Callers are advised not to trust the
- * learned format if a guest has ever used the volume when it was
- * raw, since a malicious guest can turn a raw file into any
+ * Extract metadata about the storage volume with the specified
+ * image format. If image format is VIR_STORAGE_FILE_AUTO, it
+ * will probe to automatically identify the format.  Does not recurse.
+ *
+ * Callers are advised never to use VIR_STORAGE_FILE_AUTO as a
+ * format, since a malicious guest can turn a raw file into any
  * other non-raw format at will.
  *
  * If the returned @backingFormat is VIR_STORAGE_FILE_AUTO
@@ -950,25 +952,20 @@ virStorageSourcePtr
 virStorageFileGetMetadataFromBuf(const char *path,
  char *buf,
  size_t len,
- char **backing,
+ int format,
  int *backingFormat)
 {
 virStorageSourcePtr ret = NULL;
-virStorageSourcePtr meta = NULL;

-if (!(meta = virStorageFileMetadataNew(path, VIR_STORAGE_FILE_AUTO)))
+if (!(ret = virStorageFileMetadataNew(path, format)))
 return NULL;

-if (virStorageFileGetMetadataInternal(meta, buf, len,
-  backingFormat)  0)
-goto cleanup;
-if (VIR_STRDUP(*backing, meta-backingStoreRaw)  0)
-goto cleanup;
+if (virStorageFileGetMetadataInternal(ret, buf, len,
+  backingFormat)  0) {
+virStorageSourceFree(ret);
+return NULL;
+}

-ret = meta;
-meta = NULL;
- cleanup:
-virStorageSourceFree(meta);
 return ret;
 }

diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index 4f7357b..89ecc1e 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -290,7 +290,7 @@ virStorageSourcePtr virStorageFileGetMetadataFromFD(const 
char *path,
 virStorageSourcePtr virStorageFileGetMetadataFromBuf(const char *path,
  char *buf,
  size_t len,
- char **backing,
+ int format,
  int *backingFormat)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(4)
 ATTRIBUTE_NONNULL(5);
-- 
2.0.0

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


[libvirt] [PATCH 4/4] qemu: refactor qemuDomainGetBlockInfo to work with remote storage

2014-07-07 Thread Peter Krempa
The qemu block info function relied on working with local storage. Break
this assumption by adding support for remote volumes. Unfortunately we
still need to take a hybrid approach as some of the operations require a
filedescriptor.

Previously you'd get:
 $ virsh domblkinfo gl vda
 error: cannot stat file '/img10': Bad file descriptor

Now you get some stats:
 $ virsh domblkinfo gl vda
 Capacity:   10485760
 Allocation: 197120
 Physical:   197120

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1110198
---
 src/libvirt_private.syms  |  1 +
 src/qemu/qemu_driver.c| 84 ++-
 src/util/virstoragefile.c |  2 +-
 src/util/virstoragefile.h |  3 ++
 4 files changed, 58 insertions(+), 32 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 18d5f28..6d7bf41 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1910,6 +1910,7 @@ virStorageFileGetSCSIKey;
 virStorageFileIsClusterFS;
 virStorageFileParseChainIndex;
 virStorageFileProbeFormat;
+virStorageFileProbeFormatFromBuf;
 virStorageFileResize;
 virStorageIsFile;
 virStorageNetHostDefClear;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index fe76d55..23f3f08 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10334,11 +10334,13 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
 int activeFail = false;
 virQEMUDriverConfigPtr cfg = NULL;
 char *alias = NULL;
+char *buf = NULL;
+ssize_t len;

 virCheckFlags(0, -1);

 if (!(vm = qemuDomObjFromDomain(dom)))
-goto cleanup;
+return -1;

 cfg = virQEMUDriverGetConfig(driver);

@@ -10346,8 +10348,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
 goto cleanup;

 if (!path || path[0] == '\0') {
-virReportError(VIR_ERR_INVALID_ARG,
-   %s, _(NULL or empty path));
+virReportError(VIR_ERR_INVALID_ARG, %s, _(NULL or empty path));
 goto cleanup;
 }

@@ -10357,48 +10358,68 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
_(invalid path %s not assigned to domain), path);
 goto cleanup;
 }
+
 disk = vm-def-disks[idx];
-path = virDomainDiskGetSource(disk);
-if (!path) {
-virReportError(VIR_ERR_INVALID_ARG,
-   _(disk %s does not currently have a source assigned),
-   path);
-goto cleanup;
-}

-/* The path is correct, now try to open it and get its size. */
-fd = qemuOpenFile(driver, vm, path, O_RDONLY, NULL, NULL);
-if (fd == -1)
-goto cleanup;
+if (virStorageSourceIsLocalStorage(disk-src)) {
+if (!disk-src-path) {
+virReportError(VIR_ERR_INVALID_ARG,
+   _(disk '%s' does not currently have a source 
assigned),
+   path);
+goto cleanup;
+}
+
+if ((fd = qemuOpenFile(driver, vm, path, O_RDONLY, NULL, NULL)) == -1)
+goto cleanup;
+
+if (fstat(fd, sb)  0) {
+virReportSystemError(errno,
+ _(cannot stat file '%s'), disk-src-path);
+goto cleanup;
+}
+
+if ((len = virFileReadHeaderFD(fd, VIR_STORAGE_MAX_HEADER, buf))  0) 
{
+virReportSystemError(errno, _(cannot read header '%s'),
+ disk-src-path);
+goto cleanup;
+}
+} else {
+if (virStorageFileInitAs(disk-src, cfg-user, cfg-group)  0)
+goto cleanup;
+
+if ((len = virStorageFileReadHeader(disk-src, VIR_STORAGE_MAX_HEADER,
+buf))  0)
+goto cleanup;
+
+if (virStorageFileStat(disk-src, sb)  0) {
+virReportSystemError(errno, _(failed to stat remote file '%s'),
+ NULLSTR(disk-src-path));
+goto cleanup;
+}
+}

 /* Probe for magic formats */
 if (virDomainDiskGetFormat(disk)) {
 format = virDomainDiskGetFormat(disk);
 } else {
-if (cfg-allowDiskFormatProbing) {
-if ((format = virStorageFileProbeFormat(path,
-cfg-user,
-cfg-group))  0)
-goto cleanup;
-} else {
+if (!cfg-allowDiskFormatProbing) {
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(no disk format for %s and probing is disabled),
path);
 goto cleanup;
 }
+
+if ((format = virStorageFileProbeFormatFromBuf(disk-src-path,
+   buf, len))  0)
+goto cleanup;
 }

-if (!(meta = virStorageFileGetMetadataFromFD(path, fd, format, NULL)))
+if (!(meta = virStorageFileGetMetadataFromBuf(disk-src-path, buf, len,
+   

Re: [libvirt] [libvirt-glib] [PATCH v4 3/3] GVirDomain: Add async version of _fetch_snapshots

2014-07-07 Thread Christophe Fergeau
On Mon, Jul 07, 2014 at 12:55:33PM +0200, Christophe Fergeau wrote:
 GTask was introduced in glib 2.36, so configure.ac needs to be updated
 to reflect that.

Forgot to add here that the minimum glib requirement is also listed in
libvirt-glib.spec.in. Ideally, this should be changed to be automatically
substituted from whatever is listed in configure.ac.

Christophe


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

Re: [libvirt] [PATCH] LXC: Allow setting max mem lower than current mem

2014-07-07 Thread Peter Krempa
On 07/07/14 13:20, Ján Tomko wrote:
 For inactive domains, set both current and maximum memory
 to the specified 'maximum memory' value.
 
 This matches the behavior of QEMU driver's SetMaxMemory.
 
 https://bugzilla.redhat.com/show_bug.cgi?id=1091132
 ---
  src/lxc/lxc_driver.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)
 

ACK,

Peter




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

[libvirt] [libvirt-glib] spec: Substitute minimum glib2 version from configure.ac

2014-07-07 Thread Christophe Fergeau
This way we don't have to keep track of the minimum glib2 version we
need in 2 separate places.

Signed-off-by: Christophe Fergeau cferg...@redhat.com
---
 configure.ac | 1 +
 libvirt-glib.spec.in | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 097f7f4..80ab703 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,6 +12,7 @@ AM_SILENT_RULES([yes])
 LIBVIRT_REQUIRED=0.10.2
 AC_SUBST([LIBVIRT_REQUIRED]) dnl used in the .spec file
 GLIB2_REQUIRED=2.22.0
+AC_SUBST([GLIB2_REQUIRED]) dnl used in the .spec file
 GLIB2_TEST_REQUIRED=2.38.0
 GOBJECT2_REQUIRED=2.10.0
 GIO_REQUIRED=2.10.0
diff --git a/libvirt-glib.spec.in b/libvirt-glib.spec.in
index 202e624..32ce4f0 100644
--- a/libvirt-glib.spec.in
+++ b/libvirt-glib.spec.in
@@ -30,7 +30,7 @@ URL: http://libvirt.org/
 Source0: ftp://libvirt.org/libvirt/glib/%{name}-%{version}.tar.gz
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
-BuildRequires: glib2-devel = 2.22.0
+BuildRequires: glib2-devel = @GLIB2_REQUIRED@
 BuildRequires: libvirt-devel = %{libvirt_version}
 BuildRequires: python-devel
 %if %{with_introspection}
-- 
1.9.3

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


Re: [libvirt] [libvirt-glib] [PATCH v4 3/3] GVirDomain: Add async version of _fetch_snapshots

2014-07-07 Thread Christophe Fergeau
On Mon, Jul 07, 2014 at 02:19:39PM +0200, Christophe Fergeau wrote:
 Ideally, this should be changed to be automatically substituted from
 whatever is listed in configure.ac.

https://www.redhat.com/archives/libvir-list/2014-July/msg00315.html 
does that.

Christophe


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

Re: [libvirt] [PATCH] properly set video ram size for qemu VGA video device

2014-07-07 Thread Ján Tomko
On 07/07/2014 01:44 PM, Pavel Hrdina wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=1076098
 
 We support vram option for video devices in domain xml, but so far
 only for QXL it had some effect. VGA video device in QEMU can also
 accept the size of video ram and we should pass it.
 

Even if vram is 9 MB as we made up in virDomainVideoDefaultRAM?
IMO we should either treat 9 MB as use the default and not pass it to QEMU,
or just hide the 'vram' attribute (just for the 'weird 9 MB default' cards and
QEMU domains) from non-migratable XML and use a new attribute.

BTW, there were also patches proposing a new attribute:
https://www.redhat.com/archives/libvir-list/2014-June/msg00565.html

 Signed-off-by: Pavel Hrdina phrd...@redhat.com
 ---
  src/qemu/qemu_command.c | 3 +++
  1 file changed, 3 insertions(+)

Documentation and tests are missing.

 
 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
 index fb64cda..09e29c9 100644
 --- a/src/qemu/qemu_command.c
 +++ b/src/qemu/qemu_command.c
 @@ -4800,6 +4800,9 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,
  
  /* QEMU accepts bytes for vram_size. */
  virBufferAsprintf(buf, ,vram_size=%u, video-vram * 1024);
 +} else if (video-type == VIR_DOMAIN_VIDEO_TYPE_VGA) {

VMVGA has vgamem_mb too. Don't we also need a new qemu capability to probe if
this is supported by the QEMU binary?

 +/* QEMU accepts megabytes for vgamem_mb. */
 +virBufferAsprintf(buf, ,vgamem_mb=%u, video-vram / 1024);
  }
  
  if (qemuBuildDeviceAddressStr(buf, def, video-info, qemuCaps)  0)
 

Jan



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

[libvirt] [PATCH] doc: Be more specific about semantics of _REUSE_EXT flag

2014-07-07 Thread Peter Krempa
Snapshots and block-copy have a flag that forces qemu to re-use existing
file. Our docs weren't exactly clear on what the existing file should
contain for this to actually work.

Re-word the docs a bit to state that the file needs to be pre-created in
the desired format and the backing chain metadata needs to be set prior
to handing it over to qemu.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1084360
---
 src/libvirt.c   | 12 +++-
 tools/virsh.pod | 12 +++-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index b80b484..e7a6aca 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -18274,10 +18274,12 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr 
snapshot)
  * destination files already exist as a non-empty regular file, the
  * snapshot is rejected to avoid losing contents of those files.
  * However, if @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT,
- * then the destination files must already exist and contain content
- * identical to the source files (this allows a management app to
- * pre-create files with relative backing file names, rather than the
- * default of creating with absolute backing file names).
+ * then the destination files must be pre-created manually with
+ * the correct image format and metadata including backing store path.
+ * (this allows a management app to pre-create files with relative backing
+ * file names, rather than the default of creating with absolute backing
+ * file names). Note that setting incorrect metadata in the pre-created
+ * image may lead to the VM being unable to start.
  *
  * Be aware that although libvirt prefers to report errors up front with
  * no other effect, some hypervisors have certain types of failures where
@@ -19731,7 +19733,7 @@ virDomainBlockPull(virDomainPtr dom, const char *disk,
  * by adding VIR_DOMAIN_BLOCK_REBASE_COPY_RAW to force the copy to be raw
  * (does not make sense with the shallow flag unless the source is also raw),
  * or by using VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT to reuse an existing file
- * with initial contents identical to the backing file of the source (this
+ * which was pre-created with the correct format and metadata (this
  * allows a management app to pre-create files with relative backing file
  * names, rather than the default of absolute backing file names; as a
  * security precaution, you should generally only use reuse_ext with the
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 1b6f3c4..39fe423 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -875,8 +875,8 @@ flattens the entire chain; but if I--shallow is 
specified, the copy
 shares the backing chain.

 If I--reuse-external is specified, then Idest must exist and have
-contents identical to the resulting backing file (that is, it must
-start with contents matching the backing file Idisk if I--shallow
+metadata identical to the resulting backing file (that is, it must
+start with metadata matching the backing file Idisk if I--shallow
 is used, otherwise it must start empty); this option is typically used
 to set up a relative backing file name in the destination.

@@ -3165,7 +3165,8 @@ metadata again).

 If I--reuse-external is specified, and the snapshot XML requests an
 external snapshot with a destination of an existing file, then the
-destination must exist, and is reused; otherwise, a snapshot is refused
+destination must exist and be pre-created with correct format and
+metadata. The file is then reused; otherwise, a snapshot is refused
 to avoid losing contents of the existing files.

 If I--quiesce is specified, libvirt will try to use guest agent
@@ -3224,8 +3225,9 @@ results in the following XML:

 If I--reuse-external is specified, and the domain XML or Idiskspec
 option requests an external snapshot with a destination of an existing
-file, then the destination must exist, and is reused; otherwise, a
-snapshot is refused to avoid losing contents of the existing files.
+file, then the destination must exist and be pre-created with correct
+format and metadata. The file is then  reused; otherwise, a snapshot
+is refused to avoid losing contents of the existing files.

 If I--quiesce is specified, libvirt will try to use guest agent
 to freeze and unfreeze domain's mounted file systems. However,
-- 
2.0.0

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


Re: [libvirt] [PATCH] properly set video ram size for qemu VGA video device

2014-07-07 Thread Martin Kletzander

On Mon, Jul 07, 2014 at 01:44:06PM +0200, Pavel Hrdina wrote:

https://bugzilla.redhat.com/show_bug.cgi?id=1076098

We support vram option for video devices in domain xml, but so far
only for QXL it had some effect. VGA video device in QEMU can also
accept the size of video ram and we should pass it.

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
src/qemu/qemu_command.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index fb64cda..09e29c9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4800,6 +4800,9 @@ qemuBuildDeviceVideoStr(virDomainDefPtr def,

/* QEMU accepts bytes for vram_size. */
virBufferAsprintf(buf, ,vram_size=%u, video-vram * 1024);
+} else if (video-type == VIR_DOMAIN_VIDEO_TYPE_VGA) {


The patch [1] that adds this option also adds it for VMWare VGA, can
we use that too?


+/* QEMU accepts megabytes for vgamem_mb. */
+virBufferAsprintf(buf, ,vgamem_mb=%u, video-vram / 1024);


How will this behave with pre-1.1.0 qemu (without the commit mentioned
[1])?  Will it (a) just skip the parameter or will it (b) error out?
In case of (b) this is a regression.

Martin

P.S.: Some tests in qemuxml2argv would go nicely with such change.

[1] 4a1e244eb65c646bdd938d9d137ace42d76c95a7


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

[libvirt] [PATCH] Do not allow changing the UUID of a nwfilter

2014-07-07 Thread Ján Tomko
From: Hu Jianwei ji...@redhat.com

https://bugzilla.redhat.com/show_bug.cgi?id=1077009
---
 src/conf/nwfilter_conf.c | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
index 0f633da..52f24e4 100644
--- a/src/conf/nwfilter_conf.c
+++ b/src/conf/nwfilter_conf.c
@@ -3058,6 +3058,17 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
 return NULL;
 }
 virNWFilterObjUnlock(nwfilter);
+} else {
+nwfilter = virNWFilterObjFindByName(nwfilters, def-name);
+if (nwfilter) {
+char uuidstr[VIR_UUID_STRING_BUFLEN];
+virUUIDFormat(nwfilter-def-uuid, uuidstr);
+virReportError(VIR_ERR_OPERATION_FAILED,
+   _(filter '%s' already exists with uuid %s),
+   def-name, uuidstr);
+virNWFilterObjUnlock(nwfilter);
+return NULL;
+}
 }
 
 if (virNWFilterDefLoopDetect(nwfilters, def)  0) {
-- 
1.8.5.5

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


Re: [libvirt] [PATCH] libxl: add discard support to libxl_device_disk

2014-07-07 Thread Olaf Hering
On Fri, May 30, Jim Fehlig wrote:

 Olaf Hering wrote:
  +if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
  +return;
  +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
  +   _(This version of libxenlight does not support 
  + discard= option passing));
 An error would be reported here, but the overall libxlMakeDisk operation
 would succeed right?  Shouldn't it fail if the user requests discard but
 it is not supported?

How would libvirt know if the underlying backing store supports discard?
It would need to maintain a list of supported targets.
If it remains just some sort of warning a given .xml file can be shared
among different libvirt versions. After all, discard is not operation
critical.

Olaf

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


[libvirt] [PATCH v2] libxl: add discard support to libxl_device_disk

2014-07-07 Thread Olaf Hering
Translate libvirt discard settings into libxl-4.5 discard settings.

Signed-off-by: Olaf Hering o...@aepfle.de
---
v2:
 add cast to switch variable to let compiler check if the code handles
 all enum values

 src/libxl/libxl_conf.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 8eeaf82..bb9b53d 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -715,6 +715,33 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
 return -1;
 }
 
+static void
+libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
+{
+if (!x_disk-readwrite)
+return;
+#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
+switch ((enum virDomainDiskDiscard)discard) {
+case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
+case VIR_DOMAIN_DISK_DISCARD_LAST:
+break;
+case VIR_DOMAIN_DISK_DISCARD_UNMAP:
+libxl_defbool_set(x_disk-discard_enable, true);
+break;
+case VIR_DOMAIN_DISK_DISCARD_IGNORE:
+libxl_defbool_set(x_disk-discard_enable, false);
+break;
+}
+#else
+if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
+return;
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(This version of libxenlight does not support 
+ discard= option passing));
+#endif
+}
+
+
 int
 libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
 {
@@ -829,6 +856,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk 
*x_disk)
 x_disk-removable = 1;
 x_disk-readwrite = !l_disk-readonly;
 x_disk-is_cdrom = l_disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
+libxlDiskSetDiscard(x_disk, l_disk-discard);
 /* An empty CDROM must have the empty format, otherwise libxl fails. */
 if (x_disk-is_cdrom  !x_disk-pdev_path)
 x_disk-format = LIBXL_DISK_FORMAT_EMPTY;

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


Re: [libvirt] [PATCH] libxl: add discard support to libxl_device_disk

2014-07-07 Thread Olaf Hering
On Mon, Jul 07, Daniel P. Berrange wrote:

 IIUC, this is not about the underlying storage, but about whether the
 hypervisor API supports the discard setting. The libvirt policy is to
 always raise VIR_ERR_CONFIG_UNSUPPORTED and return failure to the app
 if they request a setting that the hypervisor does not support. Whether
 discard is critical or not really depends on your POV, so it is better
 not to make such assumptions on behalf of the mgmt app.

So how should the code path error out in this case?


Olaf

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


[libvirt] [libvirt-sandbox PATCH 2/2] virt-sandbox-service: fix some paths for SUSE

2014-07-07 Thread Cédric Bosdonnat
Don't fail is /etc/rc.d/init.d/functions doesn't exist: this is
deprecated in LSB and /lib/lsb/init-functions should be used instead.

Similarily, SUSE distros have /etc/skel/.profile instead of
/etc/skel/.bash_profile. Added one more file to check and be more
lennient with missing ones
---
 bin/virt-sandbox-service | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index 789c732..5a3f6ab 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -414,7 +414,7 @@ def is_template_unit(unit):
 class SystemdContainer(Container):
 IGNORE_DIRS= [ /var/run/, /etc/logrotate.d/, /etc/pam.d ]
 DEFAULT_DIRS   = [ /etc, /var ]
-PROFILE_FILES  = [ .bashrc, .bash_profile ]
+PROFILE_FILES  = [ .bashrc, .bash_profile, .profile ]
 MACHINE_ID = /etc/machine-id
 HOSTNAME   = /etc/hostname
 SYSVINIT_PATH  = /etc/rc.d
@@ -422,7 +422,7 @@ class SystemdContainer(Container):
 MULTI_USER_WANTS_PATH = /usr/lib/systemd/system/multi-user.target.wants
 SYSINIT_WANTS_PATH = /usr/lib/systemd/system/sysinit.target.wants
 SOCKET_WANTS_PATH  = /usr/lib/systemd/system/sockets.target.wants
-MAKE_SYSTEM_DIRS   = [ /var/lib/dhclient, /var/lib/dbus, /var/log, 
/var/spool, /var/cache, /var/tmp, /var/lib/nfs/rpc_pipefs, 
SYSVINIT_PATH ]
+MAKE_SYSTEM_DIRS   = [ /var/lib/dhclient, /var/lib/dbus, /var/log, 
/var/spool, /var/cache, /var/tmp, /var/lib/nfs/rpc_pipefs, 
SYSVINIT_PATH, /lib/lsb ]
 BIND_SYSTEM_DIRS   = [ /var, /home, /root, /etc/systemd/system, 
/etc/rc.d, /usr/lib/systemd/system/basic.target.wants, 
/usr/lib/systemd/system/local-fs.target.wants, ANACONDA_WANTS_PATH, 
MULTI_USER_WANTS_PATH, SYSINIT_WANTS_PATH, SOCKET_WANTS_PATH ]
 BIND_SYSTEM_FILES  = [ MACHINE_ID, /etc/fstab, HOSTNAME ]
 LOCAL_LINK_FILES   = { SYSINIT_WANTS_PATH : [ 
systemd-tmpfiles-setup.service ] , SOCKET_WANTS_PATH : [ dbus.socket, 
systemd-journald.socket, systemd-shutdownd.socket, systemd-initctl.socket 
] }
@@ -722,8 +722,15 @@ PrivateNetwork=false
 destpath = self.dest + self.SYSVINIT_PATH
 for i in range(7):
 os.mkdir(destpath+(/rc%s.d % i))
-os.mkdir(destpath+/init.d)
-shutil.copy(self.SYSVINIT_PATH + /init.d/functions , destpath + 
/init.d)
+
+# Copy both /etc/rc.d/init.d/functions and /lib/lsb/init-functions, 
even
+# though the latter is the one recommended
+if os.path.exists(self.SYSVINIT_PATH + /init.d/functions):
+os.mkdir(destpath+/init.d)
+shutil.copy(self.SYSVINIT_PATH + /init.d/functions , destpath + 
/init.d)
+
+if os.path.exists(/lib/lsb/init-functions):
+shutil.copy(/lib/lsb/init-functions , self.dest + /lib/lsb/)
 
 self.gen_machine_id()
 self.gen_hostname()
@@ -759,7 +766,8 @@ PrivateNetwork=false
 
 for p in self.PROFILE_FILES:
 profile = /etc/skel/ + p
-shutil.copy(profile, self.dest + /root/)
+if os.path.exists(profile):
+shutil.copy(profile, self.dest + /root/)
 
 self.fix_protection()
 
-- 
1.8.4.5

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


[libvirt] [libvirt-sandbox PATCH 0/2] virt-sandbox-service fixes

2014-07-07 Thread Cédric Bosdonnat
Here are a 2 fixes that make virt-sandbox-service work for me.
One allows it to work if selinux isn't handled by libvirtd, the other
safely handles some file copying that can be different across distros.

Cédric Bosdonnat (2):
  virt-sandbox-service: check for security label only if they can be
handled
  virt-sandbox-service: fix some paths for SUSE

 bin/virt-sandbox-service | 42 --
 1 file changed, 36 insertions(+), 6 deletions(-)

-- 
1.8.4.5

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

[libvirt] [libvirt-sandbox PATCH 1/2] virt-sandbox-service: check for security label only if they can be handled

2014-07-07 Thread Cédric Bosdonnat
virt-sandbox-service assumes libvirt has selinux security model...
which is not necessarily the case. If no security model is defined,
then don't check for dynamic labels.
---
 bin/virt-sandbox-service | 24 +++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/bin/virt-sandbox-service b/bin/virt-sandbox-service
index 9ed37e0..789c732 100755
--- a/bin/virt-sandbox-service
+++ b/bin/virt-sandbox-service
@@ -314,10 +314,32 @@ class Container:
 context = self.context()
 context.undefine()
 
+def get_security_model(self):
+# XXX selinux is the default for the while, needs to be configurable 
someday
+model = selinux
+supported = False
+
+# Make sure we have a connection
+self.connect()
+
+# Loop over the security models from the host capabilities
+configCaps = self.conn.get_capabilities()
+hostCaps = configCaps.get_host()
+secmodels = hostCaps.get_secmodels()
+for secmodel in secmodels:
+if secmodel.get_model() == model:
+supported = True
+break
+
+if not supported:
+model = None
+return model
+
 
 def create(self):
 self.connect()
-if self.config.get_security_dynamic() and not self.use_image:
+if self.get_security_model() is not None and \
+   self.config.get_security_dynamic() and not self.use_image:
 raise ValueError([_(Dynamic security label only supported for 
image based containers)])
 if self.uri != lxc:///:
 self.config.set_shell(True)
-- 
1.8.4.5

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


Re: [libvirt] [PATCH] libxl: add discard support to libxl_device_disk

2014-07-07 Thread Daniel P. Berrange
On Mon, Jul 07, 2014 at 04:00:44PM +0200, Olaf Hering wrote:
 On Fri, May 30, Jim Fehlig wrote:
 
  Olaf Hering wrote:
   +if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
   +return;
   +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
   +   _(This version of libxenlight does not support 
   + discard= option passing));
  An error would be reported here, but the overall libxlMakeDisk operation
  would succeed right?  Shouldn't it fail if the user requests discard but
  it is not supported?
 
 How would libvirt know if the underlying backing store supports discard?
 It would need to maintain a list of supported targets.
 If it remains just some sort of warning a given .xml file can be shared
 among different libvirt versions. After all, discard is not operation
 critical.

IIUC, this is not about the underlying storage, but about whether the
hypervisor API supports the discard setting. The libvirt policy is to
always raise VIR_ERR_CONFIG_UNSUPPORTED and return failure to the app
if they request a setting that the hypervisor does not support. Whether
discard is critical or not really depends on your POV, so it is better
not to make such assumptions on behalf of the mgmt app.

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

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


Re: [libvirt] [PATCH v2] libxl: add discard support to libxl_device_disk

2014-07-07 Thread Daniel P. Berrange
On Mon, Jul 07, 2014 at 04:05:34PM +0200, Olaf Hering wrote:
 Translate libvirt discard settings into libxl-4.5 discard settings.
 
 Signed-off-by: Olaf Hering o...@aepfle.de
 ---
 v2:
  add cast to switch variable to let compiler check if the code handles
  all enum values
 
  src/libxl/libxl_conf.c | 28 
  1 file changed, 28 insertions(+)
 
 diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
 index 8eeaf82..bb9b53d 100644
 --- a/src/libxl/libxl_conf.c
 +++ b/src/libxl/libxl_conf.c
 @@ -715,6 +715,33 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
  return -1;
  }
  
 +static void

s/void/int/

 +libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
 +{
 +if (!x_disk-readwrite)
 +return;
 +#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
 +switch ((enum virDomainDiskDiscard)discard) {
 +case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
 +case VIR_DOMAIN_DISK_DISCARD_LAST:
 +break;
 +case VIR_DOMAIN_DISK_DISCARD_UNMAP:
 +libxl_defbool_set(x_disk-discard_enable, true);
 +break;
 +case VIR_DOMAIN_DISK_DISCARD_IGNORE:
 +libxl_defbool_set(x_disk-discard_enable, false);
 +break;
 +}

Add 'return 0'

 +#else
 +if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
 +return;

Change to 'return 0'

 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   _(This version of libxenlight does not support 
 + discard= option passing));

I'd suggest  s/discard= option passing/disk 'discard' option/
and add 'return -1' here

 +#endif
 +}
 +
 +
  int
  libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
  {
 @@ -829,6 +856,7 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, 
 libxl_device_disk *x_disk)
  x_disk-removable = 1;
  x_disk-readwrite = !l_disk-readonly;
  x_disk-is_cdrom = l_disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 
 0;
 +libxlDiskSetDiscard(x_disk, l_disk-discard);

   if (libxlDiskSetDiscard(x_disk, l_disk-discard)  0)
return -1;

  /* An empty CDROM must have the empty format, otherwise libxl fails. */
  if (x_disk-is_cdrom  !x_disk-pdev_path)
  x_disk-format = LIBXL_DISK_FORMAT_EMPTY;

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

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


Re: [libvirt] new openvz driver (bossonvz)

2014-07-07 Thread Bosson VZ
-- 
David Fabian
Cluster Design, s.r.o.

Dne Čt 3. července 2014 23:17:12, Pavel Emelyanov napsal(a):
 On 07/03/2014 03:49 PM, Bosson VZ wrote:
  Fair enough. We have no problem to adapt to the new process. I don't know 
  how libcontainer is designed
  internally and how low-level it is but having a thin user-space wrapper 
  around the vzkernel would be wonderful.
 
 Here's the preliminary version of it will look like: 
 https://github.com/xemul/libct/
 The API would get slightly shuffled to fit more the 
 https://github.com/docker/libcontainer/pull/28
 
 
  I wanted to use libvzctl in bossonvz to abstract the driver away from the 
  low-level stuff but the library
  is just too much interconnected with the veconf parser.
 
 Well, the libcontainer API is not going to mess with configs at all. 
 Everything
 will be run-time.
 
  The current vz kernel API is not the nicest thing to work with to be honest 
  and a shared user-space library
  would help both vzctl and bossonvz. If you are interested in my POV on the 
  kernel API, I would say you
  should leave more work for the user-space. At the moment, when the 
  user-space asks for a new container,
  the vzkernel magically creates a new environment and sets everything (esp. 
  cgroups) by itself without any 
  chance for the user-space to set anything. Because libvirt has its own 
  cgroup hierarchy model and any
  libvirt driver should honor it, bossonvz should, idealy, create cgroups for 
  the container under the libvirt
  hierarchy but it cannot since the kernel won't let it.
 
 Yes, this is our 15-years-old API that was kept compatible with tools. Soon 
 after
 we started merging containers upstream we started the process of its 
 deprecation,
 and in the upcoming Rhel7-based kernel we're very close to the goal.
 
  As I see it, the driver has to do two separate things to successfully use 
  the kernel API. There are the
  vz specific syscalls/ioctls (e.g. VZCTL_ENV_CREATE_DATA) and there is a 
  preparatory work done in the
  user-space (preparing forked sub-processes, pipes, etc.). Is the new SDK 
  going to cover only the low-level
  code (ioctls) or will I be able to use some sort of a high-level function 
  like spawn_environment() and get
  PID of the newly created container's init?
 
 The SDK is going to be quite high-level, and more sophisticated than existing 
 libvzctl.
 The libcontainer is going to be low-level but still more abstract than the 
 kernel API.
 
  The amount of vz specific code in the bossonvz driver is not that big. The 
  ioctls is just a single
  bossonvz_environment.c file. The harder part is the preparatory part which 
  is located in bossonvz_container.c
  and is quite complex since it closely mimics the code path of vzctl 
  (otherwise the driver would not work).
 
 It's interesting. Can you point out where you code is?
 And, btw, I think you would be interested in taking part in libcontainer
 design, discussions and development. The link above is the place where we
 try to settle down the new API and you're welcome to join :)
 
 Thanks,
 Pavel
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] new openvz driver (bossonvz)

2014-07-07 Thread Bosson VZ
Thanks for the links. I'll definitely check them out.

The source code can be found at bossonvz.bosson.eu. But have in mind that the 
bossonvz driver uses only a subset of the vzkernel API. Some vzctl 
functionality is not implemented as it was not needed. Backwards compatibility 
with older vz kernels has also been dropped. And a lot of the auxiliary code is 
hidden in libvirt functions (especially virCommand).

Thanks for the invitation. I believe the bossonvz driver could also leverage 
from that kind of co-operation.

-- 
David Fabian
Cluster Design, s.r.o.

Dne Čt 3. července 2014 23:17:12, Pavel Emelyanov napsal(a):
 On 07/03/2014 03:49 PM, Bosson VZ wrote:
  Fair enough. We have no problem to adapt to the new process. I don't know 
  how libcontainer is designed
  internally and how low-level it is but having a thin user-space wrapper 
  around the vzkernel would be wonderful.
 
 Here's the preliminary version of it will look like: 
 https://github.com/xemul/libct/
 The API would get slightly shuffled to fit more the 
 https://github.com/docker/libcontainer/pull/28
 
 
  I wanted to use libvzctl in bossonvz to abstract the driver away from the 
  low-level stuff but the library
  is just too much interconnected with the veconf parser.
 
 Well, the libcontainer API is not going to mess with configs at all. 
 Everything
 will be run-time.
 
  The current vz kernel API is not the nicest thing to work with to be honest 
  and a shared user-space library
  would help both vzctl and bossonvz. If you are interested in my POV on the 
  kernel API, I would say you
  should leave more work for the user-space. At the moment, when the 
  user-space asks for a new container,
  the vzkernel magically creates a new environment and sets everything (esp. 
  cgroups) by itself without any 
  chance for the user-space to set anything. Because libvirt has its own 
  cgroup hierarchy model and any
  libvirt driver should honor it, bossonvz should, idealy, create cgroups for 
  the container under the libvirt
  hierarchy but it cannot since the kernel won't let it.
 
 Yes, this is our 15-years-old API that was kept compatible with tools. Soon 
 after
 we started merging containers upstream we started the process of its 
 deprecation,
 and in the upcoming Rhel7-based kernel we're very close to the goal.
 
  As I see it, the driver has to do two separate things to successfully use 
  the kernel API. There are the
  vz specific syscalls/ioctls (e.g. VZCTL_ENV_CREATE_DATA) and there is a 
  preparatory work done in the
  user-space (preparing forked sub-processes, pipes, etc.). Is the new SDK 
  going to cover only the low-level
  code (ioctls) or will I be able to use some sort of a high-level function 
  like spawn_environment() and get
  PID of the newly created container's init?
 
 The SDK is going to be quite high-level, and more sophisticated than existing 
 libvzctl.
 The libcontainer is going to be low-level but still more abstract than the 
 kernel API.
 
  The amount of vz specific code in the bossonvz driver is not that big. The 
  ioctls is just a single
  bossonvz_environment.c file. The harder part is the preparatory part which 
  is located in bossonvz_container.c
  and is quite complex since it closely mimics the code path of vzctl 
  (otherwise the driver would not work).
 
 It's interesting. Can you point out where you code is?
 And, btw, I think you would be interested in taking part in libcontainer
 design, discussions and development. The link above is the place where we
 try to settle down the new API and you're welcome to join :)
 
 Thanks,
 Pavel
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH v3] libxl: add discard support to libxl_device_disk

2014-07-07 Thread Olaf Hering
Translate libvirt discard settings into libxl-4.5 discard settings.

Signed-off-by: Olaf Hering o...@aepfle.de
---
v3:
 passing discard= with old libxl is now a fatal error
v2:
 add cast to switch variable to let compiler check if the code handles
 all enum values

 src/libxl/libxl_conf.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 8eeaf82..538cfa4 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -715,6 +715,35 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
 return -1;
 }
 
+static int
+libxlDiskSetDiscard(libxl_device_disk *x_disk, int discard)
+{
+if (!x_disk-readwrite)
+return 0;
+#if defined(LIBXL_HAVE_LIBXL_DEVICE_DISK_DISCARD_ENABLE)
+switch ((enum virDomainDiskDiscard)discard) {
+case VIR_DOMAIN_DISK_DISCARD_DEFAULT:
+case VIR_DOMAIN_DISK_DISCARD_LAST:
+break;
+case VIR_DOMAIN_DISK_DISCARD_UNMAP:
+libxl_defbool_set(x_disk-discard_enable, true);
+break;
+case VIR_DOMAIN_DISK_DISCARD_IGNORE:
+libxl_defbool_set(x_disk-discard_enable, false);
+break;
+}
+return 0;
+#else
+if (discard == VIR_DOMAIN_DISK_DISCARD_DEFAULT)
+return 0;
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(This version of libxenlight does not support 
+ disk 'discard' option passing));
+return -1;
+#endif
+}
+
+
 int
 libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk *x_disk)
 {
@@ -829,6 +858,8 @@ libxlMakeDisk(virDomainDiskDefPtr l_disk, libxl_device_disk 
*x_disk)
 x_disk-removable = 1;
 x_disk-readwrite = !l_disk-readonly;
 x_disk-is_cdrom = l_disk-device == VIR_DOMAIN_DISK_DEVICE_CDROM ? 1 : 0;
+if (libxlDiskSetDiscard(x_disk, l_disk-discard)  0)
+return -1;
 /* An empty CDROM must have the empty format, otherwise libxl fails. */
 if (x_disk-is_cdrom  !x_disk-pdev_path)
 x_disk-format = LIBXL_DISK_FORMAT_EMPTY;

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


[libvirt] Follow-up on .so version number question

2014-07-07 Thread Tony Asleson
Eric posted this a while back (ref:
http://www.redhat.com/archives/libvir-list/2010-April/msg00226.html)
without any apparent response/discussion.

Can someone please elaborate on this?

Thanks,
Tony

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


Re: [libvirt] Follow-up on .so version number question

2014-07-07 Thread Eric Blake
On 07/07/2014 12:35 PM, Tony Asleson wrote:
 Eric posted this a while back (ref:
 http://www.redhat.com/archives/libvir-list/2010-April/msg00226.html)
 without any apparent response/discussion.
 
 Can someone please elaborate on this?

At this point, we really aren't too worried about libtool versioning
scheme.  We've kept our guarantee of library back-compat ever since that
email, with no complaints, so I'm not sure that changing anything now
makes any sense (I'm more worried about breaking status quo than I am
about violating libtool documentation suggestions)

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



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

Re: [libvirt] [PATCH] doc: Be more specific about semantics of _REUSE_EXT flag

2014-07-07 Thread Eric Blake
On 07/07/2014 06:40 AM, Peter Krempa wrote:
 Snapshots and block-copy have a flag that forces qemu to re-use existing
 file. Our docs weren't exactly clear on what the existing file should
 contain for this to actually work.
 
 Re-word the docs a bit to state that the file needs to be pre-created in
 the desired format and the backing chain metadata needs to be set prior
 to handing it over to qemu.

Furthermore, in at least the case of copying to raw (but probably
elsewhere), the destination file must be sized at least as large as what
the guest sees, or else qemu 2.0 and earlier can abort the job on an I/O
error with no indication to libvirt what the error was.

https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg07377.html

Libvirt should probably be taught to use newer qemu's rerror= and
werror= job options so that the job sticks around rather than
disappearing on error, so that it is not quite such an invisible shock
of a job just disappearing because of I/O error due to insufficient
sizing, but that's a much bigger patch.  For now, documenting the issue
is probably sufficient.

 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1084360
 ---
  src/libvirt.c   | 12 +++-
  tools/virsh.pod | 12 +++-
  2 files changed, 14 insertions(+), 10 deletions(-)
 
 diff --git a/src/libvirt.c b/src/libvirt.c
 index b80b484..e7a6aca 100644
 --- a/src/libvirt.c
 +++ b/src/libvirt.c
 @@ -18274,10 +18274,12 @@ virDomainSnapshotGetConnect(virDomainSnapshotPtr 
 snapshot)
   * destination files already exist as a non-empty regular file, the
   * snapshot is rejected to avoid losing contents of those files.
   * However, if @flags includes VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT,
 - * then the destination files must already exist and contain content
 - * identical to the source files (this allows a management app to
 - * pre-create files with relative backing file names, rather than the
 - * default of creating with absolute backing file names).
 + * then the destination files must be pre-created manually with
 + * the correct image format and metadata including backing store path.

No trailing dot, since your parenthetical comment is a continuation of
the same sentence.

 + * (this allows a management app to pre-create files with relative backing
 + * file names, rather than the default of creating with absolute backing
 + * file names). Note that setting incorrect metadata in the pre-created
 + * image may lead to the VM being unable to start.
   *
   * Be aware that although libvirt prefers to report errors up front with
   * no other effect, some hypervisors have certain types of failures where
 @@ -19731,7 +19733,7 @@ virDomainBlockPull(virDomainPtr dom, const char *disk,
   * by adding VIR_DOMAIN_BLOCK_REBASE_COPY_RAW to force the copy to be raw
   * (does not make sense with the shallow flag unless the source is also raw),
   * or by using VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT to reuse an existing file
 - * with initial contents identical to the backing file of the source (this
 + * which was pre-created with the correct format and metadata (this

Given my observation above, I'd use:

pre-created with the correct format, metadata, and sufficient size to
hold the copy

Oh, and it SHOULD be valid to do the following:

starting from: base - snap1 - active

use: qemu-img convert -f qcow2 -O raw snap1 flat

then start a shallow copy: virsh blockcopy $dom vda flat --shallow --raw
--reuse-external --finish

and end up with 'flat' containing the complete guest contents visible
from 'active' at the time it completes. That is, the combination of the
two separate actions into 'flat' will cover all the sectors, even though
the shallow copy does NOT copy all sectors.  And _that_ is what my
original wording was trying to convey when it said 'with initial
contents identical to the backing file of the source'.  Maybe a better
wording would have been:

reuse an existing file that contains the same guest-visible content as
the backing file of the active image being copied

   * allows a management app to pre-create files with relative backing file
   * names, rather than the default of absolute backing file names; as a
   * security precaution, you should generally only use reuse_ext with the
 diff --git a/tools/virsh.pod b/tools/virsh.pod
 index 1b6f3c4..39fe423 100644
 --- a/tools/virsh.pod
 +++ b/tools/virsh.pod
 @@ -875,8 +875,8 @@ flattens the entire chain; but if I--shallow is 
 specified, the copy
  shares the backing chain.
 
  If I--reuse-external is specified, then Idest must exist and have
 -contents identical to the resulting backing file (that is, it must
 -start with contents matching the backing file Idisk if I--shallow
 +metadata identical to the resulting backing file (that is, it must

No, it's not the metadata that must be identical, but the guest-visible
contents (the metadata can be completely different, even qed instead of
qcow2, as long as loading that file would give the guest the same 

Re: [libvirt] [PATCH 1/4] util: storage: Inline use of virStorageFileGetMetadataFromFDInternal

2014-07-07 Thread Eric Blake
On 07/07/2014 06:16 AM, Peter Krempa wrote:
 There was just one callsite left. Integrate the body to the only calling
 function.
 ---
  src/util/virstoragefile.c | 91 
 ---
  1 file changed, 39 insertions(+), 52 deletions(-)

ACK.

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



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

Re: [libvirt] [PATCH 2/4] util: storage: Allow specifying format for virStorageFileGetMetadataFromBuf

2014-07-07 Thread Eric Blake
On 07/07/2014 06:16 AM, Peter Krempa wrote:
 To allow reusing this function in the qemu driver we need to allow to
 specify the storage format. Also separate return of the backing store

s/to specify/specifying/

 path now isn't necessary.
 ---
  src/storage/storage_backend_gluster.c |  5 -
  src/util/virstoragefile.c | 31 ++-
  src/util/virstoragefile.h |  2 +-
  3 files changed, 19 insertions(+), 19 deletions(-)
 

 +++ b/src/storage/storage_backend_gluster.c
 @@ -294,10 +294,13 @@ 
 virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state,
  goto cleanup;
 
  if (!(meta = virStorageFileGetMetadataFromBuf(name, header, len,
 -  vol-backingStore.path,
 +  VIR_STORAGE_FILE_AUTO,

 vol-backingStore.format)))

 +++ b/src/util/virstoragefile.c

 + *
 + * Callers are advised never to use VIR_STORAGE_FILE_AUTO as a
 + * format, since a malicious guest can turn a raw file into any
   * other non-raw format at will.

At this point, we may want to re-phrase this, as this very patch
introduced a caller that passes AUTO.  Maybe:

Callers are advised never to use VIR_STORAGE_FILE_AUTO as a format on a
file that might be raw if that file will then be passed to a guest,
since a malicious guest ...

ACK. I'll leave it up to you whether to reword the comment, or if you
can come up with anything better.

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



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

Re: [libvirt] [PATCH 3/4] storage: gluster: Optimize header reader functions

2014-07-07 Thread Eric Blake
On 07/07/2014 06:16 AM, Peter Krempa wrote:
 The gluster code had two functions for reading volume headers, remove
 one and reuse the second one.
 ---
  src/storage/storage_backend_gluster.c | 43 
 ++-
  1 file changed, 2 insertions(+), 41 deletions(-)
 

ACK.

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



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

Re: [libvirt] [PATCH 4/4] qemu: refactor qemuDomainGetBlockInfo to work with remote storage

2014-07-07 Thread Eric Blake
On 07/07/2014 06:16 AM, Peter Krempa wrote:
 The qemu block info function relied on working with local storage. Break
 this assumption by adding support for remote volumes. Unfortunately we
 still need to take a hybrid approach as some of the operations require a
 filedescriptor.
 
 Previously you'd get:
  $ virsh domblkinfo gl vda
  error: cannot stat file '/img10': Bad file descriptor
 
 Now you get some stats:
  $ virsh domblkinfo gl vda
  Capacity:   10485760
  Allocation: 197120
  Physical:   197120
 
 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1110198
 ---
  src/libvirt_private.syms  |  1 +
  src/qemu/qemu_driver.c| 84 
 ++-
  src/util/virstoragefile.c |  2 +-
  src/util/virstoragefile.h |  3 ++
  4 files changed, 58 insertions(+), 32 deletions(-)
 

ACK.

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



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

Re: [libvirt] [PATCHv2 1/2] audit: Add auditing for serial/parallel/channel/console character devs

2014-07-07 Thread Eric Blake
On 07/04/2014 06:25 AM, Peter Krempa wrote:
 Add startup auditing and also hotplug auditing for said devices.
 ---
  docs/auditlog.html.in| 15 +++
  src/conf/domain_audit.c  | 42 ++
  src/conf/domain_audit.h  |  7 +++
  src/libvirt_private.syms |  1 +
  src/qemu/qemu_hotplug.c  | 17 +++--
  5 files changed, 76 insertions(+), 6 deletions(-)
 
 diff --git a/docs/auditlog.html.in b/docs/auditlog.html.in
 index 24cd8e9..8528b52 100644
 --- a/docs/auditlog.html.in
 +++ b/docs/auditlog.html.in
 @@ -285,6 +285,21 @@
ddUpdated path of the host entropy source for the RNG/dd
  /dl
 
 +h4a 
 name=typeresourcechardevconsole/serial/parallel/channel/a/h4
 +p
 +  The codemsg/code field will include the following sub-fields
 +/p
 +
 +dl
 +  dtreason/dt
 +  ddThe reason which caused the resource to be assigned to happen/dd

Already pushed, but this might read better as:

The reason which caused the change in resource assignment

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



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

Re: [libvirt] [PATCHv2 2/2] audit: Audit smartcard devices

2014-07-07 Thread Eric Blake
On 07/04/2014 06:25 AM, Peter Krempa wrote:
 ---
  docs/auditlog.html.in   | 20 
  src/conf/domain_audit.c | 48 
  2 files changed, 68 insertions(+)
 
 diff --git a/docs/auditlog.html.in b/docs/auditlog.html.in
 index 8528b52..8a007ca 100644
 --- a/docs/auditlog.html.in
 +++ b/docs/auditlog.html.in
 @@ -301,6 +301,26 @@
ddUpdated path of the backing character device for given emulated 
 device/dd
  /dl
 
 +h4a name=typeresourcesmartcardsmartcard/a/h4
 +p
 +  The codemsg/code field will include the following sub-fields
 +/p
 +
 +dl
 +  dtreason/dt
 +  ddThe reason which caused the resource to be assigned to happen/dd

Same wording suggestion as in 1/2

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



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

Re: [libvirt] Where to get precompiled qga-vss.dll from ?

2014-07-07 Thread Eric Blake
On 07/07/2014 02:32 AM, Puneet Bakshi wrote:
 Hi,
 
 I want to work with guest-fsfreeze-* commands in Windows 2008 guest VM.
 Host is CentOS 6.4.
 
 Windows 2008 is running QEMU VSS provider. When guest-fsfreeze-* commands
 are invoked from host, response received is This is not supported.
 
 I am following
 http://lists.gnu.org/archive/html/qemu-devel/2013-02/msg01963.html.

The libvirt list is the wrong place to be asking this question; qemu is
better.

The spice-devel list has done some pre-packaged virt stack builds for
Windows; maybe they might be a better resource to ask (for example, see
http://lists.freedesktop.org/archives/spice-devel/2014-February/016100.html)
- but I don't follow that list closely enough to know if they have
pre-built qga.

You could always download the mingw cross-compiler and try to build qga
yourself, instead of relying on someone else to provide a pre-built binary.

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



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

Re: [libvirt] [PATCH] Free the return value of virFileFindResource

2014-07-07 Thread Eric Blake
On 07/07/2014 12:33 AM, Ján Tomko wrote:
 Commits e18a80a and 57e5c3c switched from a getenv wrapper which
 does not allocate a string to virFileFindResource which does not,
 without freeing it.

I think you meant s/which does not/which does/ in the second use of the
phrase.

 
 https://bugzilla.redhat.com/show_bug.cgi?id=1116427
 ---
  src/locking/lock_driver_lockd.c | 2 ++
  src/remote/remote_driver.c  | 3 +++
  2 files changed, 5 insertions(+)
 

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



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

Re: [libvirt] QEMU snapshots on ZFS

2014-07-07 Thread Eric Blake
On 07/04/2014 10:52 AM, Arunas Ruksnaitis wrote:

 Now I am starting to move forward, and have discovered that snapshot is
 only supported as QEMU native savevm command, which only works on QCOW2
 backing image.

That's not the only supported snapshot; we also support creating
external snapshots (qemu 'blockdev-snapshot-sync').  And as of qemu 2.1
and libvirt 1.2.7 (both due out at the end of this month), it should be
possible to take an external snapshot to go from 'file (r/w)' to 'file
(r/o) - temporary (r/w)' , then use your ZFS native commands to do
whatever you want with the read-only 'file', then do an active commit to
go back to 'file (r/w)'.

 
 Is there any chance to include support for ZFS native snapshots? I.e. do a
 coordinated RAM snapshot in a separate file, snapshot ZFS volume and tie
 these two together in a snapshot XML file.

Sure, patches are welcome.  People have also asked for native LFS volume
snapshot integration; the concept is the same - someone would need to
submit the patch that coordinates the third-party snapshots to happen at
a point while qemu is temporarily using a qcow2 wrapper around the file,
then active commit the temporary wrapper back into the main file once
the third-party snapshot is done.

 
 A related, but different question: any chance to support ZFS-backed storage
 pools, so that ZFS volumes could be created, and not QCOW images in ZFS
 file system (this is a waste of ZFS, as ZFS already has native COW,
 snapshots, cloning, migration and much more). Should I start a separate
 thread for this topic?

Patches are welcome; you can use existing storage pool code as a
starting point on what needs to happen.

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



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

Re: [libvirt] Regression with 79f11b35

2014-07-07 Thread Cole Robinson
FWIW this is still an issue with current libvirt git, but I haven't dug into
it any further.

- Cole

On 05/03/2014 04:54 PM, Cole Robinson wrote:
 I'm seeing a regression with:
 
 commit 79f11b35c77b3c286c84312dc9737c2ccbf67ed5
 Author: Eric Blake ebl...@redhat.com
 Date:   Tue Apr 8 14:26:02 2014 -0600
 
 conf: track user vs. canonical name through full chain lookup
 
 
 Setup info:
 
 $ ls -ld /mnt/data
 lrwxrwxrwx. 1 root root 17 Oct 24  2011 /mnt/data - terabytedrv/data/
 $ ls -l /mnt/data/devel/images/f18*
 -rw-r--r--. 1 qemu qemu 9316335616 Mar 30 18:36
 /mnt/data/devel/images/f18-backing-img.qcow2
 -rw-r--r--. 1 root root 6848249856 Apr 25 19:11 
 /mnt/data/devel/images/f18.qcow2
 
 $ qemu-img info /mnt/data/devel/images/f18-backing-img.qcow2
 image: /mnt/data/devel/images/f18-backing-img.qcow2
 file format: qcow2
 virtual size: 9.8G (1048576 bytes)
 disk size: 8.7G
 cluster_size: 65536
 Snapshot list:
 IDTAG VM SIZEDATE   VM CLOCK
 1 snapshot1 0 2014-01-13 18:48:43   00:00:00.000
 2 snapshot2 0 2014-01-13 18:49:39   00:00:00.000
 Format specific information:
 compat: 0.10
 
 $ qemu-img info /mnt/data/devel/images/f18.qcow2 image:
 /mnt/data/devel/images/f18.qcow2
 file format: qcow2
 virtual size: 9.8G (1048576 bytes)
 disk size: 6.4G
 cluster_size: 65536
 backing file: f18-backing-img.qcow2 (actual path:
 /mnt/data/devel/images/f18-backing-img.qcow2)
 Format specific information:
 compat: 0.10
 
 
 Before the patch:
 
 $ sudo virsh vol-dumpxml /mnt/data/devel/images/f18.qcow2
 [full xml with backing image info]
 
 After the patch:
 
 $ sudo virsh vol-dumpxml /mnt/data/devel/images/f18.qcow2
 [xml minus xml for the backing image]
 
 And these errors are on the console when the daemon starts:
 
 2014-05-03 20:52:34.970+: 20600: error : virFindBackingFile:590 : Cannot
 access backing file './f18-backing-img.qcow2': No such file or directory
 2014-05-03 20:52:34.970+: 20600: warning :
 virStorageFileGetMetadataInternal:868 : Backing file 'f18-backing-img.qcow2'
 of image '/mnt/data/devel/images/ztester-serial-f18.qcow2' is missing.
 
 On git head actually the vol-dumpxml explicitly fails, but I don't have the
 error handy.
 

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


Re: [libvirt] [PATCH] Do not allow changing the UUID of a nwfilter

2014-07-07 Thread Eric Blake
On 07/07/2014 07:57 AM, Ján Tomko wrote:
 From: Hu Jianwei ji...@redhat.com
 
 https://bugzilla.redhat.com/show_bug.cgi?id=1077009
 ---
  src/conf/nwfilter_conf.c | 11 +++
  1 file changed, 11 insertions(+)

ACK.

 
 diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c
 index 0f633da..52f24e4 100644
 --- a/src/conf/nwfilter_conf.c
 +++ b/src/conf/nwfilter_conf.c
 @@ -3058,6 +3058,17 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr 
 nwfilters,
  return NULL;
  }
  virNWFilterObjUnlock(nwfilter);
 +} else {
 +nwfilter = virNWFilterObjFindByName(nwfilters, def-name);
 +if (nwfilter) {
 +char uuidstr[VIR_UUID_STRING_BUFLEN];
 +virUUIDFormat(nwfilter-def-uuid, uuidstr);
 +virReportError(VIR_ERR_OPERATION_FAILED,
 +   _(filter '%s' already exists with uuid %s),
 +   def-name, uuidstr);
 +virNWFilterObjUnlock(nwfilter);
 +return NULL;
 +}
  }
  
  if (virNWFilterDefLoopDetect(nwfilters, def)  0) {
 

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



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

Re: [libvirt] [PATCHv7 1/4] lib: Introduce flag VIR_DOMAIN_BLOCK_COMMIT_RELATIVE

2014-07-07 Thread Eric Blake
On 07/04/2014 05:22 AM, Peter Krempa wrote:
 Introduce flag for the block commit API to allow the commit operation to
 leave the chain relatively addressed. Also adds a virsh switch to enable
 this behavior.
 ---
  include/libvirt/libvirt.h.in | 3 +++
  src/libvirt.c| 5 +
  tools/virsh-domain.c | 6 ++
  tools/virsh.pod  | 5 +++--
  4 files changed, 17 insertions(+), 2 deletions(-)
 

ACK.

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



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

Re: [libvirt] [PATCHv7 2/4] lib: Introduce flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE

2014-07-07 Thread Eric Blake
On 07/04/2014 05:22 AM, Peter Krempa wrote:
 Introduce flag for the block rebase API to allow the rebase operation to
 leave the chain relatively addressed. Also adds a virsh switch to enable
 this behavior.
 ---
  include/libvirt/libvirt.h.in |  3 +++
  src/libvirt.c|  3 +++
  tools/virsh-domain.c | 12 ++--
  tools/virsh.pod  |  4 
  4 files changed, 20 insertions(+), 2 deletions(-)
 

 +++ b/src/libvirt.c
 @@ -19721,6 +19721,9 @@ virDomainBlockPull(virDomainPtr dom, const char *disk,
   * exists.  If the job is aborted, a new one can be started later to
   * resume from the same point.
   *
 + * If @flags contains VIR_DOMAIN_BLOCK_REBASE_RELATIVE, the name recorded
 + * into the active disk as the location for @base will be kept relative.

in 1/4, you had wording mentioning that the operation will fail if
libvirt cannot infer a relative name.  I think you should copy that
wording here, too.

 +++ b/tools/virsh-domain.c
 @@ -1488,10 +1488,14 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd,
  case VSH_CMD_BLOCK_JOB_PULL:
  if (vshCommandOptStringReq(ctl, cmd, base, base)  0)
  goto cleanup;
 -if (base)
 -ret = virDomainBlockRebase(dom, path, base, bandwidth, 0);
 +  if (vshCommandOptBool(cmd, keep-relative))
 +  flags |= VIR_DOMAIN_BLOCK_REBASE_RELATIVE;

Indentation looks off.

 +
 +if (base || flags)
 +ret = virDomainBlockRebase(dom, path, base, bandwidth, flags);
  else
  ret = virDomainBlockPull(dom, path, bandwidth, 0);

ACK with those 2 changes.

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



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

Re: [libvirt] [PATCHv7 3/4] qemu: Add support for networked disks for block commit

2014-07-07 Thread Eric Blake
On 07/04/2014 05:22 AM, Peter Krempa wrote:
 Now that we are able to select images from the backing chain via indexed
 access we should also convert possible network sources to
 qemu-compatible strings before passing them to qemu.
 ---
  src/qemu/qemu_driver.c | 38 ++
  1 file changed, 34 insertions(+), 4 deletions(-)
 

ACK.

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



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

Re: [libvirt] [PATCHv7 4/4] qemu: Add support for networked disks for block pull/block rebase

2014-07-07 Thread Eric Blake
On 07/04/2014 05:22 AM, Peter Krempa wrote:
 Now that we are able to select images from the backing chain via indexed
 access we should also convert possible network sources to
 qemu-compatible strings before passing them to qemu.
 ---
  src/qemu/qemu_driver.c | 45 +
  1 file changed, 41 insertions(+), 4 deletions(-)
 

 @@ -15027,6 +15029,13 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
  goto cleanup;
  }
 
 +if (flags  VIR_DOMAIN_BLOCK_REBASE_RELATIVE  !base) {
 +virReportError(VIR_ERR_INVALID_ARG, %s,
 +   _(flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE is valid 
 only 
 +  with non-null base ));

double space and trailing space in the resulting error string.

Should we hoist this check into libvirt.c, or is there a chance that
some other driver may support the combination?  But we can make that
decision in a followup patch if we decide to do it.

ACK with the spacing fixed.

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



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

Re: [libvirt] [PATCHv5 01/28] storage: Implement virStorageFileCreate for local and gluster files

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 Add backends for this frontend function so that we can use it in the
 snapshot creation code.
 ---
  src/storage/storage_backend_fs.c  | 17 +
  src/storage/storage_backend_gluster.c | 28 
  2 files changed, 45 insertions(+)
 

  static int
 +virStorageFileBackendGlusterCreate(virStorageSourcePtr src)
 +{
 +virStorageFileBackendGlusterPrivPtr priv = src-drv-priv;
 +glfs_fd_t *fd = NULL;
 +int save_errno;
 +int ret = -1;
 +
 +if (!(fd = glfs_open(priv-vol, src-path, O_CREAT | O_TRUNC | 
 O_WRONLY)))
 +return -1;
 +
 +if (src-drv-uid != 0 || src-drv-gid != 0) {

Isn't our sentinel value -1 for default? I think that comparison against
0 is likely to be wrong for running qemu:///session.

ACK with this change:

if (src-drv-uid != (uid_t)-1 || src-drv-gid != (gid_t)-1) {

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



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

Re: [libvirt] [PATCHv5 02/28] qemu: Don't propagate whole disk definition into qemuDomainGetImageIds

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 It will help re-using the function.
 ---
  src/qemu/qemu_domain.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
 

ACK

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



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

Re: [libvirt] [PATCHv5 03/28] qemu: Add helper to initialize storage file backend with correct uid/gid

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 Add a wrapper that determines the correct uid and gid for a certain
 storage file and domain.
 ---
  src/qemu/qemu_domain.c | 23 +++
  src/qemu/qemu_domain.h |  4 
  2 files changed, 27 insertions(+)
 

ACK

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



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

Re: [libvirt] [PATCHv5 04/28] storage: file: Tolerate NULL src when uninitializing the backend

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 Allow de-init of null storage sources.
 ---
  src/storage/storage_driver.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 

ACK

 diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
 index 8c0c5d6..ae86c69 100644
 --- a/src/storage/storage_driver.c
 +++ b/src/storage/storage_driver.c
 @@ -2540,7 +2540,7 @@ int storageRegister(void)
  static bool
  virStorageFileIsInitialized(virStorageSourcePtr src)
  {
 -return !!src-drv;
 +return src  src-drv;
  }
 
 

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



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

Re: [libvirt] [PATCHv5 05/28] conf: Don't output seclabels for backingStore elements

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 Some of the further changes will propagate seclabels from a disk source
 element into the backing store elements. This would change the XML
 output of the backing store as the seclabels would be formatted for each
 backing store element. Skip the seclabels formatting until we decide
 that it's necessary.

I agree - it's easier to be conservative now and turn it on later than
it is to turn it on now and be stuck with it for back-compat.

 ---
  src/conf/domain_conf.c | 59 
 +++---
  1 file changed, 42 insertions(+), 17 deletions(-)
 

ACK

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



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

Re: [libvirt] [PATCHv5 06/28] storage: Move readonly and shared flags to disk source from disk def

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 In the future we might need to track state of individual images. Move
 the readonly and shared flags to the virStorageSource struct so that we
 can keep them in a per-image basis.
 ---

Mostly mechanical. ACK

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



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

Re: [libvirt] [PATCHv5 07/28] util: storagefile: Add deep copy for struct virStorageSource

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 Now that we have pointers to store disk source information and thus can
 easily exchange the structs behind we need a function to copy all the
 data.
 ---
  src/libvirt_private.syms  |   1 +
  src/util/virstoragefile.c | 194 
 --
  src/util/virstoragefile.h |   3 +
  3 files changed, 190 insertions(+), 8 deletions(-)
 


 @@ -1771,11 +1954,11 @@ virStorageSourceBackingStoreClear(virStorageSourcePtr 
 def)
  }
 
 
 +
 +
  void
  virStorageSourceClear(virStorageSourcePtr def)
  {

Extra newline here.

ACK with that fixed.

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



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

Re: [libvirt] [PATCHv5 08/28] util: storage: Add function to transfer config parts to new chain element

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 We are going to modify storage source chains in place. Add a helper that
 will copy relevant information such as security labels to the new
 element if that doesn't contain it.
 ---
  src/libvirt_private.syms  |  1 +
  src/util/virstoragefile.c | 40 
  src/util/virstoragefile.h |  3 +++
  3 files changed, 44 insertions(+)
 

ACK

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



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

Re: [libvirt] [PATCHv5 09/28] util: storage: Copy parent's disk metadata to backing chain elements

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 When discovering a disk backing chain the parent disk's metadata need to
 be populated into the guest images so that each piece of the backing
 chain contains a copy of those. This will allow us to refactor the
 security driver so that it will not need to carry around the original
 disk definition.
 ---
  src/util/virstoragefile.c | 8 
  1 file changed, 8 insertions(+)
 

ACK.

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



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

Re: [libvirt] [PATCHv5 10/28] util: cgroup: Add helper to convert device mode to string

2014-07-07 Thread Eric Blake
On 07/04/2014 05:29 AM, Peter Krempa wrote:
 Cgroups code uses VIR_CGROUP_DEVICE_* flags to specify the mode but in
 the end it needs to be converted to a string. Add a helper to do it and
 use it in the cgroup code before introducing it into the rest of the
 code.
 ---
  src/libvirt_private.syms |  1 +
  src/util/vircgroup.c | 62 
 +++-
  src/util/vircgroup.h |  2 ++
  3 files changed, 49 insertions(+), 16 deletions(-)
 

ACK

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



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

Re: [libvirt] [PATCH] LXC: introduce lxcDomainSetMemoryFlags

2014-07-07 Thread chenhanx...@cn.fujitsu.com


 -Original Message-
 From: Ján Tomko [mailto:jto...@redhat.com]
 Sent: Monday, July 07, 2014 6:54 PM
 To: Chen, Hanxiao/陈 晗霄; libvir-list@redhat.com
 Subject: Re: [libvirt] [PATCH] LXC: introduce lxcDomainSetMemoryFlags
 
 On 07/04/2014 10:21 AM, Chen Hanxiao wrote:
  In lxc, we could not use setmem command
  with --config options.
  This patch will add support for this.
 
  Signed-off-by: Chen Hanxiao chenhanx...@cn.fujitsu.com
  ---
   src/lxc/lxc_driver.c | 52
 ++--
   1 file changed, 42 insertions(+), 10 deletions(-)
 
  diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
  index 79c3b4a..68795cb 100644
  --- a/src/lxc/lxc_driver.c
  +++ b/src/lxc/lxc_driver.c
  @@ -706,11 +706,19 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom,
 unsigned long newmax)
   return ret;
   }
 
  -static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
  +static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
  +unsigned int flags)
 
 Indentation looks off.
 
   {
   virDomainObjPtr vm;
  +virDomainDefPtr persistentDef = NULL;
  +virCapsPtr caps = NULL;
   int ret = -1;
   virLXCDomainObjPrivatePtr priv;
  +virLXCDriverPtr driver = dom-conn-privateData;
  +virLXCDriverConfigPtr cfg = NULL;
  +
  +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
  +  VIR_DOMAIN_AFFECT_CONFIG, -1);
 
   if (!(vm = lxcDomObjFromDomain(dom)))
   goto cleanup;
  @@ -720,22 +728,38 @@ static int lxcDomainSetMemory(virDomainPtr dom, 
  unsigned
 long newmem)
   if (virDomainSetMemoryEnsureACL(dom-conn, vm-def)  0)
   goto cleanup;
 
 'make check' complains about a mismatched ACL check:
 ./lxc/lxc_driver.c:728 Mismatch check 'virDomainSetMemoryEnsureACL' for
 function 'lxcDomainSetMemoryFlags'
 
 
 
  +if (!(caps = virLXCDriverGetCapabilities(driver, false)))
  +goto cleanup;
  +
  +if (virDomainLiveConfigHelperMethod(caps, driver-xmlopt, vm, flags,
  +persistentDef)  0)
  +goto cleanup;
  +
 
   if (newmem  vm-def-mem.max_balloon) {
   virReportError(VIR_ERR_INVALID_ARG,
  %s, _(Cannot set memory higher than max 
  memory));
   goto cleanup;
   }
 
 This check is only valid for AFFECT_LIVE. For AFFECT_CONFIG, a separate check
 is needed.

It should be virDomainSetMemoryFlagsEnsureACL.

 
 
  -if (!virDomainObjIsActive(vm)) {
  -virReportError(VIR_ERR_OPERATION_INVALID,
  -   %s, _(Domain is not running));
  -goto cleanup;
  -}
  + if (flags  VIR_DOMAIN_AFFECT_CONFIG) {
  + cfg = virLXCDriverGetConfig(driver);
  + persistentDef-mem.cur_balloon = newmem;
  + if (virDomainSaveConfig(cfg-configDir, persistentDef)  0)
  + goto cleanup;
  + }
 
  -if (virCgroupSetMemory(priv-cgroup, newmem)  0) {
  -virReportError(VIR_ERR_OPERATION_FAILED,
  -   %s, _(Failed to set memory for domain));
  -goto cleanup;
  +if (flags  VIR_DOMAIN_AFFECT_LIVE) {
 
  +if (!virDomainObjIsActive(vm)) {
  +virReportError(VIR_ERR_OPERATION_INVALID,
  +   %s, _(Domain is not running));
  +goto cleanup;
  +}
 
 virDomainLiveConfigHelperMethod already checked if the domain is running when
 AFFECT_LIVE is specified.
Yes, we should remove this block.

Thanks for your review, v2 will come soon.

- Chen

 
  +
  +if (virCgroupSetMemory(priv-cgroup, newmem)  0) {
  +virReportError(VIR_ERR_OPERATION_FAILED,
  +   %s, _(Failed to set memory for domain));
  +goto cleanup;
  +}
   }
 
   ret = 0;
 
 
 Jan
 


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