Re: [libvirt] [Qemu-devel] [PATCH v2 0/2] Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm

2014-08-07 Thread Alex Bligh
Serge,

On 7 Aug 2014, at 03:50, Serge Hallyn serge.hal...@ubuntu.com wrote:

 This worked for me when migrating by hand.  I'm trying to make it work
 through libvirt, using the following patch.  (So whether to have
 pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a
 boolean in /etc/libvirt/qemu.conf)  Qemu starts with decent
 looking args, but for some reason the the migration is failing -
 still looking through the logfile to figure out why.

Are you using exactly the same arguments by hand and with libvirt?

Also, on reflection, given one of the changes between 1.0 and 2.0
is ACPI, I should probably have done some testing with an ACPI
enabled image, rather than just cirros (which not ACPI enabled);
any chance this is ACPI related?

  Now sadly my
 tests are being further slowed down by qcow corruption on my host,
 but I don't think that was the cause of my failure.

Whilst getting the patch right in the first place I tend to
cp from a known good image. Obviously once it works, qcow2
corruption should not happen. But failed migrations (with
or without my patch) do appear to cause this relatively
frequently.

-- 
Alex Bligh




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


[libvirt] Help Required

2014-08-07 Thread ahmad jan
Respected Sir
i am using libvirt-1.2.6 API and facing the following error please guide

libvirtd: /usr/local/lib/libvirt.so.0: version `LIBVIRT_PRIVATE_1.2.6' not 
found (required by libvirtd)

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

[libvirt] Lifecycle events during reboot for KVM and Xen

2014-08-07 Thread Thomas Bechtold
Hi,

during debugging a problem[1] of Openstack Nova I recognized the following:

Doing a reboot (from inside of the VM with reboot command) on a kvm VM
doesn't send any lifecycle events (events debugged with [2]).
Doing the same thing with a xen VM leads to 2 events: First a
VIR_DOMAIN_EVENT_STOPPED and then a VIR_DOMAIN_EVENT_STARTED event.
The problem here is that for the xen case it doesn't seem to be possible
to recognize that a reboot is ongoing. For that reason the OpenStack
Nova component just forces the domain to stop after receiving the
VIR_DOMAIN_EVENT_STOPPED event.

Is it expected that the 2 drivers send different events for the same
action or a bug in qemu/xen/libvirt?

Cheers,

Tom


[1] https://bugs.launchpad.net/nova/+bug/1293480
[2] https://gist.github.com/toabctl/53f26989ad7634a3168b

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


Re: [libvirt] [PATCH 1/2] blockjob: avoid memory leak during block pivot

2014-08-07 Thread Peter Krempa
On 08/06/14 23:12, Eric Blake wrote:
 Valgrind caught a memory leak:
 
 ==2018== 9 bytes in 1 blocks are definitely lost in loss record 143 of 927
 ==2018==at 0x4A0645D: malloc (in 
 /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==2018==by 0x8C42369: strdup (strdup.c:42)
 ==2018==by 0x50EACC9: virStrdup (virstring.c:676)
 ==2018==by 0x50E79E5: virStorageSourceCopy (virstoragefile.c:1845)
 ==2018==by 0x20A3FAA7: qemuDomainBlockCommit (qemu_driver.c:15620)
 ==2018==by 0x51DC6B2: virDomainBlockCommit (libvirt.c:20092)
 
 I traced it to the fact that blockcopy and blockcommit end up
 reparsing a backing chain on pivot, but the chain parsing code
 doesn't gracefully handle the case where the backing file is
 already known.
 
 I'm not exactly sure when this was introduced, but suspect that the
 refactoring in commit 9944b71 and friends that moved towards probing
 in-place rather than into a temporary structure are part of the cause.
 
 * src/util/virstoragefile.c (virStorageFileGetMetadataInternal):
 Don't leak any prior value.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  src/util/virstoragefile.c | 1 +
  1 file changed, 1 insertion(+)
 
 diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
 index 3da9073..5b6b2f5 100644
 --- a/src/util/virstoragefile.c
 +++ b/src/util/virstoragefile.c
 @@ -817,6 +817,7 @@ virStorageFileGetMetadataInternal(virStorageSourcePtr 
 meta,
  goto cleanup;
  }
 
 +VIR_FREE(meta-backingStoreRaw);
  if (fileTypeInfo[meta-format].getBackingStore != NULL) {
  int store = 
 fileTypeInfo[meta-format].getBackingStore(meta-backingStoreRaw,
   backingFormat,
 

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 2/2] blockjob: fix use-after-free in blockcopy

2014-08-07 Thread Peter Krempa
On 08/06/14 23:12, Eric Blake wrote:
 Commit febf84c2 tried to delay in-memory modification of the actual
 domain disk structure until after the qemu event was received.
 However, I missed that the code for block pivot had been temporarily
 setting disk-src = disk-mirror prior to the qemu command, in order
 to label the backing chain of a reused external blockcopy disk;
 and calls into qemu while still in that state before finally undoing
 things at the cleanup label.  Since the qemu event handler then does:
  virStorageSourceFree(disk-src);
  disk-src = disk-mirror;
 we have the sad race that a fast enough qemu event can cause a leak of
 the original disk-src, as well as a use-after-free of the disk-mirror
 contents, bad enough to crash libvirtd in some of my test runs, even
 though the common case of the qemu event being much later won't trip
 the race.
 
 I'll go wear the brown paper bag of shame, for introducing a crasher
 in between rc1 and rc2 of the freeze for 1.2.7 :(  My only
 consolation is that virDomainBlockJobAbort requires the domain:write
 ACL, so it is not a CVE.
 
 The valgrind report when the race occurs looks like:
 
 ==25612== Invalid read of size 4
 ==25612==at 0x50E7C90: virStorageSourceGetActualType 
 (virstoragefile.c:1948)
 ==25612==by 0x209C0B18: qemuDomainDetermineDiskChain (qemu_domain.c:2473)
 ==25612==by 0x209D7F6A: qemuProcessHandleBlockJob (qemu_process.c:1087)
 ==25612==by 0x209F40C9: qemuMonitorEmitBlockJob (qemu_monitor.c:1357)
 ...
 ==25612==  Address 0xe4b5610 is 0 bytes inside a block of size 200 free'd
 ==25612==at 0x4A07577: free (in 
 /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 ==25612==by 0x50839E9: virFree (viralloc.c:582)
 ==25612==by 0x50E7E51: virStorageSourceFree (virstoragefile.c:2015)
 ==25612==by 0x209D7EFF: qemuProcessHandleBlockJob (qemu_process.c:1073)
 ==25612==by 0x209F40C9: qemuMonitorEmitBlockJob (qemu_monitor.c:1357)
 
 * src/qemu/qemu_driver.c (qemuDomainBlockPivot): Don't corrupt
 disk-src, and only label chain for blockcopy.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
  src/qemu/qemu_driver.c | 40 +---
  1 file changed, 25 insertions(+), 15 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 96835bc..82a82aa 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -14886,23 +14886,33 @@ qemuDomainBlockPivot(virConnectPtr conn,
  }
  }
 
 -/* We previously labeled only the top-level image; but if the
 - * image includes a relative backing file, the pivot may result in
 - * qemu needing to open the entire backing chain, so we need to
 - * label the entire chain.  This action is safe even if the
 - * backing chain has already been labeled; but only necessary when
 - * we know for sure that there is a backing chain.  */
 -oldsrc = disk-src;
 -disk-src = disk-mirror;
 +/* For active commit, the mirror is part of the already labeled
 + * chain.  For blockcopy, we previously labeled only the top-level
 + * image; but if the user is reusing an external image that
 + * includes a backing file, the pivot may result in qemu needing
 + * to open the entire backing chain, so we need to label the
 + * entire chain.  This action is safe even if the backing chain
 + * has already been labeled; but only necessary when we know for
 + * sure that there is a backing chain.  */
 +if (disk-mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
 +oldsrc = disk-src;
 +disk-src = disk-mirror;
 
 -if (qemuDomainDetermineDiskChain(driver, vm, disk, false)  0)
 -goto cleanup;
 +if (qemuDomainDetermineDiskChain(driver, vm, disk, false)  0)
 +goto cleanup;
 
 -if (disk-mirror-format  disk-mirror-format != VIR_STORAGE_FILE_RAW 
 
 -(virDomainLockDiskAttach(driver-lockManager, cfg-uri, vm, disk)  
 0 ||
 - qemuSetupDiskCgroup(vm, disk)  0 ||
 - virSecurityManagerSetDiskLabel(driver-securityManager, vm-def, 
 disk)  0))
 -goto cleanup;
 +if (disk-mirror-format 
 +disk-mirror-format != VIR_STORAGE_FILE_RAW 
 +(virDomainLockDiskAttach(driver-lockManager, cfg-uri, vm,
 + disk)  0 ||
 + qemuSetupDiskCgroup(vm, disk)  0 ||
 + virSecurityManagerSetDiskLabel(driver-securityManager, vm-def,
 +disk)  0))
 +goto cleanup;
 +
 +disk-src = oldsrc;
 +oldsrc = NULL;
 +}
 
  /* Attempt the pivot.  Record the attempt now, to prevent duplicate
   * attempts; but the actual disk change will be made when emitting
 

In the cleanup section there's the original place where oldsrc was
returned back to disk-src. That would now be dead code.

ACK with that part removed.

Peter



signature.asc
Description: OpenPGP digital signature
--

[libvirt] [PATCH] audit: Fix some comments

2014-08-07 Thread Wang Rui
Fix a comment in virDomainAuditNetDevice.
Fix a typo in comment of qemuPhysIfaceConnect which is
the caller of virDomainAuditNetDevice.

Signed-off-by: Wang Rui moon.wang...@huawei.com
---
 src/conf/domain_audit.c | 4 ++--
 src/qemu/qemu_command.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 93625fc..fcf9df7 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -318,8 +318,8 @@ virDomainAuditNet(virDomainObjPtr vm,
 
 /**
  * virDomainAuditNetDevice:
- * @vm: domain opening a network-related device
- * @def: details of network device that fd will be tied to
+ * @vmDef: the definition of the VM
+ * @netDef: details of network device that fd will be tied to
  * @device: device being opened (such as /dev/vhost-net,
  * /dev/net/tun, /dev/tanN). Note that merely opening a device
  * does not mean that virDomain owns it; a followup virDomainAuditNet
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a5ff10a..033a5a8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -160,7 +160,7 @@ VIR_ENUM_IMPL(qemuNumaPolicy, VIR_DOMAIN_NUMATUNE_MEM_LAST,
  * qemuPhysIfaceConnect:
  * @def: the definition of the VM (needed by 802.1Qbh and audit)
  * @driver: pointer to the driver instance
- * @net: pointer to he VM's interface description with direct device type
+ * @net: pointer to the VM's interface description with direct device type
  * @qemuCaps: flags for qemu
  * @vmop: VM operation type
  *
-- 
1.7.12.4


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


Re: [libvirt] [PATCH] daemon: Fix indentation in libvirtd.c

2014-08-07 Thread Ján Tomko
On 07/29/2014 10:47 AM, Wang Rui wrote:
 Signed-off-by: Wang Rui moon.wang...@huawei.com
 ---
  daemon/libvirtd.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

ACK and 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] RFC: exposing backing store allocation in domain xml

2014-08-07 Thread Peter Krempa
On 08/06/14 18:36, Eric Blake wrote:
 Adam Litke has been asking if I can expose watermark information from\

bikeshedding
I'd be glad if we stopped calling this watermark. The wiki
disambiguation article states:

citation
A watermark is a recognizable image or pattern in paper used to identify
authenticity.

Watermark or watermarking can also refer to:

In digital watermarks and digital security[edit]
Watermark (data file), a method for ensuring data integrity which
combines aspects of data hashing and digital watermarking
Watermark (data synchronization), directory synchronization related
programming terminology
High-water mark (computer security), network security terminology
Audio watermark, techniques for detecting hidden information from
watermarked signal
Digital watermarking, a technique to embed data in digital audio, images
or video
Watermarking attack, an attack on disk encryption methods
/citation

As this usage is neither of those I always have to translate it to
something more sane when discussing this topic. I actually like the
subject of this mail to refer to what's discussed here. I'm not sure
though if we can come up with a shorter name that will not be ambiguous
with something else.
/bikeshedding


 qemu when doing block commit.  Qemu still doesn't expose that
 information when doing 'virsh blockcopy' (QMP drive-mirror), but DOES
 expose it for regular and active 'virsh blockcommit'.  The idea is that
 when you are writing to more than one file at a time, management needs
 to know if the file is nearing a watermark for usage that necessitates
 growing the storage volume before hitting an ENOSPC error.  In
 particular, Adam's use is running qcow2 format on top of block devices,
 where it is easy to enlarge the block device.
 
 The current libvirt API virDomainBlockInfo() can only get watermark
 information for the active image in a disk chain.  It shows three numbers:
  capacity: the disk size seen by the guest (can be grown via
 virt-resize) - usually larger than the host block device if the guest
 has not used the complete disk, but can also be smaller than the host
 block device due to overhead of qcow2 and the disk is mostly in use
  allocation: the known usage of the host file/block device, should never
 be larger than the physical size (other than rounding up to file sector
 sizing). For sparse files, this number is smaller than total size based
 by the amount of holes in the file. For block devices with qcow2 format,
 this number is reported by qemu as the maximum offset in use by the
 qcow2 file (without regards to whether earlier offsets are holes that
 could be reused). Compare this to what 'du' would report.
  physical: the total size of the host file/block device. Compare this to
 what 'ls' would report.
 
 Also, the libvirt API virStorageVolGetXMLDesc reports two of those
 numbers for a top-level image: capacity and allocation are listed as
 siblings of target.  But it is not present for a backingStore; you
 have to use the API twice.
 
 Now that we have a common virStorageSourcePtr type in the C code, we
 could do a better job of exposing full information for the entire chain
 in a single API call.
 
 I've got a couple ideas of where we can extend existing APIs (and the
 extensions do not involve bumping the .so versioning, so it can also be
 backported, although it gets MUCH harder to backport without
 virStorageSourcePtr).
 
 First, I think the virStorageVolGetXMLDesc should show all three
 numbers, by adding a physical unit='bytes'.../physical element
 alongside the existing capacity and allocation elements.  Also, I
 think it might be nice if we could enhance the API to do a full chain
 recursion (probably requires an explicit flag to turn on) where it shows
 details on the full backing chain, rather than just partial details on
 the immediate backing file; in doing that, the backingStore element
 would gain recursive backingStore (similar to what we recently did in
 domain XML).  In that mode, each layer of backingStore would also
 report capacity, allocation, and physical.  Something like:

While this is certainly a improvement to the storage volume API, it will
not help Adam much as oVirt isn't actually using the storage driver.

 
 # virsh vol-dumpxml --pool default f20.snap2
 volume type='file'

...

 
 Also, the current storage volume API is rather hard-coded to assume that
 backing elements are in the same storage pool, which is not always true.
  It may be time to introduce backingStore type='file' or backingStore
 type='network' to allow better details of cross-pool backing elements,
 while leaving plain backingStore as a back-compat synonym for
 backingStore type='volume' for the current hard-coded layout that
 assumes the backing element is in the same storage pool.

That would certainly improve the usability, but as said it would not
help oVirt that much.

 
 The other idea I've had is to expand the domain XML to expose more
 information about backing 

[libvirt] [libvirt-glib] [PATCH v2 4/4] GVirDomain: Add _has_current_snapshot

2014-08-07 Thread Timm Bäder
... which uses virDomainHasCurrentSnapshot to determine if the given
domain has a current snapshot or not.
---
 libvirt-gobject/libvirt-gobject-domain.c | 34 
 libvirt-gobject/libvirt-gobject-domain.h |  4 
 libvirt-gobject/libvirt-gobject.sym  |  1 +
 3 files changed, 39 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
b/libvirt-gobject/libvirt-gobject-domain.c
index 5399892..f3794cc 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -1686,3 +1686,37 @@ gboolean gvir_domain_fetch_snapshots_finish(GVirDomain 
*dom,
 
 return g_task_propagate_boolean(G_TASK(res), error);
 }
+
+
+/**
+ * gvir_domain_has_current_snapshot:
+ * @dom: a #GVirDomain
+ * @flags: Unused, pass 0
+ * @has_current_snapshot: (out): Will be set to %TRUE if the given domain
+ * has a current snapshot and to %FALSE otherwise.
+ * @error: (allow-none): Place-holder for error or %NULL
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ */
+gboolean gvir_domain_has_current_snapshot(GVirDomain *dom,
+  guint flags,
+  gboolean *has_current_snapshot,
+  GError **error) {
+int status;
+g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+status = virDomainHasCurrentSnapshot(dom-priv-handle,
+ flags);
+
+if (status == -1) {
+gvir_set_error(error, GVIR_DOMAIN_ERROR, 0,
+   Unable to check if domain `%s' has a current snapshot,
+   gvir_domain_get_name(dom));
+return FALSE;
+}
+
+*has_current_snapshot = status;
+
+return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h 
b/libvirt-gobject/libvirt-gobject-domain.h
index 9846375..52b805f 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -380,6 +380,10 @@ gboolean gvir_domain_fetch_snapshots_finish(GVirDomain 
*dom,
 GAsyncResult *res,
 GError **error);
 
+gboolean gvir_domain_has_current_snapshot(GVirDomain *dom,
+  guint flags,
+  gboolean *has_current_snapshot,
+  GError **error);
 
 G_END_DECLS
 
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index bd12239..c34bf02 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -240,6 +240,7 @@ LIBVIRT_GOBJECT_0.1.9 {
gvir_domain_fetch_snapshots_async;
gvir_domain_fetch_snapshots_finish;
gvir_domain_get_snapshots;
+   gvir_domain_has_current_snapshot;
gvir_domain_snapshot_delete;
gvir_domain_snapshot_delete_flags_get_type;
gvir_domain_snapshot_get_is_current;
-- 
2.0.4

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


[libvirt] [libvirt-glib] [PATCH v2 1/4] GVirDomainSnapshot: Add _get_is_current

2014-08-07 Thread Timm Bäder
Add a way to determine if the given GVirDomainSnapshot is the current
snapshot of its GVirDomain.
---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 33 +++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h |  4 +++
 libvirt-gobject/libvirt-gobject.sym   |  1 +
 3 files changed, 38 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c 
b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index 7bb89f1..c53e877 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -235,3 +235,36 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot 
*snapshot,
 }
 return TRUE;
 }
+
+
+/**
+ * gvir_domain_snapshot_get_is_current:
+ * @snapshot: The domain snapshot
+ * @flags: Currently unused, pass 0
+ * @is_current: (out): %TRUE if the given snapshot is the current snapshot
+ * of its domain, %FALSE otherwise.
+ * @error: (allow-none): Place-holder for error or %NULL
+ *
+ * Returns: %TRUE on success, %FALSE otherwise.
+ */
+gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
+ guint flags,
+ gboolean *is_current,
+ GError **error) {
+gint status;
+
+g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
+g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+status = virDomainSnapshotIsCurrent(snapshot-priv-handle, flags);
+if (status == -1) {
+gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR, 0,
+   Could not determine if `%s' is the current snapshot,
+   gvir_domain_snapshot_get_name(snapshot));
+return FALSE;
+}
+
+*is_current = status;
+
+return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h 
b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index b3ebe7f..0a0bb96 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -85,6 +85,10 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot 
*snapshot,
   guint flags,
   GError **error);
 
+gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
+ guint flags,
+ gboolean *is_current,
+ GError **error);
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_SNAPSHOT_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index b0c55b5..c740f88 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -242,6 +242,7 @@ LIBVIRT_GOBJECT_0.1.9 {
gvir_domain_get_snapshots;
gvir_domain_snapshot_delete;
gvir_domain_snapshot_delete_flags_get_type;
+   gvir_domain_snapshot_get_is_current;
gvir_domain_snapshot_list_flags_get_type;
gvir_storage_pool_state_get_type;
gvir_storage_vol_resize_flags_get_type;
-- 
2.0.4

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


[libvirt] [libvirt-glib] [PATCH v2 2/4] GVirDomainSnapshot: Add _revert_to

2014-08-07 Thread Timm Bäder
Add a way to revert a domain to one of its snapshots.
---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 33 +++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h | 17 
 libvirt-gobject/libvirt-gobject.sym   |  2 ++
 3 files changed, 52 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c 
b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index c53e877..dca1086 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -268,3 +268,36 @@ gboolean 
gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
 
 return TRUE;
 }
+
+
+
+/**
+ * gvir_domain_snapshot_revert_to:
+ * @snapshot: The domain snapshot
+ * @flags: Bitwise OR of GVirDomainSnapshotRevertFlags
+ * @error: (allow-none): Place-holder for error or %NULL
+ *
+ * Returns: %TRUE if the snapshot's domain has successfully been
+ * reverted to the given snapshot, %FALSE otherwise, in which case
+ * @error will be set.
+ */
+gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
+guint flags,
+GError **error) {
+int status;
+
+g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
+g_return_val_if_fail((error == NULL) || (*error == NULL), FALSE);
+
+
+status = virDomainRevertToSnapshot(snapshot-priv-handle,
+   flags);
+if (status != 0) {
+gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
+   0, Failed to revert to snapshot `%s',
+   gvir_domain_snapshot_get_name(snapshot));
+return FALSE;
+}
+
+return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h 
b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index 0a0bb96..7abe8ca 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -71,6 +71,19 @@ typedef enum {
 } GVirDomainSnapshotDeleteFlags;
 
 
+/**
+ * GVirDomainSnapshotRevertFlags:
+ * @GVIR_DOMAIN_SNAPSHOT_REVERT_RUNNING: Run after revert
+ * @GVIR_DOMAIN_SNAPSHOT_REVERT_PAUSED: Pause after revert
+ * @GVIR_DOMAIN_SNAPSHOT_REVERT_FORCE: Allow risky reverts
+ */
+typedef enum {
+  GVIR_DOMAIN_SNAPSHOT_REVERT_RUNNING = 1,
+  GVIR_DOMAIN_SNAPSHOT_REVERT_PAUSED = 2,
+  GVIR_DOMAIN_SNAPSHOT_REVERT_FORCE = 4
+} GVirDomainSnapshotRevertFlags;
+
+
 GType gvir_domain_snapshot_get_type(void);
 GType gvir_domain_snapshot_handle_get_type(void);
 
@@ -89,6 +102,10 @@ gboolean 
gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
  guint flags,
  gboolean *is_current,
  GError **error);
+
+gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
+guint flags,
+GError **error);
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_SNAPSHOT_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index c740f88..c1c9421 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -244,6 +244,8 @@ LIBVIRT_GOBJECT_0.1.9 {
gvir_domain_snapshot_delete_flags_get_type;
gvir_domain_snapshot_get_is_current;
gvir_domain_snapshot_list_flags_get_type;
+   gvir_domain_snapshot_revert_flags_get_type;
+   gvir_domain_snapshot_revert_to;
gvir_storage_pool_state_get_type;
gvir_storage_vol_resize_flags_get_type;
gvir_storage_vol_type_get_type;
-- 
2.0.4

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


[libvirt] [libvirt-glib] [PATCH v2 3/4] GVirDomainSnapshot: Add _set_config

2014-08-07 Thread Timm Bäder
... which is basically analogous to gvir_domain_set_config
---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c | 68 +++
 libvirt-gobject/libvirt-gobject-domain-snapshot.h |  5 ++
 libvirt-gobject/libvirt-gobject.sym   |  1 +
 3 files changed, 74 insertions(+)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c 
b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index dca1086..62efce0 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -301,3 +301,71 @@ gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot 
*snapshot,
 
 return TRUE;
 }
+
+
+
+/**
+ * gvir_domain_snapshot_set_config:
+ * @snapshot: The domain snapshot
+ * @conf: The new config object
+ * @error: (allow-none): Place-holder for error or %NULL
+ *
+ * Updates the given snapshot's configuration according to the
+ * given GVirConfigDomainSnapshot.
+ *
+ * Returns: %TRUE if no error was reported, %FALSE otherwise.
+ */
+gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot,
+ GVirConfigDomainSnapshot *conf,
+ GError **error)
+{
+gchar *xml;
+virConnectPtr conn;
+virDomainSnapshotPtr handle;
+virDomainPtr domain;
+GVirDomainSnapshotPrivate *priv;
+
+g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
+g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(conf), FALSE);
+g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+priv = snapshot-priv;
+handle = priv-handle;
+domain = virDomainSnapshotGetDomain(handle);
+
+
+if ((conn = virDomainSnapshotGetConnect(priv-handle)) == NULL) {
+gvir_set_error_literal(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
+   0,
+   Failed to get domain connection);
+return FALSE;
+}
+
+
+/* XXX Changing the name will create a new snapshot */
+if (g_strcmp0 (gvir_domain_snapshot_get_name(snapshot),
+   gvir_config_domain_snapshot_get_name(conf)) != 0) {
+gvir_set_error_literal(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
+   0,
+   Cannot set config: snapshot names don't 
match);
+return FALSE;
+}
+
+
+xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
+
+handle = virDomainSnapshotCreateXML(domain,
+xml,
+VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE);
+g_free(xml);
+
+if (handle == NULL) {
+gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
+   0,
+   Failed to create snapshot `%s' from XML definition,
+   gvir_domain_snapshot_get_name(snapshot));
+return FALSE;
+}
+virDomainSnapshotFree(handle);
+return TRUE;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h 
b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
index 7abe8ca..5ab3025 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
@@ -106,6 +106,11 @@ gboolean 
gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
 gboolean gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
 guint flags,
 GError **error);
+
+gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot,
+ GVirConfigDomainSnapshot *conf,
+ GError **error);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_SNAPSHOT_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym 
b/libvirt-gobject/libvirt-gobject.sym
index c1c9421..bd12239 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -246,6 +246,7 @@ LIBVIRT_GOBJECT_0.1.9 {
gvir_domain_snapshot_list_flags_get_type;
gvir_domain_snapshot_revert_flags_get_type;
gvir_domain_snapshot_revert_to;
+   gvir_domain_snapshot_set_config;
gvir_storage_pool_state_get_type;
gvir_storage_vol_resize_flags_get_type;
gvir_storage_vol_type_get_type;
-- 
2.0.4

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


[libvirt] Can't run vbox's network driver and storage driver.

2014-08-07 Thread Taowei Luo
Hi, I just can't find a way running the network driver and storage driver
provided by vbox.

When I use vbox:///session as an url to run vbox driver and call network
(or storage) API, the vbox's driver didn't execute. Instead, it would run
drivers in src/network and src/storage.

The problem only comes with the network driver and storage driver. Which
means the vbox's domain driver works well with libvirt.

I know that actually libvirt communicate with vbox driver though the remote
driver, but I don't know how to make remote driver call vbox's network
driver(or storage driver).

BTW, I need vbox's driver because I have to do some test on it.

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

Re: [libvirt] [RFC PATCH 2/5] conf: Parse and format ivshmem device XML

2014-08-07 Thread Martin Kletzander

On Tue, Aug 05, 2014 at 06:48:02PM +0200, Maxime Leroy wrote:

This patch adds configuration support for the ivshmem device
as described in the schema in the previous patch.

Signed-off-by: Maxime Leroy maxime.le...@6wind.com
---
src/conf/domain_conf.c   | 234 ++-
src/conf/domain_conf.h   |  40 
src/libvirt_private.syms |   4 +
3 files changed, 277 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c25c74b..829f1bf 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -234,7 +234,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
  chr,
  memballoon,
  nvram,
-  rng)
+  rng,
+  ivshmem)

VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
  none,
@@ -759,6 +760,15 @@ VIR_ENUM_DECL(virDomainBlockJob)
VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST,
  , , copy, , active-commit)

+VIR_ENUM_IMPL(virDomainIvshmemServer, VIR_DOMAIN_IVSHMEM_SERVER_LAST,
+  yes,
+  no);
+


Since commit bb018ce6c85ee17711a0d8c122c6861bb189ce56 we have
virTristateBool enym type for this.


+VIR_ENUM_IMPL(virDomainIvshmemRole, VIR_DOMAIN_IVSHMEM_ROLE_LAST,
+  default,
+  master,
+  peer);
+


I know I said that already, but just to be sure, this is not needed as
it doesn't make sense in qemu :(

Martin


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

Re: [libvirt] [libvirt-glib] [PATCH v2 4/4] GVirDomain: Add _has_current_snapshot

2014-08-07 Thread Christophe Fergeau
On Thu, Aug 07, 2014 at 12:20:16PM +0200, Timm Bäder wrote:
 ... which uses virDomainHasCurrentSnapshot to determine if the given
 domain has a current snapshot or not.
 ---
  libvirt-gobject/libvirt-gobject-domain.c | 34 
 
  libvirt-gobject/libvirt-gobject-domain.h |  4 
  libvirt-gobject/libvirt-gobject.sym  |  1 +
  3 files changed, 39 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain.c 
 b/libvirt-gobject/libvirt-gobject-domain.c
 index 5399892..f3794cc 100644
 --- a/libvirt-gobject/libvirt-gobject-domain.c
 +++ b/libvirt-gobject/libvirt-gobject-domain.c
 @@ -1686,3 +1686,37 @@ gboolean gvir_domain_fetch_snapshots_finish(GVirDomain 
 *dom,
  
  return g_task_propagate_boolean(G_TASK(res), error);
  }
 +
 +
 +/**
 + * gvir_domain_has_current_snapshot:
 + * @dom: a #GVirDomain
 + * @flags: Unused, pass 0
 + * @has_current_snapshot: (out): Will be set to %TRUE if the given domain
 + * has a current snapshot and to %FALSE otherwise.
 + * @error: (allow-none): Place-holder for error or %NULL
 + *
 + * Returns: %TRUE on success, %FALSE otherwise.
 + */
 +gboolean gvir_domain_has_current_snapshot(GVirDomain *dom,
 +  guint flags,
 +  gboolean *has_current_snapshot,
 +  GError **error) {

I think this one needs to be gvir_domain_get_has_current_snapshot as
well :(

Christophe


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

Re: [libvirt] [libvirt-glib] [PATCH v2 1/4] GVirDomainSnapshot: Add _get_is_current

2014-08-07 Thread Christophe Fergeau
Series looks good to me apart from that naming comment in 4/4.
If someone does not like the use of gboolean *is_current as a return
value in
gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
 guint flags,
 gboolean *is_current,
 GError **error) {

now would be a good time to complain ;)

Christophe

On Thu, Aug 07, 2014 at 12:20:13PM +0200, Timm Bäder wrote:
 Add a way to determine if the given GVirDomainSnapshot is the current
 snapshot of its GVirDomain.
 ---
  libvirt-gobject/libvirt-gobject-domain-snapshot.c | 33 
 +++
  libvirt-gobject/libvirt-gobject-domain-snapshot.h |  4 +++
  libvirt-gobject/libvirt-gobject.sym   |  1 +
  3 files changed, 38 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c 
 b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
 index 7bb89f1..c53e877 100644
 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
 +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
 @@ -235,3 +235,36 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot 
 *snapshot,
  }
  return TRUE;
  }
 +
 +
 +/**
 + * gvir_domain_snapshot_get_is_current:
 + * @snapshot: The domain snapshot
 + * @flags: Currently unused, pass 0
 + * @is_current: (out): %TRUE if the given snapshot is the current snapshot
 + * of its domain, %FALSE otherwise.
 + * @error: (allow-none): Place-holder for error or %NULL
 + *
 + * Returns: %TRUE on success, %FALSE otherwise.
 + */
 +gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
 + guint flags,
 + gboolean *is_current,
 + GError **error) {
 +gint status;
 +
 +g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
 +g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
 +
 +status = virDomainSnapshotIsCurrent(snapshot-priv-handle, flags);
 +if (status == -1) {
 +gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR, 0,
 +   Could not determine if `%s' is the current snapshot,
 +   gvir_domain_snapshot_get_name(snapshot));
 +return FALSE;
 +}
 +
 +*is_current = status;
 +
 +return TRUE;
 +}
 diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.h 
 b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
 index b3ebe7f..0a0bb96 100644
 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.h
 +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.h
 @@ -85,6 +85,10 @@ gboolean gvir_domain_snapshot_delete (GVirDomainSnapshot 
 *snapshot,
guint flags,
GError **error);
  
 +gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
 + guint flags,
 + gboolean *is_current,
 + GError **error);
  G_END_DECLS
  
  #endif /* __LIBVIRT_GOBJECT_DOMAIN_SNAPSHOT_H__ */
 diff --git a/libvirt-gobject/libvirt-gobject.sym 
 b/libvirt-gobject/libvirt-gobject.sym
 index b0c55b5..c740f88 100644
 --- a/libvirt-gobject/libvirt-gobject.sym
 +++ b/libvirt-gobject/libvirt-gobject.sym
 @@ -242,6 +242,7 @@ LIBVIRT_GOBJECT_0.1.9 {
   gvir_domain_get_snapshots;
   gvir_domain_snapshot_delete;
   gvir_domain_snapshot_delete_flags_get_type;
 + gvir_domain_snapshot_get_is_current;
   gvir_domain_snapshot_list_flags_get_type;
   gvir_storage_pool_state_get_type;
   gvir_storage_vol_resize_flags_get_type;
 -- 
 2.0.4
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] Error

2014-08-07 Thread Kyle Lafkoff
You're missing the linux kernel headers package. Try installing with:

$ sudo apt-get install linux-headers-`uname -r`

Is there a reason you need to compile your own verse using the provided
package from the system?

e.g.,

$ sudo apt-get install libvirt0


On Wed, Aug 6, 2014 at 9:53 PM, ahmad jan mr_ahmad...@yahoo.com wrote:

 I am using Libvirt-1.0.0 on ubuntu 14.02 LTS and found the following error

 checking linux/if_bridge.h usability... no

 checking linux/if_bridge.h presence... yes
 configure: WARNING: linux/if_bridge.h: present but cannot be compiled
 configure: WARNING: linux/if_bridge.h: check for missing prerequisite
 headers?
 configure: WARNING: linux/if_bridge.h: see the Autoconf documentation
 configure: WARNING: linux/if_bridge.h: section Present But Cannot Be
 Compiled
 configure: WARNING: linux/if_bridge.h: proceeding with the compiler's result
 configure: WARNING: ## - ##
 configure: WARNING: ## Report this to libvir-list at redhat.com ##
 configure: WARNING: ## - ##
 checking for linux/if_bridge.h... no
 configure: error: You must install kernel-headers in order to compile
 libvirt with QEMU or LXC support


 Please Guide, how do I recover it


 thanks



 --
 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] [Qemu-devel] [PATCH v2 0/2] Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm

2014-08-07 Thread Serge E. Hallyn
Quoting Alex Bligh (a...@alex.org.uk):
 Serge,
 
 On 7 Aug 2014, at 03:50, Serge Hallyn serge.hal...@ubuntu.com wrote:
 
  This worked for me when migrating by hand.  I'm trying to make it work
  through libvirt, using the following patch.  (So whether to have
  pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a
  boolean in /etc/libvirt/qemu.conf)  Qemu starts with decent
  looking args, but for some reason the the migration is failing -
  still looking through the logfile to figure out why.
 
 Are you using exactly the same arguments by hand and with libvirt?
 
 Also, on reflection, given one of the changes between 1.0 and 2.0
 is ACPI, I should probably have done some testing with an ACPI
 enabled image, rather than just cirros (which not ACPI enabled);
 any chance this is ACPI related?

Turning off acpi (well, commenting it out in the xml, which I'm assuming
dtrt) doesn't help:

===
LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin 
QEMU_AUDIO_DRV=none /usr/bin/kvm -name cirros -S -global 
virtio-net-pci.romfile=pxe-virtio.rom.12.04 -machine 
pc-1.0-qemu-kvm,accel=kvm,usb=off -m 512 -realtime mlock=off -smp 
1,sockets=1,cores=1,threads=1 -uuid 2542c328-6842-33ef-d30e-866c3f3189a8 
-no-user-config -nodefaults -chardev 
socket,id=charmonitor,path=/var/lib/libvirt/qemu/cirros.monitor,server,nowait 
-mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown 
-no-acpi -boot strict=on -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 
-drive 
file=/var/lib/libvirt/images/cirros.img,if=none,id=drive-ide0-0-0,format=raw 
-device ide-hd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 
-netdev tap,fd=26,id=hostnet0 -device 
virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:be:d8:99,bus=pci.0,addr=0x3 
-chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 
-vnc 127.0.0.1:0 -device cirrus-vga,id=!
 video0,bus=pci.0,addr=0x2 -device AC97,id=sound0,bus=pci.0,addr=0x4 -incoming 
fd:23 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -msg 
timestamp=on
2014-08-07 12:51:02.400+: 1539: debug : virFileClose:99 : Closed fd 25
2014-08-07 12:51:02.401+: 1539: debug : virFileClose:99 : Closed fd 31
2014-08-07 12:51:02.401+: 1539: debug : virFileClose:99 : Closed fd 3
2014-08-07 12:51:02.401+: 1540: debug : virExec:616 : Run hook 
0x7f25cb17bca0 0x7f25d3aedf20
2014-08-07 12:51:02.401+: 1540: debug : qemuProcessHook:2719 : Obtaining 
domain lock
2014-08-07 12:51:02.401+: 1540: debug : virDomainLockProcessStart:175 : 
plugin=0x7f25c4170290 dom=0x7f25c4186510 paused=1 fd=0x7f25d3aedb44
2014-08-07 12:51:02.401+: 1540: debug : virDomainLockManagerNew:133 : 
plugin=0x7f25c4170290 dom=0x7f25c4186510 withResources=1
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerPluginGetDriver:281 : 
plugin=0x7f25c4170290
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerNew:305 : 
driver=0x7f25da723580 type=0 nparams=5 params=0x7f25d3aeda30 flags=0
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerLogParams:98 :   
key=uuid type=uuid value=2542c328-6842-33ef-d30e-866c3f3189a8
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerLogParams:91 :   
key=name type=string value=cirros
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerLogParams:79 :   
key=id type=uint value=2
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerLogParams:79 :   
key=pid type=uint value=1540
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerLogParams:94 :   
key=uri type=cstring value=qemu:///system
2014-08-07 12:51:02.401+: 1540: debug : virDomainLockManagerNew:145 : 
Adding leases
2014-08-07 12:51:02.401+: 1540: debug : virDomainLockManagerNew:150 : 
Adding disks
2014-08-07 12:51:02.401+: 1540: debug : virDomainLockManagerAddDisk:91 : 
Add disk /var/lib/libvirt/images/cirros.img
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerAddResource:332 : 
lock=0x7f25c417b080 type=0 name=/var/lib/libvirt/images/cirros.img nparams=0 
params=(nil) flags=0
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerAcquire:350 : 
lock=0x7f25c417b080 state='null' flags=3 action=0 fd=0x7f25d3aedb44
2014-08-07 12:51:02.401+: 1540: debug : virLockManagerFree:387 : 
lock=0x7f25c417b080
2014-08-07 12:51:02.401+: 1540: debug : virObjectUnref:259 : OBJECT_UNREF: 
obj=0x7f25c415e620
2014-08-07 12:51:02.401+: 1540: debug : qemuProcessHook:2746 : Hook 
complete ret=0
2014-08-07 12:51:02.401+: 1540: debug : virExec:618 : Done hook 0
2014-08-07 12:51:02.401+: 1540: debug : virExec:638 : Setting child 
AppArmor profile to libvirt-2542c328-6842-33ef-d30e-866c3f3189a8
2014-08-07 12:51:02.402+: 1540: debug : virExec:655 : Setting child uid:gid 
to 107:113 with caps 0
2014-08-07 12:51:02.402+: 1540: debug : virCommandHandshakeChild:358 : 
Notifying parent for handshake start on 28
2014-08-07 12:51:02.402+: 1540: debug 

[libvirt] [PATCH libvirt 0/6] Add support for qemu usb-mtp device

2014-08-07 Thread Giuseppe Scrivano
This series adds support for qemu usb-mtp devices.

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

Giuseppe Scrivano (6):
  conf: add MTP filesystem support to the parser
  conf, virDomainFSDefPtr: rename path argument to target
  qemu_command: fix block indentation
  qemu: add support for MTP filesystem
  docs: add documentation and schema for MTP filesystem type
  tests: add tests for MTP filesystem

 docs/formatdomain.html.in  |  9 +
 docs/schemas/domaincommon.rng  | 15 ++--
 src/conf/domain_conf.c | 38 +--
 src/conf/domain_conf.h |  3 +-
 src/qemu/qemu_command.c| 67 +++---
 tests/domainconfdata/getfilesystem.xml |  4 ++
 tests/domainconftest.c |  2 +
 7 files changed, 93 insertions(+), 45 deletions(-)

-- 
1.9.3

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


[libvirt] [PATCH libvirt 1/6] conf: add MTP filesystem support to the parser

2014-08-07 Thread Giuseppe Scrivano
Signed-off-by: Giuseppe Scrivano gscri...@redhat.com
---
 src/conf/domain_conf.c | 34 +-
 src/conf/domain_conf.h |  1 +
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c25c74b..3bdf46a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -342,7 +342,8 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
   file,
   template,
   ram,
-  bind)
+  bind,
+  mtp)
 
 VIR_ENUM_IMPL(virDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
   default,
@@ -6404,7 +6405,8 @@ virDomainFSDefParseXML(xmlNodePtr node,
 xmlStrEqual(cur-name, BAD_CAST source)) {
 
 if (def-type == VIR_DOMAIN_FS_TYPE_MOUNT ||
-def-type == VIR_DOMAIN_FS_TYPE_BIND)
+def-type == VIR_DOMAIN_FS_TYPE_BIND ||
+def-type == VIR_DOMAIN_FS_TYPE_MTP)
 source = virXMLPropString(cur, dir);
 else if (def-type == VIR_DOMAIN_FS_TYPE_FILE)
 source = virXMLPropString(cur, file);
@@ -6418,7 +6420,10 @@ virDomainFSDefParseXML(xmlNodePtr node,
 }
 } else if (!target 
xmlStrEqual(cur-name, BAD_CAST target)) {
-target = virXMLPropString(cur, dir);
+if (def-type == VIR_DOMAIN_FS_TYPE_MTP)
+target = virXMLPropString(cur, name);
+else
+target = virXMLPropString(cur, dir);
 } else if (xmlStrEqual(cur-name, BAD_CAST readonly)) {
 def-readonly = true;
 } else if (xmlStrEqual(cur-name, BAD_CAST driver)) {
@@ -15668,9 +15673,11 @@ virDomainFSDefFormat(virBufferPtr buf,
 }
 
 
-virBufferAsprintf(buf,
-  filesystem type='%s' accessmode='%s'\n,
-  type, accessmode);
+virBufferAsprintf(buf, filesystem type='%s', type);
+if (def-type != VIR_DOMAIN_FS_TYPE_MTP)
+virBufferAsprintf(buf,  accessmode='%s', accessmode);
+virBufferAddLit(buf, \n);
+
 virBufferAdjustIndent(buf, 2);
 if (def-fsdriver) {
 virBufferAsprintf(buf, driver type='%s', fsdriver);
@@ -15712,15 +15719,24 @@ virDomainFSDefFormat(virBufferPtr buf,
 virBufferAsprintf(buf, source usage='%lld' units='KiB'/\n,
   def-usage / 1024);
 break;
+case VIR_DOMAIN_FS_TYPE_MTP:
+virBufferEscapeString(buf, source dir='%s'/\n,
+  def-src);
+break;
 }
 
-virBufferEscapeString(buf, target dir='%s'/\n,
-  def-dst);
+if (def-type == VIR_DOMAIN_FS_TYPE_MTP)
+virBufferEscapeString(buf, target name='%s'/\n,
+  def-dst);
+else
+virBufferEscapeString(buf, target dir='%s'/\n,
+  def-dst);
 
 if (def-readonly)
 virBufferAddLit(buf, readonly/\n);
 
-if (virDomainDeviceInfoFormat(buf, def-info, flags)  0)
+if (def-type != VIR_DOMAIN_FS_TYPE_MTP 
+virDomainDeviceInfoFormat(buf, def-info, flags)  0)
 return -1;
 
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bffc0a5..a4d8a76 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -760,6 +760,7 @@ typedef enum {
 VIR_DOMAIN_FS_TYPE_TEMPLATE, /* Expands a OS template to a guest dir */
 VIR_DOMAIN_FS_TYPE_RAM,   /* Mount a RAM filesystem on a guest dir */
 VIR_DOMAIN_FS_TYPE_BIND,  /* Binds a guest dir to another guest dir */
+VIR_DOMAIN_FS_TYPE_MTP,   /* Binds a host dir to a MTP guest device */
 
 VIR_DOMAIN_FS_TYPE_LAST
 } virDomainFSType;
-- 
1.9.3

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


[libvirt] [PATCH libvirt 3/6] qemu_command: fix block indentation

2014-08-07 Thread Giuseppe Scrivano
Signed-off-by: Giuseppe Scrivano gscri...@redhat.com
---
 src/qemu/qemu_command.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a5ff10a..716be0a 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3988,13 +3988,13 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
 }
 
 if (fs-wrpolicy) {
-   if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV_WRITEOUT)) {
-   virBufferAsprintf(opt, ,writeout=%s, wrpolicy);
-   } else {
-   virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-  _(filesystem writeout not supported));
-   goto error;
-   }
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_FSDEV_WRITEOUT)) {
+virBufferAsprintf(opt, ,writeout=%s, wrpolicy);
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(filesystem writeout not supported));
+goto error;
+}
 }
 
 virBufferAsprintf(opt, ,id=%s%s, QEMU_FSDEV_HOST_PREFIX, 
fs-info.alias);
-- 
1.9.3

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


[libvirt] [PATCH libvirt 6/6] tests: add tests for MTP filesystem

2014-08-07 Thread Giuseppe Scrivano
Signed-off-by: Giuseppe Scrivano gscri...@redhat.com
---
 tests/domainconfdata/getfilesystem.xml | 4 
 tests/domainconftest.c | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/tests/domainconfdata/getfilesystem.xml 
b/tests/domainconfdata/getfilesystem.xml
index 2ee78b4..efcd83b 100644
--- a/tests/domainconfdata/getfilesystem.xml
+++ b/tests/domainconfdata/getfilesystem.xml
@@ -21,6 +21,10 @@
   source dir='/'/
   target dir='/dev'/
 /filesystem
+filesystem type='mtp'
+  source dir='/'/
+  target name='mtp share'/
+/filesystem
 console type='pty'
   target type='lxc' port='0'/
 /console
diff --git a/tests/domainconftest.c b/tests/domainconftest.c
index 3d6ebe1..eee3193 100644
--- a/tests/domainconftest.c
+++ b/tests/domainconftest.c
@@ -111,6 +111,8 @@ mymain(void)
 DO_TEST_GET_FS(/dev, true);
 DO_TEST_GET_FS(/dev/pts, false);
 DO_TEST_GET_FS(/doesnotexist, false);
+DO_TEST_GET_FS(mtp share, true);
+DO_TEST_GET_FS(mtp not existing share, false);
 
 virObjectUnref(caps);
 virObjectUnref(xmlopt);
-- 
1.9.3

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


[libvirt] [PATCH libvirt 2/6] conf, virDomainFSDefPtr: rename path argument to target

2014-08-07 Thread Giuseppe Scrivano
Since the target for MTP is a name and not a path, make the function
more generic.

Signed-off-by: Giuseppe Scrivano gscri...@redhat.com
---
 src/conf/domain_conf.c | 4 ++--
 src/conf/domain_conf.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3bdf46a..e8abc1a 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -18782,12 +18782,12 @@ virDomainFSRemove(virDomainDefPtr def, size_t i)
 
 virDomainFSDefPtr
 virDomainGetFilesystemForTarget(virDomainDefPtr def,
-const char *path)
+const char *target)
 {
 size_t i;
 
 for (i = 0; i  def-nfss; i++) {
-if (STREQ(def-fss[i]-dst, path))
+if (STREQ(def-fss[i]-dst, target))
 return def-fss[i];
 }
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index a4d8a76..48968f0 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2485,7 +2485,7 @@ int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
 int *devIdx);
 
 virDomainFSDefPtr virDomainGetFilesystemForTarget(virDomainDefPtr def,
-  const char *path);
+  const char *target);
 int virDomainFSInsert(virDomainDefPtr def, virDomainFSDefPtr fs);
 int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
 virDomainFSDefPtr virDomainFSRemove(virDomainDefPtr def, size_t i);
-- 
1.9.3

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


[libvirt] [PATCH libvirt 5/6] docs: add documentation and schema for MTP filesystem type

2014-08-07 Thread Giuseppe Scrivano
Signed-off-by: Giuseppe Scrivano gscri...@redhat.com
---
 docs/formatdomain.html.in |  9 +
 docs/schemas/domaincommon.rng | 15 ---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index e5b1adb..938409b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2309,6 +2309,10 @@
   lt;target dir='/import/from/host'/gt;
   lt;readonly/gt;
 lt;/filesystemgt;
+lt;filesystem type='mtp'gt;
+  lt;source dir='/export/to/guest'/gt;
+  lt;target name='my-vm-template'/gt;
+lt;/filesystemgt;
 ...
   lt;/devicesgt;
   .../pre
@@ -2367,6 +2371,11 @@
   A directory inside the guest will be bound to another
   directory inside the guest. Only used by LXC driver
   span class=since (since 0.9.13)/span/dd
+dtcodetype='mtp'/code/dt
+dd
+  A host directory will be exposed to the guest as a MTP
+  device. Only used by QEMU/KVM driver
+  span class=since (since 1.2.8)/span/dd
 /dl
 
   The filesystem block has an optional attribute codeaccessmode/code
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 11f0fd0..dd870ef 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1899,9 +1899,18 @@
   /choice
   interleave
 element name=target
-  attribute name=dir
-ref name=absDirPath/
-  /attribute
+  choice
+group
+  attribute name=dir
+ref name=absDirPath/
+  /attribute
+/group
+group
+  attribute name=name
+ref name=genericName/
+  /attribute
+/group
+  /choice
   empty/
 /element
 optional
-- 
1.9.3

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


[libvirt] [PATCH libvirt 4/6] qemu: add support for MTP filesystem

2014-08-07 Thread Giuseppe Scrivano
Generate the qemu command line option:

-device 'usb-mtp,root=$SRC,desc=$TARGET'

from the definition XML:

filesystem type='mtp'
  source dir='$SRC'/
  target name='$TARGET'/
/filesystem

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

Signed-off-by: Giuseppe Scrivano gscri...@redhat.com
---
 src/qemu/qemu_command.c | 53 -
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 716be0a..ad5b318 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3955,12 +3955,6 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
 const char *driver = qemuDomainFSDriverTypeToString(fs-fsdriver);
 const char *wrpolicy = virDomainFSWrpolicyTypeToString(fs-wrpolicy);
 
-if (fs-type != VIR_DOMAIN_FS_TYPE_MOUNT) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(only supports mount filesystem type));
-goto error;
-}
-
 if (!driver) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
_(Filesystem driver type not supported));
@@ -4029,22 +4023,26 @@ qemuBuildFSDevStr(virDomainDefPtr def,
 {
 virBuffer opt = VIR_BUFFER_INITIALIZER;
 
-if (fs-type != VIR_DOMAIN_FS_TYPE_MOUNT) {
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
-   _(can only passthrough directories));
-goto error;
-}
+if (fs-type == VIR_DOMAIN_FS_TYPE_MOUNT) {
+virBufferAddLit(opt, virtio-9p-pci);
+virBufferAsprintf(opt, ,id=%s, fs-info.alias);
+virBufferAsprintf(opt, ,fsdev=%s%s, QEMU_FSDEV_HOST_PREFIX, 
fs-info.alias);
+virBufferAsprintf(opt, ,mount_tag=%s, fs-dst);
 
-virBufferAddLit(opt, virtio-9p-pci);
-virBufferAsprintf(opt, ,id=%s, fs-info.alias);
-virBufferAsprintf(opt, ,fsdev=%s%s, QEMU_FSDEV_HOST_PREFIX, 
fs-info.alias);
-virBufferAsprintf(opt, ,mount_tag=%s, fs-dst);
-
-if (qemuBuildDeviceAddressStr(opt, def, fs-info, qemuCaps)  0)
-goto error;
+if (qemuBuildDeviceAddressStr(opt, def, fs-info, qemuCaps)  0)
+goto error;
 
-if (virBufferCheckError(opt)  0)
+if (virBufferCheckError(opt)  0)
+goto error;
+}
+else if (fs-type == VIR_DOMAIN_FS_TYPE_MTP) {
+virBufferAddLit(opt, usb-mtp);
+virBufferAsprintf(opt, ,root=%s,desc=%s, fs-src, fs-dst);
+} else {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(unsupported filesystem type));
 goto error;
+}
 
 return virBufferContentAndReset(opt);
 
@@ -8310,11 +8308,20 @@ qemuBuildCommandLine(virConnectPtr conn,
 char *optstr;
 virDomainFSDefPtr fs = def-fss[i];
 
-virCommandAddArg(cmd, -fsdev);
-if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
+if (fs-type != VIR_DOMAIN_FS_TYPE_MOUNT 
+fs-type != VIR_DOMAIN_FS_TYPE_MTP) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(only supports mount or mtp filesystem 
type));
 goto error;
-virCommandAddArg(cmd, optstr);
-VIR_FREE(optstr);
+}
+
+if (fs-type == VIR_DOMAIN_FS_TYPE_MOUNT) {
+virCommandAddArg(cmd, -fsdev);
+if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
+goto error;
+virCommandAddArg(cmd, optstr);
+VIR_FREE(optstr);
+}
 
 virCommandAddArg(cmd, -device);
 if (!(optstr = qemuBuildFSDevStr(def, fs, qemuCaps)))
-- 
1.9.3

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


[libvirt] [PATCH] docs: use unique dev names in disk examples

2014-08-07 Thread Eric Blake
Jiri Moskovcak reported on IRC that the documentation on valid
disk was confusing because it didn't have unique dev='...'
entries.

* docs/formatdomain.html.in: Use unique names.

Signed-off-by: Eric Blake ebl...@redhat.com
---
 docs/formatdomain.html.in |   26 +-
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8950959..08f31c4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1540,14 +1540,14 @@
   lt;source protocol=rbd name=image_name2gt;
 lt;host name=hostname port=7000/gt;
   lt;/sourcegt;
-  lt;target dev=hdd bus=ide/gt;
+  lt;target dev=hdc bus=ide/gt;
   lt;auth username='myuser'gt;
 lt;secret type='ceph' usage='mypassid'/gt;
   lt;/authgt;
 lt;/diskgt;
 lt;disk type='block' device='cdrom'gt;
   lt;driver name='qemu' type='raw'/gt;
-  lt;target dev='hdc' bus='ide' tray='open'/gt;
+  lt;target dev='hdd' bus='ide' tray='open'/gt;
   lt;readonly/gt;
 lt;/diskgt;
 lt;disk type='network' device='cdrom'gt;
@@ -1555,7 +1555,7 @@
   lt;source protocol=http name=url_pathgt;
 lt;host name=hostname port=80/gt;
   lt;/sourcegt;
-  lt;target dev='hdc' bus='ide' tray='open'/gt;
+  lt;target dev='hde' bus='ide' tray='open'/gt;
   lt;readonly/gt;
 lt;/diskgt;
 lt;disk type='network' device='cdrom'gt;
@@ -1563,7 +1563,7 @@
   lt;source protocol=https name=url_pathgt;
 lt;host name=hostname port=443/gt;
   lt;/sourcegt;
-  lt;target dev='hdc' bus='ide' tray='open'/gt;
+  lt;target dev='hdf' bus='ide' tray='open'/gt;
   lt;readonly/gt;
 lt;/diskgt;
 lt;disk type='network' device='cdrom'gt;
@@ -1571,7 +1571,7 @@
   lt;source protocol=ftp name=url_pathgt;
 lt;host name=hostname port=21/gt;
   lt;/sourcegt;
-  lt;target dev='hdc' bus='ide' tray='open'/gt;
+  lt;target dev='hdg' bus='ide' tray='open'/gt;
   lt;readonly/gt;
 lt;/diskgt;
 lt;disk type='network' device='cdrom'gt;
@@ -1579,7 +1579,7 @@
   lt;source protocol=ftps name=url_pathgt;
 lt;host name=hostname port=990/gt;
   lt;/sourcegt;
-  lt;target dev='hdc' bus='ide' tray='open'/gt;
+  lt;target dev='hdh' bus='ide' tray='open'/gt;
   lt;readonly/gt;
 lt;/diskgt;
 lt;disk type='network' device='cdrom'gt;
@@ -1587,7 +1587,7 @@
   lt;source protocol=tftp name=url_pathgt;
 lt;host name=hostname port=69/gt;
   lt;/sourcegt;
-  lt;target dev='hdc' bus='ide' tray='open'/gt;
+  lt;target dev='hdi' bus='ide' tray='open'/gt;
   lt;readonly/gt;
 lt;/diskgt;
 lt;disk type='block' device='lun'gt;
@@ -1601,12 +1601,12 @@
   lt;source dev='/dev/sda'/gt;
   lt;geometry cyls='16383' heads='16' secs='63' trans='lba'/gt;
   lt;blockio logical_block_size='512' physical_block_size='4096'/gt;
-  lt;target dev='hda' bus='ide'/gt;
+  lt;target dev='sdb' bus='ide'/gt;
 lt;/diskgt;
 lt;disk type='volume' device='disk'gt;
   lt;driver name='qemu' type='raw'/gt;
   lt;source pool='blk-pool0' volume='blk-pool0-vol0'/gt;
-  lt;target dev='hda' bus='ide'/gt;
+  lt;target dev='sdc' bus='ide'/gt;
 lt;/diskgt;
 lt;disk type='network' device='disk'gt;
   lt;driver name='qemu' type='raw'/gt;
@@ -1626,7 +1626,7 @@
   lt;auth username='myuser'gt;
 lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
-  lt;target dev='sda' bus='scsi'/gt;
+  lt;target dev='vdb' bus='scsi'/gt;
 lt;/diskgt;
 lt;disk type='volume' device='disk'gt;
   lt;driver name='qemu' type='raw'/gt;
@@ -1634,7 +1634,7 @@
   lt;auth username='myuser'gt;
 lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
-  lt;target dev='vda' bus='virtio'/gt;
+  lt;target dev='vdc' bus='virtio'/gt;
 lt;/diskgt;
 lt;disk type='volume' device='disk'gt;
   lt;driver name='qemu' type='raw'/gt;
@@ -1642,7 +1642,7 @@
   lt;auth username='myuser'gt;
 lt;secret type='iscsi' usage='libvirtiscsi'/gt;
   lt;/authgt;
-  lt;target dev='vda' bus='virtio'/gt;
+  lt;target dev='vdd' bus='virtio'/gt;
 lt;/diskgt;
 lt;disk type='file' device='disk'gt;
   lt;driver name='qemu' type='qcow2'/gt;
@@ -1656,7 +1656,7 @@
   lt;backingStore/gt;
 lt;/backingStoregt;
   lt;/backingStoregt;
-  lt;target dev='vda' bus='virtio'/gt;
+  lt;target dev='vde' bus='virtio'/gt;
 lt;/diskgt;
   lt;/devicesgt;
   .../pre
-- 
1.7.1

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


[libvirt] [PATCH v2] Perform disk config validity checking for attach-device config

2014-08-07 Thread John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1078126

Using 'virsh attach-device --config' (or --persistent) to attach a
file backed lun device will succeed; however, subsequent domain restarts
will result in failure because the configuration of a file backed lun
is not supported.

Although allowing 'illegal configurations' is something that can be
allowed, it may not be practical in this case. Generally, when attaching
a device to a domain means the domain must be running. A way around
this is using the --config (or --persistent) option. When an attach
is done to a running domain, a temporary configuration is modified
first followed by the live update. The live update will make a number
of disk validity checks when building the qemu command to attach the
disk. If any fail, then change is rejected.

Rather than allow a potentially illegal combination, adjust the code
in the configuration path to make the same checks as the running path
will make with respect to disk validity checks. This way we avoid
having the potential for some subsequent start/reboot to fail because
an illegal combination was allowed.

NB: The live path still checks the configuration since it is possible
to just do --live guest modification...

Signed-off-by: John Ferlan jfer...@redhat.com
---

Changes since V1:
http://www.redhat.com/archives/libvir-list/2014-August/msg00045.html

Based on #virt IRC discussion this morning 
- move the qemu_caps checking to only occur during the live check
- slightly change the name of the called routine

 src/qemu/qemu_command.c | 127 +++-
 src/qemu/qemu_command.h |   2 +
 src/qemu/qemu_driver.c  |   2 +
 3 files changed, 76 insertions(+), 55 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 033a5a8..c1791d9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3230,6 +3230,73 @@ qemuGetDriveSourceString(virStorageSourcePtr src,
 }
 
 
+/* Perform disk definition config validity checks */
+int
+qemuBuildCheckDiskConfig(virDomainDiskDefPtr disk)
+{
+if (virDiskNameToIndex(disk-dst)  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unsupported disk type '%s'), disk-dst);
+goto error;
+}
+
+if (disk-wwn) {
+if ((disk-bus != VIR_DOMAIN_DISK_BUS_IDE) 
+(disk-bus != VIR_DOMAIN_DISK_BUS_SCSI)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Only ide and scsi disk support wwn));
+goto error;
+}
+}
+
+if ((disk-vendor || disk-product) 
+disk-bus != VIR_DOMAIN_DISK_BUS_SCSI) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Only scsi disk supports vendor and product));
+goto error;
+}
+
+if (disk-device == VIR_DOMAIN_DISK_DEVICE_LUN) {
+/* make sure that both the bus supports type='lun' (SG_IO). */
+if (disk-bus != VIR_DOMAIN_DISK_BUS_VIRTIO 
+disk-bus != VIR_DOMAIN_DISK_BUS_SCSI) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(disk device='lun' is not supported for 
bus='%s'),
+   virDomainDiskQEMUBusTypeToString(disk-bus));
+goto error;
+}
+if (disk-src-type == VIR_STORAGE_TYPE_NETWORK) {
+if (disk-src-protocol != VIR_STORAGE_NET_PROTOCOL_ISCSI) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(disk device='lun' is not supported 
+ for protocol='%s'),
+   
virStorageNetProtocolTypeToString(disk-src-protocol));
+goto error;
+}
+} else if (!virDomainDiskSourceIsBlockType(disk)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(disk device='lun' is only valid for block 
+ type disk source));
+goto error;
+}
+if (disk-wwn) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Setting wwn is not supported for lun device));
+goto error;
+}
+if (disk-vendor || disk-product) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(Setting vendor or product is not supported 
+ for lun device));
+goto error;
+}
+}
+return 0;
+ error:
+return -1;
+}
+
+
 char *
 qemuBuildDriveStr(virConnectPtr conn,
   virDomainDiskDefPtr disk,
@@ -3616,68 +3683,18 @@ qemuBuildDriveDevStr(virDomainDefPtr def,
 {
 virBuffer opt = VIR_BUFFER_INITIALIZER;
 const char *bus = virDomainDiskQEMUBusTypeToString(disk-bus);
-int idx = virDiskNameToIndex(disk-dst);
 int controllerModel;
 
-if (idx  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unsupported 

[libvirt] [PATCH] virsh: clean up attach-interface paragraph in man page

2014-08-07 Thread Laine Stump
This makes the paragaph about attach-interface more descriptive and
correct, adding in a few bits of information that were previously
missing, e.g. --script is only allowed for bridge interfaces of Xen
domains, target name is regenerated if it starts with vnet, mac
address will be autogenerated if not specified.

(I did this in response to an email asking why a script couldn't be
specified for a bridge interface of a qemu domain, and why an
interface of type='ethernet' couldn't be created with
attach-interface)
---
 tools/virsh.pod | 36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/tools/virsh.pod b/tools/virsh.pod
index 849ae31..abb8743 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -2202,19 +2202,29 @@ Likewise, I--shareable is an alias for I--mode 
shareable.
 [I--target target] [I--mac mac] [I--script script] [I--model model]
 [I--config] [I--inbound average,peak,burst] [I--outbound 
average,peak,burst]
 
-Attach a new network interface to the domain.  Itype can be either Inetwork
-to indicate a physical network device or Ibridge to indicate a bridge to a
-device.  Isource indicates the source device.  Itarget allows to indicate
-the target device in the guest. Names starting with 'vnet' are considered as
-auto-generated an hence blanked out.  Imac allows to specify the MAC address
-of the network interface.  Iscript allows to specify a path to a script
-handling a bridge instead of the default one.  Imodel allows to specify the
-model type.  Iinbound and Ioutbound control the bandwidth of the interface.
-Ipeak and Iburst are optional, so average,peak, average,,burst and
-average are also legal. Values for Iaverage and Ipeak are
-expressed in kilobytes per second, while Iburst is expressed in kilobytes
-in a single burst at -Ipeak speed as described in the Network XML
-documentation at Lhttp://libvirt.org/formatnetwork.html#elementQoS.
+Attach a new network interface to the domain.  Itype can be either
+Inetwork to indicate connection via a libvirt virtual network or
+Ibridge to indicate connection via a bridge device on the host.
+Isource indicates the source of the connection (either the name of a
+network, or of a bridge device).  Itarget is used to specify the
+tap/macvtap device to be used to connect the domain to the
+source. Names starting with 'vnet' are considered as auto-generated
+and are blanked out/regenerated each time the interface is attached.
+Imac specifies the MAC address of the network interface; if a MAC
+address is not given, a new address will be automatically generated
+(and stored in the persistent configuration if --config is given on
+the commandline).  Iscript is used to specify a path to a custom
+script to be called while attaching to a bridge - this will be called
+instead of the default script not in addition to it; --script is valid
+only for interfaces of type Ibridge and only for Xen domains.
+Imodel specifies the network device model to be presented to the
+domain.  Iinbound and Ioutbound control the bandwidth of the
+interface.  Ipeak and Iburst are optional, so average,peak,
+average,,burst and average are also legal. Values for Iaverage
+and Ipeak are expressed in kilobytes per second, while Iburst is
+expressed in kilobytes in a single burst at -Ipeak speed as
+described in the Network XML documentation at
+Lhttp://libvirt.org/formatnetwork.html#elementQoS.
 
 If I--live is specified, affect a running domain.
 If I--config is specified, affect the next startup of a persistent domain.
-- 
1.9.3

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


Re: [libvirt] [RFC PATCH 1/5] doc: schema: Add basic documentation for the ivshmem support

2014-08-07 Thread Maxime Leroy
On Wed, Aug 6, 2014 at 11:41 AM, Wang Rui moon.wang...@huawei.com wrote:
 On 2014/8/6 0:48, Maxime Leroy wrote:
 This patch documents XML elements used for support of ivshmem
 devices.

 About ivshmem, please see the following documentation:
 http://git.qemu.org/?p=qemu.git;a=blob;f=docs/specs/ivshmem_device_spec.txt
 (Ivshmem documentation for qemu will be updated soon:
 https://lists.nongnu.org/archive/html/qemu-devel/2014-07/msg02974.html)

 In the devices section in the domain XML users may specify:

 - For ivshmem device using an ivshmem server:

  ivshmem use_server='yes' role='master'/
source file='/tmp/socket-ivshmem0'/

 I prefer to use source mode='connect' path='/tmp/socket-ivshmem0'/ .
 So when ParesXML and Format functions are needed, we can use
 virDomainChrSourceDef*(), like vmchannel device.
 What do you think about it ?

First, thanks for the review.

I was thinking of using virDomainChrSourceDef to
improve this patch.

So the format of the xml needs to be updated accordingly:

- For ivshmem device using an ivshmem server:

ivshmem type='unix'
  source mode='connect' path='/tmp/socket-ivshmem0'/
  size unit='M'32/size
  msi vectors='32' ioeventfd='on'/
/ivshmem

- For ivshmem device using directly a shared memory

ivshmem type='file'
  source path='ivshmem0'
  size unit='M'32/size
/ivshmem

Thus, 'use_server' attribute will be replaced  by 'type' attribute
(unix or file).
Are you ok with that ?

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


Re: [libvirt] [RFC PATCH 4/5] qemu: Build command line for ivshmem device

2014-08-07 Thread Maxime Leroy
On Wed, Aug 6, 2014 at 12:04 PM, Wang Rui moon.wang...@huawei.com wrote:
 On 2014/8/6 0:48, Maxime Leroy wrote:
 This patch implements support for the ivshmem device
 in QEMU.

 Example from this xml:

 ivshmem server='yes'' role='master'/

 s/'yes''/'yes'

[..]
 +virCommandAddArg(cmd, -device);
 +if (!(devstr = qemuBuildIvshmemDevStr(def, ivshmem, qemuCaps)))
 +goto error;
 +virCommandAddArg(cmd, devstr);
 +VIR_FREE(devstr);
 +
 +if (ivshmem-use_server == VIR_DOMAIN_IVSHMEM_SERVER_ENABLED) {
 +virDomainChrSourceDef source;
 +
 +source.type = VIR_DOMAIN_CHR_TYPE_UNIX;
 +source.data.nix.path = ivshmem-file;
 +source.data.nix.listen = false;
 +
 +virCommandAddArg(cmd, -chardev);

 In qemuBuildCommandLine() , -device and -chardev capabilities are checked
 before most(not all) of virCommandAddArg for devices. I think that will be
 nicer.


ok, I will update accordingly.

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


Re: [libvirt] [RFC PATCH 2/5] conf: Parse and format ivshmem device XML

2014-08-07 Thread Maxime Leroy
On Wed, Aug 6, 2014 at 11:30 AM, Wang Rui moon.wang...@huawei.com wrote:
 On 2014/8/6 0:48, Maxime Leroy wrote:
[..]
 @@ -2805,6 +2841,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
  case VIR_DOMAIN_DEVICE_NVRAM:
  case VIR_DOMAIN_DEVICE_LAST:
  case VIR_DOMAIN_DEVICE_RNG:
 +case VIR_DOMAIN_DEVICE_IVSHMEM:
  break;

 The function is good in logic. But I think it's better to keep 
 VIR_DOMAIN_DEVICE_LAST
 the last case. (Also case VIR_DOMAIN_DEVICE_RNG should be moved ahead of
 case VIR_DOMAIN_DEVICE_LAST)


Good catch ;) I will fix it.

[...]
 +/* analysis of the ivshmem devices */
 +if ((n = virXPathNodeSet(./devices/ivshmem, ctxt, nodes))  0) {
 +goto error;
 +}
 +if (n  VIR_ALLOC_N(def-ivshmems, n)  0)
 +goto error;
 +
 +node = ctxt-node;
 +for (i = 0; i  n; i++) {
 +virDomainIvshmemDefPtr ivshmem;
 +ctxt-node = nodes[i];
 +ivshmem = virDomainIvshmemDefParseXML(nodes[i], ctxt, flags);
 +if (!ivshmem)
 +goto error;
 +
 +def-ivshmems[def-nivshmems++] = ivshmem;
 +}
 +ctxt-node = node;
 +VIR_FREE(nodes);

 Here actions: node = ctxt-node; ctxt-node = nodes[i]; ctxt-node = node;
 I see other devices' xml parsing function virDomainXXXParseXML (such as 
 virDomainRNGDefParseXML).
 These actions are in the function virDomainXXXparesXML().
 So are the actions here are redundant? Or should be moved into 
 virDomainIvshmemDefParseXML.


The action is not redundant. The virDomainDefParseXML can parse multi
ivshmem devices.
It's why we loop here on the different ivshmem nodes.

In virDomainIvshmemDefParseXML, we iterate on the different nodes of
one ivshmem device
(like msi node, size node, source node).

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


Re: [libvirt] [RFC PATCH 1/5] doc: schema: Add basic documentation for the ivshmem support

2014-08-07 Thread Maxime Leroy
On Thu, Aug 7, 2014 at 12:33 PM, Martin Kletzander mklet...@redhat.com wrote:
 On Tue, Aug 05, 2014 at 06:48:01PM +0200, Maxime Leroy wrote:

 This patch documents XML elements used for support of ivshmem
 devices.


 At first, I'd like to thank you for the proposal.  There were numerous
 requests for this, but since ivshmem is not known much, it's not easy
 to get it in.  I'll get to the details later.


You welcome. ;) Thanks for the review.

[...]
 At first, we should be more generic about the name if we want other
 hypervisors to benefit from it.  The idea is that ivshmem is not
 something new that nobody else than qemu can do.  It's just a shared
 memory, every other hypervisor out there can come up with something
 similar to this, so we don't want this to be called ivshmem.  One more
 reason for that is that it doesn't just share memory between VMs, but
 between host - guest too.  Something like a 'shmem' should be fine,
 I guess.


I agree with you, shmem is a better name for ivshmem.

In such a case, should ivshmem be renamed in QEMU ?

This would break compatibility with older versions of QEMU.

If we change ivshmem name in QEMU, we need to manage this case in libvirt.

So, I am not sure about this point.

 I prolonged the paragraph to stress out this is not qemu-only feature
 (or might not be in the future) and we should be prepared for that.
 Because of that, we should be more generic about more things than just
 the name.

 Another thing that bothers me (and bothered me with earlier
 ivshmem-related proposals as well) is that role='(master|peer)' thing.
 That thing does not mean squat for qemu and should be removed
 completely.  Looking at the code the only thing that role=peer
 (non-default, by the way) does is that it disables migration...
 That's it.  That's another sign of the ivshmem code maturity inside
 QEMU that we should keep in mind when designing the XML schema.



Ok. I added this role to be coherent with the initial proposals.

I agree with you, we should wait that live migration is properly
supported in ivshmem QEMU before adding any options related to that in
libvirt.

So I will remove this role to avoid adding confusions.



 Note: the ivshmem server needs to be launched before
   creating the VM. It's not done by libvirt.


 This is a good temporary workaround, but keep in mind that libvirt
 works remotely as well and for remote machines libvirt should be able
 to do everything for you to be able to run the machine if necessary.
 So even if it might not start the server now, it should in the future.
 That should be at least differentiable by some parameter (maybe you do
 it somewhere in the code somehow, I haven't got into that).


The new version of ivshmem server has not been accepted yet in QEMU.
I think it's too early to have an option to launch an ivshmem server or not.

I will prefer to focus on integrating these patches in libvirt first,
before adding a new feature to launch an ivhsmem server.

Are you ok with that ?

 - For ivshmem device not using an ivshmem server:

 ivshmem use_server='no' role='peer'/
   source file='ivshmem1'/
   size unit='M'32/size
 /ivshmem

 Note: the ivshmem shm needs to be created before
   creating the VM. It's not done by libvirt.


 Isn't it done by qemu automatically?  If it's not, the same as for the
 ivshmem server applies.

Just checked the QEMU code, QEMU creates the file if it doesn't exist yet.
So my mistake ;)

 I had one idea to deal with most of the problems (but adding a lot of
 code); let me outline that.  From the global POV, we want something
 that will fully work remotely, we want to be able to start it, stop
 it, assign it to domains, etc.  We might even migrate it in the
 future, but that's another storyline.  It must be generic enough, as
 it can change a lot in the future.  And so on.  One way out of this
 mess is to have yet another driver, let's call it shmem driver.  That
 driver would have APIs to define, undefine, ..., start and stop shared
 memory regions.  Those would have their own XML, and domain XML would
 only have a device shmem name='asdf_mem'/ or shmem uuid='...'/
 that would mean the domain will be started with a shared memory
 region defined in the shmem driver.  That way it could be shared even
 between hypervisors.

It seems a nice idea to have a more generic way to share memory
between guests or host.
When can you share a spec or a RFC patch about it?

 At first it seemed like an unreasonable solution, but the more I think
 about it the more I like it.  It's not a requirement to get your
 patches it, though, I just wanted to share this in case you (or anyone
 else) find it compelling enough to try it.

I will keep focusing about ivshmem support as QEMU is supporting it for now.
I will be on holiday next week. Based on the the comments, I will send
a new version after my holidays.


Maxime

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


Re: [libvirt] [PATCH] docs: use unique dev names in disk examples

2014-08-07 Thread Martin Kletzander

On Thu, Aug 07, 2014 at 08:38:11AM -0600, Eric Blake wrote:

Jiri Moskovcak reported on IRC that the documentation on valid
disk was confusing because it didn't have unique dev='...'
entries.

* docs/formatdomain.html.in: Use unique names.

Signed-off-by: Eric Blake ebl...@redhat.com
---
docs/formatdomain.html.in |   26 +-
1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8950959..08f31c4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in

[...]

@@ -1601,12 +1601,12 @@
  lt;source dev='/dev/sda'/gt;
  lt;geometry cyls='16383' heads='16' secs='63' trans='lba'/gt;
  lt;blockio logical_block_size='512' physical_block_size='4096'/gt;
-  lt;target dev='hda' bus='ide'/gt;
+  lt;target dev='sdb' bus='ide'/gt;


This one should start with hd, it's IDE.  Or the bus should be
changed.


lt;/diskgt;
lt;disk type='volume' device='disk'gt;
  lt;driver name='qemu' type='raw'/gt;
  lt;source pool='blk-pool0' volume='blk-pool0-vol0'/gt;
-  lt;target dev='hda' bus='ide'/gt;
+  lt;target dev='sdc' bus='ide'/gt;


The same applies here.


lt;/diskgt;
lt;disk type='network' device='disk'gt;
  lt;driver name='qemu' type='raw'/gt;
@@ -1626,7 +1626,7 @@
  lt;auth username='myuser'gt;
lt;secret type='iscsi' usage='libvirtiscsi'/gt;
  lt;/authgt;
-  lt;target dev='sda' bus='scsi'/gt;
+  lt;target dev='vdb' bus='scsi'/gt;


This one should start with sd, it's SCSI.

Rest looks fine, ACK if you match the dev/bus in those three mentioned
places.

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] docs: use unique dev names in disk examples

2014-08-07 Thread Laine Stump
On 08/07/2014 10:38 AM, Eric Blake wrote:
 Jiri Moskovcak reported on IRC that the documentation on valid
 disk was confusing because it didn't have unique dev='...'
 entries.

 * docs/formatdomain.html.in: Use unique names.

ACK in case you didn't treat it as trivial.

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


Re: [libvirt] [PATCH] virsh: clean up attach-interface paragraph in man page

2014-08-07 Thread Martin Kletzander

On Thu, Aug 07, 2014 at 10:55:40AM -0400, Laine Stump wrote:

This makes the paragaph about attach-interface more descriptive and
correct, adding in a few bits of information that were previously
missing, e.g. --script is only allowed for bridge interfaces of Xen
domains, target name is regenerated if it starts with vnet, mac
address will be autogenerated if not specified.

(I did this in response to an email asking why a script couldn't be
specified for a bridge interface of a qemu domain, and why an
interface of type='ethernet' couldn't be created with
attach-interface)
---
tools/virsh.pod | 36 +++-
1 file changed, 23 insertions(+), 13 deletions(-)



ACK,

Martin


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

Re: [libvirt] virsh migrate: sometimes command line cannot exit until manually press ENTER key

2014-08-07 Thread Shivaprasad bhat
On Thu, Aug 7, 2014 at 11:02 AM, Chun Yan Liu cy...@suse.com wrote:
 Hi, List,

 Do you meet the same problem? Host is kvm, doing: (e.g.)
 #virsh migrate sles11 qemu+ssh://147.2.207.55/system --live --unsafe
 password:
 Sometimes, VM is already running on the target host and disappears
 from source host, but the command line still hangs there, if pressing
 ENTER, it will exit.

 I debugged the code, but found the result is weird. The code hangs at
 tools/virsh-domain.c - cmdMigrate -vshWatchJob-poll():
 poll() is trying to select pipe_fd, which is used to receive message from
 doMigrate thread. In debugging, found that doMigrate finishes and at
 the end it  does call safewrite() to write the retval ('0' or '1') to pipe_fd,
 and the write is completed. But cmdMigrate poll() cannot get the event.
 Then after pressing ENTER key, poll() can get the event and select
 pipe_fd, then command line can exit.

 Any ideas about the possible reason?

It is because, the authentication thread is independently waiting for the
password on virsh. I see that the virWatchJob interferes with authentication
thread and the password is never taken successfully. The virWatchJob
probably needs to wait till the authentication thread completes taking the
password after which it should start watching the job. Moreover, I see
that --p2p
migration doesnt work at all when auto login is not configured.


 Thanks,
 Chunyan


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

Thanks,
Shiva

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


[libvirt] Lifecycle events during reboot for KVM and Xen

2014-08-07 Thread Thomas Bechtold
Hi,

during debugging a problem[1] of Openstack Nova I recognized the following:

Doing a reboot (from inside of the VM with reboot command) on a kvm VM
doesn't send any lifecycle events (events debugged with [2]).
Doing the same thing with a xen VM leads to 2 events: First a
VIR_DOMAIN_EVENT_STOPPED and then a VIR_DOMAIN_EVENT_STARTED event.
The problem here is that for the xen case it doesn't seem to be possible
to recognize that a reboot is ongoing. For that reason the OpenStack
Nova component just forces the domain to stop after receiving the
VIR_DOMAIN_EVENT_STOPPED event.

Is it expected that the 2 drivers send different events for the same
action or a bug in qemu/xen/libvirt?

Cheers,

Tom


[1] https://bugs.launchpad.net/nova/+bug/1293480
[2] https://gist.github.com/toabctl/53f26989ad7634a3168b

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


Re: [libvirt] [libvirt-glib] [PATCH 3/4] GVirDomainSnapshot: Add _set_config

2014-08-07 Thread Himanshu Sharma
You have any idea how I can clone VM of ESXi from libvirt?


-Original Message-
From: libvir-list-boun...@redhat.com [mailto:libvir-list-boun...@redhat.com] On 
Behalf Of Christophe Fergeau
Sent: 05 August 2014 18:26
To: m...@baedert.org
Cc: libvir-list@redhat.com
Subject: Re: [libvirt] [libvirt-glib] [PATCH 3/4] GVirDomainSnapshot: Add 
_set_config

On Sat, Aug 02, 2014 at 10:41:48AM +0200, m...@baedert.org wrote:
 From: Timm Bäder m...@baedert.org
 
 ... which is basically analogous to gvir_domain_set_config
 ---
  libvirt-gobject/libvirt-gobject-domain-snapshot.c | 58 
 +++  libvirt-gobject/libvirt-gobject-domain-snapshot.h |  
 5 ++
  libvirt-gobject/libvirt-gobject.sym   |  1 +
  3 files changed, 64 insertions(+)
 
 diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c 
 b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
 index 497288f..2c81882 100644
 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
 +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
 @@ -297,3 +297,61 @@ gboolean 
 gvir_domain_snapshot_revert_to(GVirDomainSnapshot *snapshot,
  
  return TRUE;
  }
 +
 +
 +
 +/**
 + * gvir_domain_snapshot_set_config:
 + * @snapshot: The domain snapshot
 + * @conf: The new config object
 + * @error: (allow-none): Place-holder for error or NULL
 + *
 + * Updates the given snapshot's configuration according to the
 + * given GVirConfigDomainSnapshot.
 + *
 + * Returns: TRUE if no error was reported, FALSE otherwise.
 + */
 +gboolean gvir_domain_snapshot_set_config(GVirDomainSnapshot *snapshot,
 + GVirConfigDomainSnapshot *conf,
 + GError **error) {
 +gchar *xml;
 +virConnectPtr conn;
 +virDomainSnapshotPtr handle;
 +virDomainPtr domain;
 +GVirDomainSnapshotPrivate *priv;
 +
 +g_return_val_if_fail(GVIR_IS_DOMAIN_SNAPSHOT(snapshot), FALSE);
 +g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_SNAPSHOT(conf), FALSE);
 +g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
 +
 +priv = snapshot-priv;
 +handle = priv-handle;
 +domain = virDomainSnapshotGetDomain(handle);
 +
 +
 +if ((conn = virDomainSnapshotGetConnect(priv-handle)) == NULL) {
 +gvir_set_error_literal(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
 +   0,
 +   Failed to get domain connection);
 +return FALSE;
 +}
 +
 +
 +xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf));
 +
 +handle = virDomainSnapshotCreateXML(domain,
 +xml,
 +VIR_DOMAIN_SNAPSHOT_CREATE_REDEFINE);
 +free(xml);

g_free here.

 +
 +if (handle == NULL) {
 +gvir_set_error(error, GVIR_DOMAIN_SNAPSHOT_ERROR,
 +   0,
 +   Failed to create Snapshot `%s' from XML 
 + definition,

snapshot could have a lower case here.

I'm not exactly clear on what this method will be doing according to your 0/4. 
If it creates a new snapshot rather than modifying an existing one, maybe the 
name should be different/this should not be wrapped?

Christophe



DISCLAIMER:
---
The contents of this e-mail and any attachment(s) are confidential and
intended
for the named recipient(s) only. 
It shall not attach any liability on the originator or NEC or its
affiliates. Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the
opinions of NEC or its affiliates. 
Any form of reproduction, dissemination, copying, disclosure, modification,
distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is
strictly prohibited. If you have 
received this email in error please delete it and notify the sender
immediately. .
---

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


Re: [libvirt] Help Required

2014-08-07 Thread Eric Blake
On 08/07/2014 12:37 AM, ahmad jan wrote:
 Respected Sir
 i am using libvirt-1.2.6 API and facing the following error please guide
 
 libvirtd: /usr/local/lib/libvirt.so.0: version `LIBVIRT_PRIVATE_1.2.6' not 
 found (required by libvirtd)

Usually, this is a sign that you have mixed self-built binaries with
distro binaries, and the two have different notions of where to look for
auxiliary files.  If you are going to self-build, it's easiest to use
the same ./configure options as your distro (the './autogen.sh --system'
trick helps when doing this from git), but it is also possible if you
are very careful to make sure that your self-built locations are found
first (perhaps by playing with LD_LIBRARY_PATH and friends).

-- 
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/2] blockjob: fix use-after-free in blockcopy

2014-08-07 Thread Eric Blake
On 08/07/2014 01:58 AM, Peter Krempa wrote:
 On 08/06/14 23:12, Eric Blake wrote:
 Commit febf84c2 tried to delay in-memory modification of the actual
 domain disk structure until after the qemu event was received.
 However, I missed that the code for block pivot had been temporarily
 setting disk-src = disk-mirror prior to the qemu command, in order
 to label the backing chain of a reused external blockcopy disk;
 and calls into qemu while still in that state before finally undoing
 things at the cleanup label.  Since the qemu event handler then does:
  virStorageSourceFree(disk-src);
  disk-src = disk-mirror;
 we have the sad race that a fast enough qemu event can cause a leak of
 the original disk-src, as well as a use-after-free of the disk-mirror
 contents, bad enough to crash libvirtd in some of my test runs, even
 though the common case of the qemu event being much later won't trip
 the race.



 -if (qemuDomainDetermineDiskChain(driver, vm, disk, false)  0)
 -goto cleanup;
 +if (qemuDomainDetermineDiskChain(driver, vm, disk, false)  0)
 +goto cleanup;


If we go to cleanup here...

 -if (disk-mirror-format  disk-mirror-format != 
 VIR_STORAGE_FILE_RAW 
 -(virDomainLockDiskAttach(driver-lockManager, cfg-uri, vm, disk)  
 0 ||
 - qemuSetupDiskCgroup(vm, disk)  0 ||
 - virSecurityManagerSetDiskLabel(driver-securityManager, vm-def, 
 disk)  0))
 -goto cleanup;
 +if (disk-mirror-format 
 +disk-mirror-format != VIR_STORAGE_FILE_RAW 
 +(virDomainLockDiskAttach(driver-lockManager, cfg-uri, vm,
 + disk)  0 ||
 + qemuSetupDiskCgroup(vm, disk)  0 ||
 + virSecurityManagerSetDiskLabel(driver-securityManager, 
 vm-def,
 +disk)  0))
 +goto cleanup;
 +
 +disk-src = oldsrc;
 +oldsrc = NULL;

...then we miss the restore of disk-src here...

 +}

  /* Attempt the pivot.  Record the attempt now, to prevent duplicate
   * attempts; but the actual disk change will be made when emitting

 
 In the cleanup section there's the original place where oldsrc was
 returned back to disk-src. That would now be dead code.

...so the cleanup label is not dead code.

 
 ACK with that part removed.

Is the patch okay as-is, with my explanation?

-- 
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] Error

2014-08-07 Thread Eric Blake
On 08/06/2014 08:53 PM, ahmad jan wrote:
 I am using Libvirt-1.0.0 on ubuntu 14.02 LTS and found the following error
 
 checking linux/if_bridge.h usability... no
 checking linux/if_bridge.h presence... yes
 configure: WARNING: linux/if_bridge.h: present but cannot be compiled

if_bridge.h has had a hairy history.  The kernel developers have done a
lousy job, and we have had to patch our configure.ac no less than three
times to work around their changes.

Make sure you have at least commits c308a9a and 1bf661c (both from
1.0.2) backported to your build environment.

But if you are going to self-build, why not just build 1.2.7?  Libvirt
remains backward-compatible, so the newer build should work just fine in
place of the older 1.0.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] [PATCH] docs: use unique dev names in disk examples

2014-08-07 Thread Eric Blake
On 08/07/2014 09:35 AM, Martin Kletzander wrote:
 On Thu, Aug 07, 2014 at 08:38:11AM -0600, Eric Blake wrote:
 Jiri Moskovcak reported on IRC that the documentation on valid
 disk was confusing because it didn't have unique dev='...'
 entries.

 * docs/formatdomain.html.in: Use unique names.


 -  lt;target dev='hda' bus='ide'/gt;
 +  lt;target dev='sdb' bus='ide'/gt;
 
 This one should start with hd, it's IDE.  Or the bus should be
 changed.

Good catch.

 Rest looks fine, ACK if you match the dev/bus in those three mentioned
 places.

Fixed, and pushed.

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



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

[libvirt] File permissions on VNC unix sockets

2014-08-07 Thread Landon Gilbert-Bland
I am using kvm libvirt/qemu, and am trying to get VNC working with unix
sockets. I'm using the following in my XML:

graphics type='vnc' socket='/tmp/kvmtest'/

This works, it creates the unix socket and I can use it for VNC. But it
creates the socket with 755 permissions, and owned by libvirt-qemu:kvm.
Ideally, I would like it to be 770 root:libvirtd, but could also work
with 775 libvirt-qemu:kvm.

Basically, I would like the group to be read/write/execute, so that
anyone in this group can use virt-manager (or whatever) to get into the
vm with vnc. I haven't found a way to change this in the settins. It
doesn't seem to be honoring the unix socket settings in
/etc/libvirt/libvirdd.conf (it looks like those are only for
libvirt-sock and libvirt-sock-ro), and I haven't been able to find any
documentation about changing these permissions in the XML.

I can manually chmod/chown the socket after it is created (manually or
with a cron), but that is far from an ideal solution. I don't suppose
anyone has run across a configuration option for this that I have missed?

I have only tested this in ubuntu 14.01 and debian sid, for what it's worth.

Thanks,
--landon

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


Re: [libvirt] [PATCH v3 1/3] domain_conf: Common routine to handle network storage host xml def

2014-08-07 Thread Eric Blake
On 08/05/2014 02:09 PM, John Ferlan wrote:
 In preparation for hostdev support for iSCSI and a virStorageNetHostDefPtr,
 split out the network disk storage parsing of the 'host' element into a
 separate routine.
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/conf/domain_conf.c | 137 
 +++--
  1 file changed, 76 insertions(+), 61 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] File permissions on VNC unix sockets

2014-08-07 Thread Landon Gilbert-Bland
Erp! Meant to send this to libvirt-users. Sorry about the noise, you can
ignore this.

--landon

On 08/07/2014 11:19 AM, Landon Gilbert-Bland wrote:
 I am using kvm libvirt/qemu, and am trying to get VNC working with unix
 sockets. I'm using the following in my XML:
 
 graphics type='vnc' socket='/tmp/kvmtest'/
 
 This works, it creates the unix socket and I can use it for VNC. But it
 creates the socket with 755 permissions, and owned by libvirt-qemu:kvm.
 Ideally, I would like it to be 770 root:libvirtd, but could also work
 with 775 libvirt-qemu:kvm.
 
 Basically, I would like the group to be read/write/execute, so that
 anyone in this group can use virt-manager (or whatever) to get into the
 vm with vnc. I haven't found a way to change this in the settins. It
 doesn't seem to be honoring the unix socket settings in
 /etc/libvirt/libvirdd.conf (it looks like those are only for
 libvirt-sock and libvirt-sock-ro), and I haven't been able to find any
 documentation about changing these permissions in the XML.
 
 I can manually chmod/chown the socket after it is created (manually or
 with a cron), but that is far from an ideal solution. I don't suppose
 anyone has run across a configuration option for this that I have missed?
 
 I have only tested this in ubuntu 14.01 and debian sid, for what it's worth.
 
 Thanks,
 --landon
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list
 

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


Re: [libvirt] [PATCH v4 2/3] hostdev: Add iSCSI hostdev XML

2014-08-07 Thread Eric Blake
On 08/05/2014 05:24 PM, John Ferlan wrote:
 Introduce a new structure to handle an iSCSI host device based on the
 existing virDomainHostdevSubsysSCSI by adding a protocol='iscsi' to
 the source/ element.  The hostdev structure mimics the existing
 disk/ element for an iSCSI device (network) device. New XML is:
 
   hostdev mode='subsystem' type='scsi' managed='yes'
 source protocol='iscsi' name='iqn.1992-01.com.example'
   host name='example.org' port='3260'/
   auth username='myname'
 secret type='iscsi' usage='mycluster_myname'/
   /auth
 /source
 address type='drive' controller='0' bus='0' target='2' unit='5'/
   /hostdev
 
 The controller element will mimic the existing scsi_host code insomuch
 as when 'lsi' and 'virtio-scsi' are used.

Might be worth mentioning that protocol='adapter' was added as an
optional marker of the existing use.

 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
 Changes since v3:
   * Rework RNG to match comments from review 8/8
   * Move the auth inside the source
   * Modify the tests and html doc to match where the auth is found
 


 +++ b/src/conf/domain_conf.c
 @@ -597,6 +597,11 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend,
vfio,
xen)
  
 +VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol,
 +  VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST,
 +  adapter,
 +  iscsi)

So 0 == adapter...

 +static int
  virDomainHostdevSubsysSCSIDefParseXML(xmlNodePtr sourcenode,
virDomainHostdevSubsysSCSIPtr scsisrc)
  {
 -return virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);
 +char *protocol = NULL;
 +int ret = -1;
 +
 +if ((protocol = virXMLPropString(sourcenode, protocol))) {
 +scsisrc-protocol =
 +virDomainHostdevSubsysSCSIProtocolTypeFromString(protocol);
 +if (scsisrc-protocol  0) {
 +virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
 +   _(Unknown SCSI subsystem protocol '%s'),
 +   protocol);
 +goto cleanup;
 +}
 +}
 +
 +if (scsisrc-protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
 +ret = virDomainHostdevSubsysSCSIiSCSIDefParseXML(sourcenode, 
 scsisrc);
 +else
 +ret = virDomainHostdevSubsysSCSIHostDefParseXML(sourcenode, scsisrc);

so whether the user omitted protocol or specified it as adapter, they
get the old style parse...

 -if (def-missing 
 -!(flags  VIR_DOMAIN_XML_INACTIVE))
 -virBufferAddLit(buf,  missing='yes');
 +if (def-source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI 
 +scsisrc-protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
 +const char *protocol =
 +
 virDomainHostdevSubsysSCSIProtocolTypeToString(scsisrc-protocol);

...but here, you don't output the protocol.  I can live with that (the
alternative would be to always output the protocol, whether or not it
was provided on input, and then touch up existing tests to reflect the
new output; but the end result is the same).

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 v3 3/3] qemu: Remove extraneous space in function prototypes

2014-08-07 Thread Eric Blake
On 08/05/2014 02:09 PM, John Ferlan wrote:
 During review of the iSCSI hostdev series, eblake noted that the
 prototypes shouldn't have the extranenous space between the * and
 the function name:
 
 http://www.redhat.com/archives/libvir-list/2014-July/msg01227.html
 
 Since it was more invasive than 1 or 2 lines - I said I'd send a
 patch covering this once committed.
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/qemu/qemu_capabilities.h |   2 +-
  src/qemu/qemu_command.h  | 136 
 +--
  src/qemu/qemu_conf.h |   2 +-
  3 files changed, 70 insertions(+), 70 deletions(-)

ACK.  Mechanical, and nice to do it as a separate patch.

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



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

[libvirt] [PATCH 01/24] src/xenxs: Refactor code parsing memory config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMMem(virConfPtr conf,.);
which parses memory config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 83 +-
 1 file changed, 45 insertions(+), 38 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 4461654..443e6da 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -40,11 +40,9 @@
 #include virstoragefile.h
 #include virstring.h
 
-/* Convenience method to grab a long int from the config file object */
-static int xenXMConfigGetBool(virConfPtr conf,
-  const char *name,
-  int *value,
-  int def)
+/* Convenience method to grab a int from the config file object */
+static int
+xenXMConfigGetBool(virConfPtr conf, const char *name, int *value, int def)
 {
 virConfValuePtr val;
 
@@ -67,11 +65,10 @@ static int xenXMConfigGetBool(virConfPtr conf,
 }
 
 
-/* Convenience method to grab a int from the config file object */
-static int xenXMConfigGetULong(virConfPtr conf,
-   const char *name,
-   unsigned long *value,
-   unsigned long def)
+/* Convenience method to grab a long int from the config file object */
+static int
+xenXMConfigGetULong(virConfPtr conf, const char *name, unsigned long *value,
+unsigned long def)
 {
 virConfValuePtr val;
 
@@ -99,10 +96,9 @@ static int xenXMConfigGetULong(virConfPtr conf,
 
 
 /* Convenience method to grab a int from the config file object */
-static int xenXMConfigGetULongLong(virConfPtr conf,
-   const char *name,
-   unsigned long long *value,
-   unsigned long long def)
+static int
+xenXMConfigGetULongLong(virConfPtr conf, const char *name,
+unsigned long long *value, unsigned long long def)
 {
 virConfValuePtr val;
 
@@ -130,10 +126,9 @@ static int xenXMConfigGetULongLong(virConfPtr conf,
 
 
 /* Convenience method to grab a string from the config file object */
-static int xenXMConfigGetString(virConfPtr conf,
-const char *name,
-const char **value,
-const char *def)
+static int
+xenXMConfigGetString(virConfPtr conf, const char *name, const char **value,
+ const char *def)
 {
 virConfValuePtr val;
 
@@ -155,10 +150,10 @@ static int xenXMConfigGetString(virConfPtr conf,
 return 0;
 }
 
-static int xenXMConfigCopyStringInternal(virConfPtr conf,
- const char *name,
- char **value,
- int allowMissing)
+
+static int
+xenXMConfigCopyStringInternal(virConfPtr conf, const char *name, char **value,
+  int allowMissing)
 {
 virConfValuePtr val;
 
@@ -188,15 +183,16 @@ static int xenXMConfigCopyStringInternal(virConfPtr conf,
 }
 
 
-static int xenXMConfigCopyString(virConfPtr conf,
- const char *name,
- char **value) {
+static int
+xenXMConfigCopyString(virConfPtr conf, const char *name, char **value)
+{
 return xenXMConfigCopyStringInternal(conf, name, value, 0);
 }
 
-static int xenXMConfigCopyStringOpt(virConfPtr conf,
-const char *name,
-char **value) {
+
+static int
+xenXMConfigCopyStringOpt(virConfPtr conf, const char *name, char **value)
+{
 return xenXMConfigCopyStringInternal(conf, name, value, 1);
 }
 
@@ -244,6 +240,25 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, 
unsigned char *uuid)
 return 0;
 }
 
+
+static int
+xenParseXMMem(virConfPtr conf, virDomainDefPtr def)
+{
+if (xenXMConfigGetULongLong(conf, memory, def-mem.cur_balloon,
+MIN_XEN_GUEST_SIZE * 2)  0)
+return -1;
+
+if (xenXMConfigGetULongLong(conf, maxmem, def-mem.max_balloon,
+def-mem.cur_balloon)  0)
+return -1;
+
+def-mem.cur_balloon *= 1024;
+def-mem.max_balloon *= 1024;
+
+return 0;
+}
+
+
 #define MAX_VFB 1024
 /*
  * Turn a config record into a lump of XML describing the
@@ -251,7 +266,7 @@ xenXMConfigGetUUID(virConfPtr conf, const char *name, 
unsigned char *uuid)
  */
 virDomainDefPtr
 xenParseXM(virConfPtr conf, int xendConfigVersion,
-   virCapsPtr caps)
+   virCapsPtr caps)
 {
 const char *str;
 int hvm = 0;
@@ -360,17 +375,9 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 }
 }
 
-if (xenXMConfigGetULongLong(conf, memory, def-mem.cur_balloon,
-

[libvirt] [PATCH 02/24] src/xenxs: Refactor code parsing virtual time config

2014-08-07 Thread Kiarie Kahurani
introduce function
xenParseXMTimeOffset(virConfPtr conf,...);
which parses time offset config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 71 +-
 1 file changed, 43 insertions(+), 28 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 443e6da..0e0cf90 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -259,7 +259,48 @@ xenParseXMMem(virConfPtr conf, virDomainDefPtr def)
 }
 
 
+static int
+xenParseXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
+ int xendConfigVersion)
+{
+int vmlocaltime;
+
+if (xenXMConfigGetBool(conf, localtime, vmlocaltime, 0)  0)
+return -1;
+
+if (STREQ(def-os.type, hvm)) {
+/* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset 
*/
+if (xendConfigVersion  XEND_CONFIG_VERSION_3_1_0) {
+if (vmlocaltime)
+def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
+else
+def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
+def-clock.data.utc_reset = true;
+} else {
+unsigned long rtc_timeoffset;
+def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
+if (xenXMConfigGetULong(conf, rtc_timeoffset, rtc_timeoffset, 
0)  0)
+return -1;
+
+def-clock.data.variable.adjustment = (int)rtc_timeoffset;
+def-clock.data.variable.basis = vmlocaltime ?
+VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
+VIR_DOMAIN_CLOCK_BASIS_UTC;
+}
+} else {
+/* PV domains do not have an emulated RTC and the offset is fixed. */
+def-clock.offset = vmlocaltime ?
+VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME :
+VIR_DOMAIN_CLOCK_OFFSET_UTC;
+def-clock.data.utc_reset = true;
+} /* !hvm */
+
+return 0;
+}
+
+
 #define MAX_VFB 1024
+
 /*
  * Turn a config record into a lump of XML describing the
  * domain, suitable for later feeding for virDomainCreateXML
@@ -279,7 +320,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 virDomainHostdevDefPtr hostdev = NULL;
 size_t i;
 const char *defaultMachine;
-int vmlocaltime = 0;
 unsigned long count;
 char *script = NULL;
 char *listenAddr = NULL;
@@ -456,34 +496,9 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 def-clock.timers[0] = timer;
 }
 }
-if (xenXMConfigGetBool(conf, localtime, vmlocaltime, 0)  0)
-goto cleanup;
 
-if (hvm) {
-/* only managed HVM domains since 3.1.0 have persistent rtc_timeoffset 
*/
-if (xendConfigVersion  XEND_CONFIG_VERSION_3_1_0) {
-if (vmlocaltime)
-def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME;
-else
-def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_UTC;
-def-clock.data.utc_reset = true;
-} else {
-unsigned long rtc_timeoffset;
-def-clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE;
-if (xenXMConfigGetULong(conf, rtc_timeoffset, rtc_timeoffset, 
0)  0)
-goto cleanup;
-def-clock.data.variable.adjustment = (int)rtc_timeoffset;
-def-clock.data.variable.basis = vmlocaltime ?
-VIR_DOMAIN_CLOCK_BASIS_LOCALTIME :
-VIR_DOMAIN_CLOCK_BASIS_UTC;
-}
-} else {
-/* PV domains do not have an emulated RTC and the offset is fixed. */
-def-clock.offset = vmlocaltime ?
-VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME :
-VIR_DOMAIN_CLOCK_OFFSET_UTC;
-def-clock.data.utc_reset = true;
-} /* !hvm */
+if (xenParseXMTimeOffset(conf, def, xendConfigVersion)  0)
+goto cleanup;
 
 if (xenXMConfigCopyStringOpt(conf, device_model, def-emulator)  0)
 goto cleanup;
-- 
1.8.4.5

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


[libvirt] [PATCH 03/24] src/xenxs: Refactor code parsing event actions

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMEventActions(virConfPtr conf,)
which parses events leading to certain actions

signed-off-by: Kiarie Kahurani davidkia...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 61 +-
 1 file changed, 37 insertions(+), 24 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 0e0cf90..ecc8f52 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -299,6 +299,42 @@ xenParseXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
 }
 
 
+static int
+xenParseXMEventsActions(virConfPtr conf, virDomainDefPtr def)
+{
+const char *str = NULL;
+
+if (xenXMConfigGetString(conf, on_poweroff, str, destroy)  0)
+return -1;
+
+if ((def-onPoweroff = virDomainLifecycleTypeFromString(str))  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected value %s for on_poweroff), str);
+return -1;
+}
+
+if (xenXMConfigGetString(conf, on_reboot, str, restart)  0)
+return -1;
+
+if ((def-onReboot = virDomainLifecycleTypeFromString(str))  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected value %s for on_reboot), str);
+return -1;
+}
+
+if (xenXMConfigGetString(conf, on_crash, str, restart)  0)
+return -1;
+
+if ((def-onCrash = virDomainLifecycleCrashTypeFromString(str))  0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected value %s for on_crash), str);
+return -1;
+}
+
+return 0;
+}
+
+
 #define MAX_VFB 1024
 
 /*
@@ -431,31 +467,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 if (str  (virBitmapParse(str, 0, def-cpumask, 4096)  0))
 goto cleanup;
 
-if (xenXMConfigGetString(conf, on_poweroff, str, destroy)  0)
+if (xenParseXMEventsActions(conf, def)  0)
 goto cleanup;
-if ((def-onPoweroff = virDomainLifecycleTypeFromString(str))  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unexpected value %s for on_poweroff), str);
-goto cleanup;
-}
-
-if (xenXMConfigGetString(conf, on_reboot, str, restart)  0)
-goto cleanup;
-if ((def-onReboot = virDomainLifecycleTypeFromString(str))  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unexpected value %s for on_reboot), str);
-goto cleanup;
-}
-
-if (xenXMConfigGetString(conf, on_crash, str, restart)  0)
-goto cleanup;
-if ((def-onCrash = virDomainLifecycleCrashTypeFromString(str))  0) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unexpected value %s for on_crash), str);
-goto cleanup;
-}
-
-
 
 if (hvm) {
 if (xenXMConfigGetBool(conf, pae, val, 0)  0)
-- 
1.8.4.5

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


[libvirt] [PATCH 06/24] src/xenxs: Refactor code parsing xm disk config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMDisk(virConfPtr conf, );
which parses xm disk config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 322 -
 1 file changed, 168 insertions(+), 154 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index e75842f..f4bb37d 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -500,136 +500,15 @@ xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr 
def)
 }
 
 
-#define MAX_VFB 1024
-
-/*
- * Turn a config record into a lump of XML describing the
- * domain, suitable for later feeding for virDomainCreateXML
- */
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
-   virCapsPtr caps)
+static int
+xenParseXMDisk(virConfPtr conf, virDomainDefPtr def,
+   int xendConfigVersion)
 {
-const char *str;
-int hvm = 0;
-int val;
-virConfValuePtr list;
-virDomainDefPtr def = NULL;
+const char *str = NULL;
 virDomainDiskDefPtr disk = NULL;
-virDomainNetDefPtr net = NULL;
-virDomainGraphicsDefPtr graphics = NULL;
-size_t i;
-const char *defaultMachine;
-char *script = NULL;
-char *listenAddr = NULL;
-
-if (VIR_ALLOC(def)  0)
-return NULL;
-
-def-virtType = VIR_DOMAIN_VIRT_XEN;
-def-id = -1;
-
-if (xenXMConfigCopyString(conf, name, def-name)  0)
-goto cleanup;
-if (xenXMConfigGetUUID(conf, uuid, def-uuid)  0)
-goto cleanup;
-
-
-if ((xenXMConfigGetString(conf, builder, str, linux) == 0) 
-STREQ(str, hvm))
-hvm = 1;
-
-if (VIR_STRDUP(def-os.type, hvm ? hvm : xen)  0)
-goto cleanup;
-
-def-os.arch =
-virCapabilitiesDefaultGuestArch(caps,
-def-os.type,
-
virDomainVirtTypeToString(def-virtType));
-if (!def-os.arch) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(no supported architecture for os type '%s'),
-   def-os.type);
-goto cleanup;
-}
-
-defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
-def-os.type,
-def-os.arch,
-
virDomainVirtTypeToString(def-virtType));
-if (defaultMachine != NULL) {
-if (VIR_STRDUP(def-os.machine, defaultMachine)  0)
-goto cleanup;
-}
-
-if (hvm) {
-const char *boot;
-if (xenXMConfigCopyString(conf, kernel, def-os.loader)  0)
-goto cleanup;
-
-if (xenXMConfigGetString(conf, boot, boot, c)  0)
-goto cleanup;
-
-for (i = 0; i  VIR_DOMAIN_BOOT_LAST  boot[i]; i++) {
-switch (*boot) {
-case 'a':
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY;
-break;
-case 'd':
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM;
-break;
-case 'n':
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_NET;
-break;
-case 'c':
-default:
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK;
-break;
-}
-def-os.nBootDevs++;
-}
-} else {
-const char *extra, *root;
-
-if (xenXMConfigCopyStringOpt(conf, bootloader, def-os.bootloader) 
 0)
-goto cleanup;
-if (xenXMConfigCopyStringOpt(conf, bootargs, 
def-os.bootloaderArgs)  0)
-goto cleanup;
-
-if (xenXMConfigCopyStringOpt(conf, kernel, def-os.kernel)  0)
-goto cleanup;
-if (xenXMConfigCopyStringOpt(conf, ramdisk, def-os.initrd)  0)
-goto cleanup;
-if (xenXMConfigGetString(conf, extra, extra, NULL)  0)
-goto cleanup;
-if (xenXMConfigGetString(conf, root, root, NULL)  0)
-goto cleanup;
-
-if (root) {
-if (virAsprintf(def-os.cmdline, root=%s %s, root, extra)  0)
-goto cleanup;
-} else {
-if (VIR_STRDUP(def-os.cmdline, extra)  0)
-goto cleanup;
-}
-}
-
-if (xenParseXMMem(conf, def)  0)
-goto cleanup;
+int hvm = STREQ(def-os.type, hvm);
+virConfValuePtr list = virConfGetValue(conf, disk);
 
-if (xenParseXMEventsActions(conf, def)  0)
-goto cleanup;
-
-if (xenParseXMCPUFeatures(conf, def)  0)
-goto cleanup;
-
-if (xenParseXMTimeOffset(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-if (xenXMConfigCopyStringOpt(conf, device_model, def-emulator)  0)
-goto cleanup;
-
-list = virConfGetValue(conf, disk);
 if (list  list-type == VIR_CONF_LIST) {
 list = list-list;
 while (list) {
@@ -641,9 +520,8 @@ 

[libvirt] [PATCH 05/24] src/xenxs: Refactor code parsing CPU features

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMCPUFeatures(virConfPtr conf,.);
which parses CPU features instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 127 +++--
 1 file changed, 74 insertions(+), 53 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 8cc892b..e75842f 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -428,6 +428,78 @@ xenParseXMPCI(virConfPtr conf, virDomainDefPtr def)
 }
 
 
+static int
+xenParseXMCPUFeatures(virConfPtr conf, virDomainDefPtr def)
+{
+unsigned long count = 0;
+const char *str = NULL;
+int val = 0;
+
+if (xenXMConfigGetULong(conf, vcpus, count, 1)  0 ||
+MAX_VIRT_CPUS  count)
+return -1;
+
+def-maxvcpus = count;
+if (xenXMConfigGetULong(conf, vcpu_avail, count, -1)  0)
+return -1;
+
+def-vcpus = MIN(count_one_bits_l(count), def-maxvcpus);
+if (xenXMConfigGetString(conf, cpus, str, NULL)  0)
+return -1;
+
+if (str  (virBitmapParse(str, 0, def-cpumask, 4096)  0))
+return -1;
+
+if (STREQ(def-os.type, hvm)) {
+if (xenXMConfigGetBool(conf, pae, val, 0)  0)
+return -1;
+
+else if (val)
+def-features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON;
+if (xenXMConfigGetBool(conf, acpi, val, 0)  0)
+return -1;
+
+else if (val)
+def-features[VIR_DOMAIN_FEATURE_ACPI] = VIR_TRISTATE_SWITCH_ON;
+if (xenXMConfigGetBool(conf, apic, val, 0)  0)
+return -1;
+
+else if (val)
+def-features[VIR_DOMAIN_FEATURE_APIC] = VIR_TRISTATE_SWITCH_ON;
+if (xenXMConfigGetBool(conf, hap, val, 0)  0)
+return -1;
+
+else if (val)
+def-features[VIR_DOMAIN_FEATURE_HAP] = VIR_TRISTATE_SWITCH_ON;
+if (xenXMConfigGetBool(conf, viridian, val, 0)  0)
+return -1;
+
+else if (val)
+def-features[VIR_DOMAIN_FEATURE_VIRIDIAN] = 
VIR_TRISTATE_SWITCH_ON;
+
+if (xenXMConfigGetBool(conf, hpet, val, -1)  0)
+return -1;
+
+else if (val != -1) {
+virDomainTimerDefPtr timer;
+
+if (VIR_ALLOC_N(def-clock.timers, 1)  0 ||
+VIR_ALLOC(timer)  0)
+return -1;
+
+timer-name = VIR_DOMAIN_TIMER_NAME_HPET;
+timer-present = val;
+timer-tickpolicy = -1;
+
+def-clock.ntimers = 1;
+def-clock.timers[0] = timer;
+}
+}
+
+return 0;
+}
+
+
 #define MAX_VFB 1024
 
 /*
@@ -448,7 +520,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 virDomainGraphicsDefPtr graphics = NULL;
 size_t i;
 const char *defaultMachine;
-unsigned long count;
 char *script = NULL;
 char *listenAddr = NULL;
 
@@ -546,61 +617,11 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 if (xenParseXMMem(conf, def)  0)
 goto cleanup;
 
-if (xenXMConfigGetULong(conf, vcpus, count, 1)  0 ||
-MAX_VIRT_CPUS  count)
-goto cleanup;
-def-maxvcpus = count;
-if (xenXMConfigGetULong(conf, vcpu_avail, count, -1)  0)
-goto cleanup;
-def-vcpus = MIN(count_one_bits_l(count), def-maxvcpus);
-
-if (xenXMConfigGetString(conf, cpus, str, NULL)  0)
-goto cleanup;
-if (str  (virBitmapParse(str, 0, def-cpumask, 4096)  0))
-goto cleanup;
-
 if (xenParseXMEventsActions(conf, def)  0)
 goto cleanup;
 
-if (hvm) {
-if (xenXMConfigGetBool(conf, pae, val, 0)  0)
-goto cleanup;
-else if (val)
-def-features[VIR_DOMAIN_FEATURE_PAE] = VIR_TRISTATE_SWITCH_ON;
-if (xenXMConfigGetBool(conf, acpi, val, 0)  0)
-goto cleanup;
-else if (val)
-def-features[VIR_DOMAIN_FEATURE_ACPI] = VIR_TRISTATE_SWITCH_ON;
-if (xenXMConfigGetBool(conf, apic, val, 0)  0)
-goto cleanup;
-else if (val)
-def-features[VIR_DOMAIN_FEATURE_APIC] = VIR_TRISTATE_SWITCH_ON;
-if (xenXMConfigGetBool(conf, hap, val, 0)  0)
-goto cleanup;
-else if (val)
-def-features[VIR_DOMAIN_FEATURE_HAP] = VIR_TRISTATE_SWITCH_ON;
-if (xenXMConfigGetBool(conf, viridian, val, 0)  0)
-goto cleanup;
-else if (val)
-def-features[VIR_DOMAIN_FEATURE_VIRIDIAN] = 
VIR_TRISTATE_SWITCH_ON;
-
-if (xenXMConfigGetBool(conf, hpet, val, -1)  0)
-goto cleanup;
-else if (val != -1) {
-virDomainTimerDefPtr timer;
-
-if (VIR_ALLOC_N(def-clock.timers, 1)  0 ||
-VIR_ALLOC(timer)  0)
-goto cleanup;
-
-timer-name = VIR_DOMAIN_TIMER_NAME_HPET;
-timer-present = val;
-timer-tickpolicy = -1;
-
-def-clock.ntimers = 1;
-

[libvirt] [PATCH 07/24] src/xenxs: Refactor code parsing Vfb config

2014-08-07 Thread Kiarie Kahurani
introduce function
 xenParseXMVfb(virConfPtr conf,..);
which parses Vfb config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 301 +++--
 1 file changed, 155 insertions(+), 146 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index f4bb37d..228e0a2 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -40,6 +40,7 @@
 #include virstoragefile.h
 #include virstring.h
 
+#define MAX_VFB 1024
 /* Convenience method to grab a int from the config file object */
 static int
 xenXMConfigGetBool(virConfPtr conf, const char *name, int *value, int def)
@@ -689,7 +690,158 @@ xenParseXMDisk(virConfPtr conf, virDomainDefPtr def,
 
 return 0;
 }
-#define MAX_VFB 1024
+
+
+static int
+xenParseXMVfb(virConfPtr conf, virDomainDefPtr def,
+  int xendConfigVersion)
+{
+int val;
+char *listenAddr = NULL;
+int hvm = STREQ(def-os.type, hvm);
+virConfValuePtr list;
+virDomainGraphicsDefPtr graphics = NULL;
+
+if (hvm || xendConfigVersion  XEND_CONFIG_VERSION_3_0_4) {
+if (xenXMConfigGetBool(conf, vnc, val, 0)  0)
+goto cleanup;
+if (val) {
+if (VIR_ALLOC(graphics)  0)
+goto cleanup;
+graphics-type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
+if (xenXMConfigGetBool(conf, vncunused, val, 1)  0)
+goto cleanup;
+graphics-data.vnc.autoport = val ? 1 : 0;
+if (!graphics-data.vnc.autoport) {
+unsigned long vncdisplay;
+if (xenXMConfigGetULong(conf, vncdisplay, vncdisplay, 0)  
0)
+goto cleanup;
+graphics-data.vnc.port = (int)vncdisplay + 5900;
+}
+
+if (xenXMConfigCopyStringOpt(conf, vnclisten, listenAddr)  0)
+goto cleanup;
+if (listenAddr 
+virDomainGraphicsListenSetAddress(graphics, 0, listenAddr,
+  -1, true)  0) {
+   goto cleanup;
+}
+
+VIR_FREE(listenAddr);
+if (xenXMConfigCopyStringOpt(conf, vncpasswd, 
graphics-data.vnc.auth.passwd)  0)
+goto cleanup;
+if (xenXMConfigCopyStringOpt(conf, keymap, 
graphics-data.vnc.keymap)  0)
+goto cleanup;
+if (VIR_ALLOC_N(def-graphics, 1)  0)
+goto cleanup;
+def-graphics[0] = graphics;
+def-ngraphics = 1;
+graphics = NULL;
+} else {
+if (xenXMConfigGetBool(conf, sdl, val, 0)  0)
+goto cleanup;
+if (val) {
+if (VIR_ALLOC(graphics)  0)
+goto cleanup;
+graphics-type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
+if (xenXMConfigCopyStringOpt(conf, display, 
graphics-data.sdl.display)  0)
+goto cleanup;
+if (xenXMConfigCopyStringOpt(conf, xauthority, 
graphics-data.sdl.xauth)  0)
+goto cleanup;
+if (VIR_ALLOC_N(def-graphics, 1)  0)
+goto cleanup;
+def-graphics[0] = graphics;
+def-ngraphics = 1;
+graphics = NULL;
+}
+}
+}
+
+if (!hvm  def-graphics == NULL) { /* New PV guests use this format */
+list = virConfGetValue(conf, vfb);
+if (list  list-type == VIR_CONF_LIST 
+list-list  list-list-type == VIR_CONF_STRING 
+list-list-str) {
+char vfb[MAX_VFB];
+char *key = vfb;
+
+if (virStrcpyStatic(vfb, list-list-str) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(VFB %s too big for destination),
+   list-list-str);
+goto cleanup;
+}
+
+if (VIR_ALLOC(graphics)  0)
+goto cleanup;
+if (strstr(key, type=sdl))
+graphics-type = VIR_DOMAIN_GRAPHICS_TYPE_SDL;
+else
+graphics-type = VIR_DOMAIN_GRAPHICS_TYPE_VNC;
+while (key) {
+char *nextkey = strchr(key, ',');
+char *end = nextkey;
+if (nextkey) {
+*end = '\0';
+nextkey++;
+}
+
+if (!strchr(key, '='))
+break;
+if (graphics-type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
+if (STRPREFIX(key, vncunused=)) {
+if (STREQ(key + 10, 1))
+graphics-data.vnc.autoport = true;
+} else if (STRPREFIX(key, vnclisten=)) {
+if (virDomainGraphicsListenSetAddress(graphics, 0, 
key+10,
+ 

[libvirt] [PATCH 08/24] src/xenxs: Refactor code parsing Char devices config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMCharDev(virConfPtr conf,.);
which parses Char devices config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 174 -
 1 file changed, 93 insertions(+), 81 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 228e0a2..628cef6 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -843,6 +843,97 @@ xenParseXMVfb(virConfPtr conf, virDomainDefPtr def,
 return -1;
 }
 
+
+static int
+xenParseXMCharDev(virConfPtr conf, virDomainDefPtr def)
+{
+const char *str;
+virConfValuePtr value = NULL;
+virDomainChrDefPtr chr = NULL;
+
+if (STREQ(def-os.type, hvm)) {
+if (xenXMConfigGetString(conf, parallel, str, NULL)  0)
+goto cleanup;
+if (str  STRNEQ(str, none) 
+!(chr = xenParseSxprChar(str, NULL)))
+goto cleanup;
+if (chr) {
+if (VIR_ALLOC_N(def-parallels, 1)  0) {
+goto cleanup;
+}
+
+chr-deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
+chr-target.port = 0;
+def-parallels[0] = chr;
+def-nparallels++;
+chr = NULL;
+}
+
+/* Try to get the list of values to support multiple serial ports */
+value = virConfGetValue(conf, serial);
+if (value  value-type == VIR_CONF_LIST) {
+int portnum = -1;
+
+value = value-list;
+while (value) {
+char *port = NULL;
+
+if ((value-type != VIR_CONF_STRING) || (value-str == NULL))
+goto cleanup;
+port = value-str;
+portnum++;
+if (STREQ(port, none)) {
+value = value-next;
+continue;
+}
+
+if (!(chr = xenParseSxprChar(port, NULL)))
+goto cleanup;
+chr-deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+chr-target.port = portnum;
+if (VIR_APPEND_ELEMENT(def-serials, def-nserials, chr)  0) {
+goto cleanup;
+}
+
+value = value-next;
+}
+} else {
+/* If domain is not using multiple serial ports we parse data old 
way */
+if (xenXMConfigGetString(conf, serial, str, NULL)  0)
+goto cleanup;
+if (str  STRNEQ(str, none) 
+!(chr = xenParseSxprChar(str, NULL)))
+goto cleanup;
+if (chr) {
+if (VIR_ALLOC_N(def-serials, 1)  0) {
+virDomainChrDefFree(chr);
+goto cleanup;
+}
+chr-deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+chr-target.port = 0;
+def-serials[0] = chr;
+def-nserials++;
+}
+}
+} else {
+if (VIR_ALLOC_N(def-consoles, 1)  0)
+goto cleanup;
+def-nconsoles = 1;
+if (!(def-consoles[0] = xenParseSxprChar(pty, NULL)))
+goto cleanup;
+def-consoles[0]-deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;
+def-consoles[0]-target.port = 0;
+def-consoles[0]-targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
+}
+
+return 0;
+
+ cleanup:
+virDomainChrDefFree(chr);
+return -1;
+}
+
+
 /*
  * Turn a config record into a lump of XML describing the
  * domain, suitable for later feeding for virDomainCreateXML
@@ -1145,87 +1236,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 if (xenParseXMVfb(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
-if (hvm) {
-virDomainChrDefPtr chr = NULL;
-
-if (xenXMConfigGetString(conf, parallel, str, NULL)  0)
-goto cleanup;
-if (str  STRNEQ(str, none) 
-!(chr = xenParseSxprChar(str, NULL)))
-goto cleanup;
-
-if (chr) {
-if (VIR_ALLOC_N(def-parallels, 1)  0) {
-virDomainChrDefFree(chr);
-goto cleanup;
-}
-chr-deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL;
-chr-target.port = 0;
-def-parallels[0] = chr;
-def-nparallels++;
-chr = NULL;
-}
-
-/* Try to get the list of values to support multiple serial ports */
-list = virConfGetValue(conf, serial);
-if (list  list-type == VIR_CONF_LIST) {
-int portnum = -1;
-
-list = list-list;
-while (list) {
-char *port = NULL;
-
-if ((list-type != VIR_CONF_STRING) || (list-str == NULL))
-goto cleanup;
-
-port = list-str;
-portnum++;
-if (STREQ(port, none)) {
-

[libvirt] [PATCH 09/24] src/xenxs: Refactor code parsing Vif config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMVif(virConfPtr conf,);
which parses Vfb config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 283 +++--
 1 file changed, 143 insertions(+), 140 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 628cef6..73efa5f 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -934,134 +934,13 @@ xenParseXMCharDev(virConfPtr conf, virDomainDefPtr def)
 }
 
 
-/*
- * Turn a config record into a lump of XML describing the
- * domain, suitable for later feeding for virDomainCreateXML
- */
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
-   virCapsPtr caps)
+static int
+xenParseXMVif(virConfPtr conf, virDomainDefPtr def)
 {
-const char *str;
-int hvm = 0;
-virConfValuePtr list;
-virDomainDefPtr def = NULL;
-virDomainDiskDefPtr disk = NULL;
-virDomainNetDefPtr net = NULL;
-size_t i;
-const char *defaultMachine;
 char *script = NULL;
+virDomainNetDefPtr net = NULL;
+virConfValuePtr list = virConfGetValue(conf, vif);
 
-if (VIR_ALLOC(def)  0)
-return NULL;
-
-def-virtType = VIR_DOMAIN_VIRT_XEN;
-def-id = -1;
-
-if (xenXMConfigCopyString(conf, name, def-name)  0)
-goto cleanup;
-if (xenXMConfigGetUUID(conf, uuid, def-uuid)  0)
-goto cleanup;
-
-
-if ((xenXMConfigGetString(conf, builder, str, linux) == 0) 
-STREQ(str, hvm))
-hvm = 1;
-
-if (VIR_STRDUP(def-os.type, hvm ? hvm : xen)  0)
-goto cleanup;
-
-def-os.arch =
-virCapabilitiesDefaultGuestArch(caps,
-def-os.type,
-
virDomainVirtTypeToString(def-virtType));
-if (!def-os.arch) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(no supported architecture for os type '%s'),
-   def-os.type);
-goto cleanup;
-}
-
-defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
-def-os.type,
-def-os.arch,
-
virDomainVirtTypeToString(def-virtType));
-if (defaultMachine != NULL) {
-if (VIR_STRDUP(def-os.machine, defaultMachine)  0)
-goto cleanup;
-}
-
-if (hvm) {
-const char *boot;
-if (xenXMConfigCopyString(conf, kernel, def-os.loader)  0)
-goto cleanup;
-
-if (xenXMConfigGetString(conf, boot, boot, c)  0)
-goto cleanup;
-
-for (i = 0; i  VIR_DOMAIN_BOOT_LAST  boot[i]; i++) {
-switch (*boot) {
-case 'a':
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_FLOPPY;
-break;
-case 'd':
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_CDROM;
-break;
-case 'n':
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_NET;
-break;
-case 'c':
-default:
-def-os.bootDevs[i] = VIR_DOMAIN_BOOT_DISK;
-break;
-}
-def-os.nBootDevs++;
-}
-} else {
-const char *extra, *root;
-
-if (xenXMConfigCopyStringOpt(conf, bootloader, def-os.bootloader) 
 0)
-goto cleanup;
-if (xenXMConfigCopyStringOpt(conf, bootargs, 
def-os.bootloaderArgs)  0)
-goto cleanup;
-
-if (xenXMConfigCopyStringOpt(conf, kernel, def-os.kernel)  0)
-goto cleanup;
-if (xenXMConfigCopyStringOpt(conf, ramdisk, def-os.initrd)  0)
-goto cleanup;
-if (xenXMConfigGetString(conf, extra, extra, NULL)  0)
-goto cleanup;
-if (xenXMConfigGetString(conf, root, root, NULL)  0)
-goto cleanup;
-
-if (root) {
-if (virAsprintf(def-os.cmdline, root=%s %s, root, extra)  0)
-goto cleanup;
-} else {
-if (VIR_STRDUP(def-os.cmdline, extra)  0)
-goto cleanup;
-}
-}
-
-if (xenParseXMMem(conf, def)  0)
-goto cleanup;
-
-if (xenParseXMEventsActions(conf, def)  0)
-goto cleanup;
-
-if (xenParseXMCPUFeatures(conf, def)  0)
-goto cleanup;
-
-if (xenParseXMTimeOffset(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-if (xenParseXMDisk(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-if (xenXMConfigCopyStringOpt(conf, device_model, def-emulator)  0)
-goto cleanup;
-
-list = virConfGetValue(conf, vif);
 if (list  list-type == VIR_CONF_LIST) {
 list = list-list;
 while (list) {
@@ -1082,7 +961,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 
 if ((list-type != VIR_CONF_STRING) || (list-str == 

[libvirt] [PATCH 10/24] src/xenxs: Refactor code parsing emulated hardware config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenParseXMEmulatedHardware(virConfPtr conf,.);
which parses emulated devices config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 82 --
 1 file changed, 48 insertions(+), 34 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 73efa5f..9eabfa4 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1085,6 +1085,52 @@ xenParseXMVif(virConfPtr conf, virDomainDefPtr def)
 VIR_FREE(script);
 return -1;
 }
+
+
+static int
+xenParseXMEmulatedDevices(virConfPtr conf, virDomainDefPtr def)
+{
+const char *str;
+
+if (STREQ(def-os.type, hvm)) {
+if (xenXMConfigGetString(conf, soundhw, str, NULL)  0)
+return -1;
+
+if (str 
+xenParseSxprSound(def, str)  0)
+return -1;
+
+if (xenXMConfigGetString(conf, usbdevice, str, NULL)  0)
+return -1;
+
+if (str 
+(STREQ(str, tablet) ||
+ STREQ(str, mouse) ||
+ STREQ(str, keyboard))) {
+virDomainInputDefPtr input;
+if (VIR_ALLOC(input)  0)
+return -1;
+
+input-bus = VIR_DOMAIN_INPUT_BUS_USB;
+if (STREQ(str, mouse))
+input-type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
+else if (STREQ(str, tablet))
+input-type = VIR_DOMAIN_INPUT_TYPE_TABLET;
+else if (STREQ(str, keyboard))
+input-type = VIR_DOMAIN_INPUT_TYPE_KBD;
+if (VIR_ALLOC_N(def-inputs, 1)  0) {
+virDomainInputDefFree(input);
+return -1;
+
+}
+def-inputs[0] = input;
+def-ninputs = 1;
+}
+}
+
+return 0;
+}
+
 /*
  * Turn a config record into a lump of XML describing the
  * domain, suitable for later feeding for virDomainCreateXML
@@ -1214,31 +1260,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 if (xenParseXMPCI(conf, def)  0)
 goto cleanup;
 
-if (hvm) {
-if (xenXMConfigGetString(conf, usbdevice, str, NULL)  0)
-goto cleanup;
-if (str 
-(STREQ(str, tablet) ||
- STREQ(str, mouse) ||
- STREQ(str, keyboard))) {
-virDomainInputDefPtr input;
-if (VIR_ALLOC(input)  0)
-goto cleanup;
-input-bus = VIR_DOMAIN_INPUT_BUS_USB;
-if (STREQ(str, mouse))
-input-type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
-else if (STREQ(str, tablet))
-input-type = VIR_DOMAIN_INPUT_TYPE_TABLET;
-else if (STREQ(str, keyboard))
-input-type = VIR_DOMAIN_INPUT_TYPE_KBD;
-if (VIR_ALLOC_N(def-inputs, 1)  0) {
-virDomainInputDefFree(input);
-goto cleanup;
-}
-def-inputs[0] = input;
-def-ninputs = 1;
-}
-}
+if (xenParseXMEmulatedDevices(conf, def)  0)
+goto cleanup;
 
 if (xenParseXMVfb(conf, def, xendConfigVersion)  0)
 goto cleanup;
@@ -1246,15 +1269,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 if (xenParseXMCharDev(conf, def)  0)
 goto cleanup;
 
-if (hvm) {
-if (xenXMConfigGetString(conf, soundhw, str, NULL)  0)
-goto cleanup;
-
-if (str 
-xenParseSxprSound(def, str)  0)
-goto cleanup;
-}
-
 return def;
 
  cleanup:
-- 
1.8.4.5

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


[libvirt] [PATCH 04/24] src/xenxs: Refactor code parsing PCI config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenParseXMPCI(virConfPtr conf, );
which parses PCI config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 185 +++--
 1 file changed, 95 insertions(+), 90 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index ecc8f52..8cc892b 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -335,6 +335,99 @@ xenParseXMEventsActions(virConfPtr conf, virDomainDefPtr 
def)
 }
 
 
+static int
+xenParseXMPCI(virConfPtr conf, virDomainDefPtr def)
+{
+virConfValuePtr list = virConfGetValue(conf, pci);
+virDomainHostdevDefPtr hostdev = NULL;
+
+if (list  list-type == VIR_CONF_LIST) {
+list = list-list;
+while (list) {
+char domain[5];
+char bus[3];
+char slot[3];
+char func[2];
+char *key, *nextkey;
+int domainID;
+int busID;
+int slotID;
+int funcID;
+
+domain[0] = bus[0] = slot[0] = func[0] = '\0';
+
+if ((list-type != VIR_CONF_STRING) || (list-str == NULL))
+goto skippci;
+/* pci=[':00:1b.0',':00:13.0'] */
+if (!(key = list-str))
+goto skippci;
+if (!(nextkey = strchr(key, ':')))
+goto skippci;
+if (virStrncpy(domain, key, (nextkey - key), sizeof(domain)) == 
NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Domain %s too big for destination), key);
+goto skippci;
+}
+
+key = nextkey + 1;
+if (!(nextkey = strchr(key, ':')))
+goto skippci;
+if (virStrncpy(bus, key, (nextkey - key), sizeof(bus)) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Bus %s too big for destination), key);
+goto skippci;
+}
+
+key = nextkey + 1;
+if (!(nextkey = strchr(key, '.')))
+goto skippci;
+if (virStrncpy(slot, key, (nextkey - key), sizeof(slot)) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Slot %s too big for destination), key);
+goto skippci;
+}
+
+key = nextkey + 1;
+if (strlen(key) != 1)
+goto skippci;
+if (virStrncpy(func, key, 1, sizeof(func)) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Function %s too big for destination), key);
+goto skippci;
+}
+
+if (virStrToLong_i(domain, NULL, 16, domainID)  0)
+goto skippci;
+if (virStrToLong_i(bus, NULL, 16, busID)  0)
+goto skippci;
+if (virStrToLong_i(slot, NULL, 16, slotID)  0)
+goto skippci;
+if (virStrToLong_i(func, NULL, 16, funcID)  0)
+goto skippci;
+if (!(hostdev = virDomainHostdevDefAlloc()))
+   return -1;
+
+hostdev-managed = false;
+hostdev-source.subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
+hostdev-source.subsys.u.pci.addr.domain = domainID;
+hostdev-source.subsys.u.pci.addr.bus = busID;
+hostdev-source.subsys.u.pci.addr.slot = slotID;
+hostdev-source.subsys.u.pci.addr.function = funcID;
+
+if (VIR_APPEND_ELEMENT(def-hostdevs, def-nhostdevs, hostdev)  
0) {
+virDomainHostdevDefFree(hostdev);
+return -1;
+}
+
+skippci:
+list = list-next;
+}
+}
+
+return 0;
+}
+
+
 #define MAX_VFB 1024
 
 /*
@@ -353,7 +446,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 virDomainDiskDefPtr disk = NULL;
 virDomainNetDefPtr net = NULL;
 virDomainGraphicsDefPtr graphics = NULL;
-virDomainHostdevDefPtr hostdev = NULL;
 size_t i;
 const char *defaultMachine;
 unsigned long count;
@@ -837,95 +929,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 }
 }
 
-list = virConfGetValue(conf, pci);
-if (list  list-type == VIR_CONF_LIST) {
-list = list-list;
-while (list) {
-char domain[5];
-char bus[3];
-char slot[3];
-char func[2];
-char *key, *nextkey;
-int domainID;
-int busID;
-int slotID;
-int funcID;
-
-domain[0] = bus[0] = slot[0] = func[0] = '\0';
-
-if ((list-type != VIR_CONF_STRING) || (list-str == NULL))
-goto skippci;
-
-/* pci=[':00:1b.0',':00:13.0'] */
-if (!(key = list-str))
-goto skippci;
-if 

[libvirt] [PATCH 12/24] src/xenxs: Refactor code parsing OS config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenParseXMOS(virConfPtr conf,...);
which parses the OS config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 80 ++
 1 file changed, 50 insertions(+), 30 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 32c6d8c..b21d794 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1176,33 +1176,26 @@ xenParseXMGeneralMeta(virConfPtr conf, virDomainDefPtr 
def,
 
 return 0;
 }
-/*
- * Turn a config record into a lump of XML describing the
- * domain, suitable for later feeding for virDomainCreateXML
- */
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
-   virCapsPtr caps)
-{
-virDomainDefPtr def = NULL;
-size_t i;
 
-if (VIR_ALLOC(def)  0)
-return NULL;
-
-def-virtType = VIR_DOMAIN_VIRT_XEN;
-def-id = -1;
 
-if (xenParseXMGeneralMeta(conf, def, caps)  0)
-goto cleanup;
+static int
+xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
+{
+size_t i;
 
 if (STREQ(def-os.type, hvm)) {
 const char *boot;
+if (xenXMConfigCopyStringOpt(conf, device_model, def-emulator)  0)
+return -1;
+
+if (xenXMConfigCopyStringOpt(conf, device_model, def-emulator)  0)
+return -1;
+
 if (xenXMConfigCopyString(conf, kernel, def-os.loader)  0)
-goto cleanup;
+return -1;
 
 if (xenXMConfigGetString(conf, boot, boot, c)  0)
-goto cleanup;
+return -1;
 
 for (i = 0; i  VIR_DOMAIN_BOOT_LAST  boot[i]; i++) {
 switch (*boot) {
@@ -1226,28 +1219,58 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 const char *extra, *root;
 
 if (xenXMConfigCopyStringOpt(conf, bootloader, def-os.bootloader) 
 0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigCopyStringOpt(conf, bootargs, 
def-os.bootloaderArgs)  0)
-goto cleanup;
+return -1;
 
 if (xenXMConfigCopyStringOpt(conf, kernel, def-os.kernel)  0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigCopyStringOpt(conf, ramdisk, def-os.initrd)  0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigGetString(conf, extra, extra, NULL)  0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigGetString(conf, root, root, NULL)  0)
-goto cleanup;
+return -1;
 
 if (root) {
 if (virAsprintf(def-os.cmdline, root=%s %s, root, extra)  0)
-goto cleanup;
+return -1;
+
 } else {
 if (VIR_STRDUP(def-os.cmdline, extra)  0)
-goto cleanup;
+return -1;
+
 }
 }
 
+return 0;
+}
+/*
+ * Turn a config record into a lump of XML describing the
+ * domain, suitable for later feeding for virDomainCreateXML
+ */
+virDomainDefPtr
+xenParseXM(virConfPtr conf, int xendConfigVersion,
+   virCapsPtr caps)
+{
+virDomainDefPtr def = NULL;
+
+if (VIR_ALLOC(def)  0)
+return NULL;
+
+def-virtType = VIR_DOMAIN_VIRT_XEN;
+def-id = -1;
+
+if (xenParseXMGeneralMeta(conf, def, caps)  0)
+goto cleanup;
+
+if (xenParseXMOS(conf, def)  0)
+goto cleanup;
+
 if (xenParseXMMem(conf, def)  0)
 goto cleanup;
 
@@ -1263,9 +1286,6 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 if (xenParseXMDisk(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
-if (xenXMConfigCopyStringOpt(conf, device_model, def-emulator)  0)
-goto cleanup;
-
 if (xenParseXMVif(conf, def)  0)
 goto cleanup;
 
-- 
1.8.4.5

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


[libvirt] [PATCH 13/24] src/xenxs: Export code for reuse

2014-08-07 Thread Kiarie Kahurani
wrap code tagged for resuse into one function and export it

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 71 --
 src/xenxs/xen_xm.h |  2 ++
 2 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index b21d794..aa943ca 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1249,56 +1249,69 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
 
 return 0;
 }
-/*
- * Turn a config record into a lump of XML describing the
- * domain, suitable for later feeding for virDomainCreateXML
- */
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
-   virCapsPtr caps)
-{
-virDomainDefPtr def = NULL;
 
-if (VIR_ALLOC(def)  0)
-return NULL;
 
-def-virtType = VIR_DOMAIN_VIRT_XEN;
-def-id = -1;
+int
+xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def,
+ virCapsPtr caps, int xendConfigVersion)
+{
 
 if (xenParseXMGeneralMeta(conf, def, caps)  0)
-goto cleanup;
+return -1;
 
 if (xenParseXMOS(conf, def)  0)
-goto cleanup;
+return -1;
 
 if (xenParseXMMem(conf, def)  0)
-goto cleanup;
+return -1;
+
+if (xenParseXMTimeOffset(conf, def, xendConfigVersion)  0)
+return -1;
 
 if (xenParseXMEventsActions(conf, def)  0)
-goto cleanup;
+return -1;
+
+if (xenParseXMPCI(conf, def)  0)
+return -1;
 
 if (xenParseXMCPUFeatures(conf, def)  0)
-goto cleanup;
+return -1;
 
-if (xenParseXMTimeOffset(conf, def, xendConfigVersion)  0)
-goto cleanup;
+if (xenParseXMEmulatedDevices(conf, def)  0)
+return -1;
 
-if (xenParseXMDisk(conf, def, xendConfigVersion)  0)
-goto cleanup;
+if (xenParseXMCharDev(conf, def)  0)
+return -1;
+
+if (xenParseXMVfb(conf, def, xendConfigVersion)  0)
+return -1;
 
 if (xenParseXMVif(conf, def)  0)
-goto cleanup;
+return -1;
 
-if (xenParseXMPCI(conf, def)  0)
-goto cleanup;
+return 0;
+}
 
-if (xenParseXMEmulatedDevices(conf, def)  0)
-goto cleanup;
+/*
+ * Turn a config record into a lump of XML describing the
+ * domain, suitable for later feeding for virDomainCreateXML
+ */
+virDomainDefPtr
+xenParseXM(virConfPtr conf, int xendConfigVersion,
+   virCapsPtr caps)
+{
+virDomainDefPtr def = NULL;
 
-if (xenParseXMVfb(conf, def, xendConfigVersion)  0)
+if (VIR_ALLOC(def)  0)
+return NULL;
+
+def-virtType = VIR_DOMAIN_VIRT_XEN;
+def-id = -1;
+
+if (xenParseConfigCommon(conf, def, caps, xendConfigVersion)  0)
 goto cleanup;
 
-if (xenParseXMCharDev(conf, def)  0)
+if (xenParseXMDisk(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
 return def;
diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h
index 629a4b3..5292396 100644
--- a/src/xenxs/xen_xm.h
+++ b/src/xenxs/xen_xm.h
@@ -35,5 +35,7 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr 
def,
 
 virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion,
virCapsPtr caps);
+int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def, 
+ virCapsPtr caps, int xendConfigVersion);
 
 #endif /* __VIR_XEN_XM_H__ */
-- 
1.8.4.5

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


[libvirt] [PATCH 14/24] src/xenxs: Refactor code formating general VM config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenFormatXMGeneralMeta(virConfPtr conf,..);
which parses uuid and name instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 53 -
 1 file changed, 32 insertions(+), 21 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index aa943ca..08d26e5 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1322,8 +1322,8 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 }
 
 
-static
-int xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l)
+static int
+xenXMConfigSetInt(virConfPtr conf, const char *setting, long long l)
 {
 virConfValuePtr value = NULL;
 
@@ -1445,8 +1445,10 @@ xenFormatXMDisk(virConfValuePtr list,
 return -1;
 }
 
-static int xenFormatXMSerial(virConfValuePtr list,
- virDomainChrDefPtr serial)
+
+static int
+xenFormatXMSerial(virConfValuePtr list,
+  virDomainChrDefPtr serial)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 virConfValuePtr val, tmp;
@@ -1482,10 +1484,12 @@ static int xenFormatXMSerial(virConfValuePtr list,
 return -1;
 }
 
-static int xenFormatXMNet(virConnectPtr conn,
-  virConfValuePtr list,
-  virDomainNetDefPtr net,
-  int hvm, int xendConfigVersion)
+
+static int
+xenFormatXMNet(virConnectPtr conn,
+   virConfValuePtr list,
+   virDomainNetDefPtr net,
+   int hvm, int xendConfigVersion)
 {
 virBuffer buf = VIR_BUFFER_INITIALIZER;
 virConfValuePtr val, tmp;
@@ -1587,10 +1591,8 @@ static int xenFormatXMNet(virConnectPtr conn,
 }
 
 
-
 static int
-xenFormatXMPCI(virConfPtr conf,
-   virDomainDefPtr def)
+xenFormatXMPCI(virConfPtr conf, virDomainDefPtr def)
 {
 
 virConfValuePtr pciVal = NULL;
@@ -1656,32 +1658,41 @@ xenFormatXMPCI(virConfPtr conf,
 }
 
 
+static int
+xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr def)
+{
+char uuid[VIR_UUID_STRING_BUFLEN];
+
+if (xenXMConfigSetString(conf, name, def-name)  0)
+return -1;
+
+virUUIDFormat(def-uuid, uuid);
+if (xenXMConfigSetString(conf, uuid, uuid)  0)
+return -1;
+
+return 0;
+}
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
 
-virConfPtr xenFormatXM(virConnectPtr conn,
-   virDomainDefPtr def,
-   int xendConfigVersion)
+virConfPtr
+xenFormatXM(virConnectPtr conn,
+virDomainDefPtr def,
+int xendConfigVersion)
 {
 virConfPtr conf = NULL;
 int hvm = 0, vmlocaltime = 0;
 size_t i;
 char *cpus = NULL;
 const char *lifecycle;
-char uuid[VIR_UUID_STRING_BUFLEN];
 virConfValuePtr diskVal = NULL;
 virConfValuePtr netVal = NULL;
 
 if (!(conf = virConfNew()))
 goto cleanup;
 
-
-if (xenXMConfigSetString(conf, name, def-name)  0)
-goto cleanup;
-
-virUUIDFormat(def-uuid, uuid);
-if (xenXMConfigSetString(conf, uuid, uuid)  0)
+if (xenFormatXMGeneralMeta(conf, def)  0)
 goto cleanup;
 
 if (xenXMConfigSetInt(conf, maxmem,
-- 
1.8.4.5

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


[libvirt] [PATCH 15/24] src/xenxs: Refactor code formating memory config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenFormatXMMem(virConfPtr conf,...);
which parses memory config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 24 ++--
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 08d26e5..350aeeb 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1672,6 +1672,23 @@ xenFormatXMGeneralMeta(virConfPtr conf, virDomainDefPtr 
def)
 
 return 0;
 }
+
+
+static int
+xenFormatXMMem(virConfPtr conf, virDomainDefPtr def)
+{
+if (xenXMConfigSetInt(conf, maxmem,
+  VIR_DIV_UP(def-mem.max_balloon, 1024))  0)
+return -1;
+
+if (xenXMConfigSetInt(conf, memory,
+  VIR_DIV_UP(def-mem.cur_balloon, 1024))  0)
+return -1;
+
+return 0;
+}
+
+
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -1695,12 +1712,7 @@ xenFormatXM(virConnectPtr conn,
 if (xenFormatXMGeneralMeta(conf, def)  0)
 goto cleanup;
 
-if (xenXMConfigSetInt(conf, maxmem,
-  VIR_DIV_UP(def-mem.max_balloon, 1024))  0)
-goto cleanup;
-
-if (xenXMConfigSetInt(conf, memory,
-  VIR_DIV_UP(def-mem.cur_balloon, 1024))  0)
+if (xenFormatXMMem(conf, def)  0)
 goto cleanup;
 
 if (xenXMConfigSetInt(conf, vcpus, def-maxvcpus)  0)
-- 
1.8.4.5

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


[libvirt] [PATCH 16/24] src/xenxs: Refactor code formating virtual time config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenFormatXMTimeOffset(virConfPtr conf,);
which formats time config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 153 -
 1 file changed, 82 insertions(+), 71 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 350aeeb..5f092dc 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1689,6 +1689,86 @@ xenFormatXMMem(virConfPtr conf, virDomainDefPtr def)
 }
 
 
+static int
+xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr def,
+  int xendConfigVersion)
+{
+int vmlocaltime;
+if (xendConfigVersion  XEND_CONFIG_VERSION_3_1_0) {
+/* 3.1: UTC and LOCALTIME */
+switch (def-clock.offset) {
+case VIR_DOMAIN_CLOCK_OFFSET_UTC:
+vmlocaltime = 0;
+break;
+case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
+vmlocaltime = 1;
+break;
+default:
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unsupported clock offset='%s'),
+   
virDomainClockOffsetTypeToString(def-clock.offset));
+return -1;
+}
+
+} else {
+if (STREQ(def-os.type, hvm)) {
+/* =3.1 HV: VARIABLE */
+int rtc_timeoffset;
+switch (def-clock.offset) {
+case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
+vmlocaltime = (int)def-clock.data.variable.basis;
+rtc_timeoffset = def-clock.data.variable.adjustment;
+break;
+case VIR_DOMAIN_CLOCK_OFFSET_UTC:
+if (def-clock.data.utc_reset) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(unsupported clock adjustment='reset'));
+return -1;
+}
+vmlocaltime = 0;
+rtc_timeoffset = 0;
+break;
+case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
+if (def-clock.data.utc_reset) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(unsupported clock adjustment='reset'));
+return -1;
+}
+vmlocaltime = 1;
+rtc_timeoffset = 0;
+break;
+default:
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unsupported clock offset='%s'),
+   
virDomainClockOffsetTypeToString(def-clock.offset));
+return -1;
+}
+if (xenXMConfigSetInt(conf, rtc_timeoffset, rtc_timeoffset)  0)
+return -1;
+
+} else {
+/* =3.1 PV: UTC and LOCALTIME */
+switch (def-clock.offset) {
+case VIR_DOMAIN_CLOCK_OFFSET_UTC:
+vmlocaltime = 0;
+break;
+case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
+vmlocaltime = 1;
+break;
+default:
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unsupported clock offset='%s'),
+   
virDomainClockOffsetTypeToString(def-clock.offset));
+return -1;
+}
+} /* !hvm */
+}
+
+if (xenXMConfigSetInt(conf, localtime, vmlocaltime)  0)
+return -1;
+
+return 0;
+}
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -1699,7 +1779,7 @@ xenFormatXM(virConnectPtr conn,
 int xendConfigVersion)
 {
 virConfPtr conf = NULL;
-int hvm = 0, vmlocaltime = 0;
+int hvm = 0;
 size_t i;
 char *cpus = NULL;
 const char *lifecycle;
@@ -1838,78 +1918,9 @@ xenFormatXM(virConnectPtr conn,
 goto cleanup;
 } /* !hvm */
 
-
-if (xendConfigVersion  XEND_CONFIG_VERSION_3_1_0) {
-/* 3.1: UTC and LOCALTIME */
-switch (def-clock.offset) {
-case VIR_DOMAIN_CLOCK_OFFSET_UTC:
-vmlocaltime = 0;
-break;
-case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME:
-vmlocaltime = 1;
-break;
-default:
-virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-   _(unsupported clock offset='%s'),
-   
virDomainClockOffsetTypeToString(def-clock.offset));
-goto cleanup;
-}
-} else {
-if (hvm) {
-/* =3.1 HV: VARIABLE */
-int rtc_timeoffset;
-switch (def-clock.offset) {
-case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE:
-vmlocaltime = (int)def-clock.data.variable.basis;
-rtc_timeoffset = 

[libvirt] [PATCH 17/24] src/xenxs: Refactor code formating event actions config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenFormatXMEventActions(virConfPtr conf,.);
which formats event actions instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 63 +++---
 1 file changed, 36 insertions(+), 27 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 5f092dc..c3e7cde 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1769,6 +1769,41 @@ xenFormatXMTimeOffset(virConfPtr conf, virDomainDefPtr 
def,
 
 return 0;
 }
+
+
+static int
+xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr def)
+{
+const char *lifecycle = NULL;
+
+if (!(lifecycle = virDomainLifecycleTypeToString(def-onPoweroff))) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected lifecycle action %d), def-onPoweroff);
+return -1;
+}
+if (xenXMConfigSetString(conf, on_poweroff, lifecycle)  0)
+return -1;
+
+
+if (!(lifecycle = virDomainLifecycleTypeToString(def-onReboot))) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected lifecycle action %d), def-onReboot);
+return -1;
+}
+if (xenXMConfigSetString(conf, on_reboot, lifecycle)  0)
+return -1;
+
+
+if (!(lifecycle = virDomainLifecycleCrashTypeToString(def-onCrash))) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unexpected lifecycle action %d), def-onCrash);
+return -1;
+}
+if (xenXMConfigSetString(conf, on_crash, lifecycle)  0)
+return -1;
+
+return 0;
+}
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -1782,7 +1817,6 @@ xenFormatXM(virConnectPtr conn,
 int hvm = 0;
 size_t i;
 char *cpus = NULL;
-const char *lifecycle;
 virConfValuePtr diskVal = NULL;
 virConfValuePtr netVal = NULL;
 
@@ -1921,33 +1955,8 @@ xenFormatXM(virConnectPtr conn,
 if (xenFormatXMTimeOffset(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
-if (!(lifecycle = virDomainLifecycleTypeToString(def-onPoweroff))) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unexpected lifecycle action %d), def-onPoweroff);
-goto cleanup;
-}
-if (xenXMConfigSetString(conf, on_poweroff, lifecycle)  0)
-goto cleanup;
-
-
-if (!(lifecycle = virDomainLifecycleTypeToString(def-onReboot))) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unexpected lifecycle action %d), def-onReboot);
+if (xenFormatXMEventActions(conf, def)  0)
 goto cleanup;
-}
-if (xenXMConfigSetString(conf, on_reboot, lifecycle)  0)
-goto cleanup;
-
-
-if (!(lifecycle = virDomainLifecycleCrashTypeToString(def-onCrash))) {
-virReportError(VIR_ERR_INTERNAL_ERROR,
-   _(unexpected lifecycle action %d), def-onCrash);
-goto cleanup;
-}
-if (xenXMConfigSetString(conf, on_crash, lifecycle)  0)
-goto cleanup;
-
-
 
 if (hvm) {
 if (def-emulator 
-- 
1.8.4.5

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


[libvirt] [PATCH 11/24] src/xenxs: Refactor code parsing general config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenParseXMGeneralMeta(virConfPtr conf, ...);
which parses general metadata instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 58 --
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 9eabfa4..32c6d8c 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1131,38 +1131,28 @@ xenParseXMEmulatedDevices(virConfPtr conf, 
virDomainDefPtr def)
 return 0;
 }
 
-/*
- * Turn a config record into a lump of XML describing the
- * domain, suitable for later feeding for virDomainCreateXML
- */
-virDomainDefPtr
-xenParseXM(virConfPtr conf, int xendConfigVersion,
-   virCapsPtr caps)
+
+static int
+xenParseXMGeneralMeta(virConfPtr conf, virDomainDefPtr def,
+  virCapsPtr caps)
 {
+
+const char *defaultMachine;
 const char *str;
 int hvm = 0;
-virDomainDefPtr def = NULL;
-size_t i;
-const char *defaultMachine;
-
-if (VIR_ALLOC(def)  0)
-return NULL;
-
-def-virtType = VIR_DOMAIN_VIRT_XEN;
-def-id = -1;
 
 if (xenXMConfigCopyString(conf, name, def-name)  0)
-goto cleanup;
-if (xenXMConfigGetUUID(conf, uuid, def-uuid)  0)
-goto cleanup;
+return -1;
 
+if (xenXMConfigGetUUID(conf, uuid, def-uuid)  0)
+return -1;
 
 if ((xenXMConfigGetString(conf, builder, str, linux) == 0) 
 STREQ(str, hvm))
 hvm = 1;
 
 if (VIR_STRDUP(def-os.type, hvm ? hvm : xen)  0)
-goto cleanup;
+return -1;
 
 def-os.arch =
 virCapabilitiesDefaultGuestArch(caps,
@@ -1172,7 +1162,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 virReportError(VIR_ERR_INTERNAL_ERROR,
_(no supported architecture for os type '%s'),
def-os.type);
-goto cleanup;
+return -1;
 }
 
 defaultMachine = virCapabilitiesDefaultGuestMachine(caps,
@@ -1181,10 +1171,32 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
 
virDomainVirtTypeToString(def-virtType));
 if (defaultMachine != NULL) {
 if (VIR_STRDUP(def-os.machine, defaultMachine)  0)
-goto cleanup;
+return -1;
 }
 
-if (hvm) {
+return 0;
+}
+/*
+ * Turn a config record into a lump of XML describing the
+ * domain, suitable for later feeding for virDomainCreateXML
+ */
+virDomainDefPtr
+xenParseXM(virConfPtr conf, int xendConfigVersion,
+   virCapsPtr caps)
+{
+virDomainDefPtr def = NULL;
+size_t i;
+
+if (VIR_ALLOC(def)  0)
+return NULL;
+
+def-virtType = VIR_DOMAIN_VIRT_XEN;
+def-id = -1;
+
+if (xenParseXMGeneralMeta(conf, def, caps)  0)
+goto cleanup;
+
+if (STREQ(def-os.type, hvm)) {
 const char *boot;
 if (xenXMConfigCopyString(conf, kernel, def-os.loader)  0)
 goto cleanup;
-- 
1.8.4.5

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


[libvirt] [PATCH 18/24] src/xenxs: Refactor code formating Char devices config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenFormatXMCharDev(virConfPtr conf,);
which formats Char devices config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 163 ++---
 1 file changed, 91 insertions(+), 72 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index c3e7cde..6752b27 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1804,6 +1804,94 @@ xenFormatXMEventActions(virConfPtr conf, virDomainDefPtr 
def)
 
 return 0;
 }
+
+
+static int
+xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def)
+{
+size_t i;
+
+if (STREQ(def-os.type, hvm)) {
+if (def-nparallels) {
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+char *str;
+int ret;
+
+ret = xenFormatSxprChr(def-parallels[0], buf);
+str = virBufferContentAndReset(buf);
+if (ret == 0)
+ret = xenXMConfigSetString(conf, parallel, str);
+VIR_FREE(str);
+if (ret  0)
+return -1;
+
+} else {
+if (xenXMConfigSetString(conf, parallel, none)  0)
+return -1;
+}
+
+if (def-nserials) {
+if ((def-nserials == 1)  (def-serials[0]-target.port == 0)) {
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+char *str;
+int ret;
+
+ret = xenFormatSxprChr(def-serials[0], buf);
+str = virBufferContentAndReset(buf);
+if (ret == 0)
+ret = xenXMConfigSetString(conf, serial, str);
+VIR_FREE(str);
+if (ret  0)
+return -1;
+
+} else {
+size_t j = 0;
+int maxport = -1, port;
+virConfValuePtr serialVal = NULL;
+
+if (VIR_ALLOC(serialVal)  0)
+return -1;
+
+serialVal-type = VIR_CONF_LIST;
+serialVal-list = NULL;
+
+for (i = 0; i  def-nserials; i++)
+if (def-serials[i]-target.port  maxport)
+maxport = def-serials[i]-target.port;
+
+for (port = 0; port = maxport; port++) {
+virDomainChrDefPtr chr = NULL;
+for (j = 0; j  def-nserials; j++) {
+if (def-serials[j]-target.port == port) {
+chr = def-serials[j];
+break;
+}
+}
+
+if (xenFormatXMSerial(serialVal, chr)  0) {
+VIR_FREE(serialVal);
+return -1;
+}
+}
+
+if (serialVal-list != NULL) {
+int ret = virConfSetValue(conf, serial, serialVal);
+serialVal = NULL;
+if (ret  0)
+return -1;
+}
+VIR_FREE(serialVal);
+}
+} else {
+if (xenXMConfigSetString(conf, serial, none)  0)
+return -1;
+}
+}
+
+return 0;
+}
+
+
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -2134,79 +,10 @@ xenFormatXM(virConnectPtr conn,
 if (xenFormatXMPCI(conf, def)  0)
 goto cleanup;
 
-if (hvm) {
-if (def-nparallels) {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
-char *str;
-int ret;
-
-ret = xenFormatSxprChr(def-parallels[0], buf);
-str = virBufferContentAndReset(buf);
-if (ret == 0)
-ret = xenXMConfigSetString(conf, parallel, str);
-VIR_FREE(str);
-if (ret  0)
-goto cleanup;
-} else {
-if (xenXMConfigSetString(conf, parallel, none)  0)
-goto cleanup;
-}
-
-if (def-nserials) {
-if ((def-nserials == 1)  (def-serials[0]-target.port == 0)) {
-virBuffer buf = VIR_BUFFER_INITIALIZER;
-char *str;
-int ret;
-
-ret = xenFormatSxprChr(def-serials[0], buf);
-str = virBufferContentAndReset(buf);
-if (ret == 0)
-ret = xenXMConfigSetString(conf, serial, str);
-VIR_FREE(str);
-if (ret  0)
-goto cleanup;
-} else {
-size_t j = 0;
-int maxport = -1, port;
-virConfValuePtr serialVal = NULL;
-
-if (VIR_ALLOC(serialVal)  0)
-goto cleanup;
-serialVal-type = VIR_CONF_LIST;
-

[libvirt] [PATCH 19/24] src/xenxs: Refactor code formating xm disk config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenFormatXMDomainDisks(virConfPtr conf,.);
which formats domain disks config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 72 +-
 1 file changed, 44 insertions(+), 28 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 6752b27..5a585ce 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1892,6 +1892,49 @@ xenFormatXMCharDev(virConfPtr conf, virDomainDefPtr def)
 }
 
 
+static int
+xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr def,
+   int xendConfigVersion)
+{
+virConfValuePtr diskVal = NULL;
+size_t i = 0;
+int hvm = STREQ(def-os.type, hvm);
+
+if (VIR_ALLOC(diskVal)  0)
+goto cleanup;
+
+diskVal-type = VIR_CONF_LIST;
+diskVal-list = NULL;
+
+for (i = 0; i  def-ndisks; i++) {
+if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 
+def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_CDROM 
+def-disks[i]-dst 
+STREQ(def-disks[i]-dst, hdc)) {
+continue;
+}
+
+if (def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
+continue;
+
+if (xenFormatXMDisk(diskVal, def-disks[i],
+hvm, xendConfigVersion)  0)
+goto cleanup;
+}
+
+if (diskVal-list != NULL) {
+int ret = virConfSetValue(conf, disk, diskVal);
+diskVal = NULL;
+if (ret  0)
+goto cleanup;
+}
+
+return 0;
+
+ cleanup:
+virConfFreeValue(diskVal);
+return -1;
+}
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -1905,7 +1948,6 @@ xenFormatXM(virConnectPtr conn,
 int hvm = 0;
 size_t i;
 char *cpus = NULL;
-virConfValuePtr diskVal = NULL;
 virConfValuePtr netVal = NULL;
 
 if (!(conf = virConfNew()))
@@ -2173,33 +2215,8 @@ xenFormatXM(virConnectPtr conn,
 }
 }
 
-/* analyze of the devices */
-if (VIR_ALLOC(diskVal)  0)
+if (xenFormatXMDomainDisks(conf, def, xendConfigVersion)  0)
 goto cleanup;
-diskVal-type = VIR_CONF_LIST;
-diskVal-list = NULL;
-
-for (i = 0; i  def-ndisks; i++) {
-if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 
-def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_CDROM 
-def-disks[i]-dst 
-STREQ(def-disks[i]-dst, hdc)) {
-continue;
-}
-if (def-disks[i]-device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
-continue;
-
-if (xenFormatXMDisk(diskVal, def-disks[i],
-hvm, xendConfigVersion)  0)
-goto cleanup;
-}
-if (diskVal-list != NULL) {
-int ret = virConfSetValue(conf, disk, diskVal);
-diskVal = NULL;
-if (ret  0)
-goto cleanup;
-}
-VIR_FREE(diskVal);
 
 if (VIR_ALLOC(netVal)  0)
 goto cleanup;
@@ -2243,7 +2260,6 @@ xenFormatXM(virConnectPtr conn,
 return conf;
 
  cleanup:
-virConfFreeValue(diskVal);
 virConfFreeValue(netVal);
 VIR_FREE(cpus);
 if (conf)
-- 
1.8.4.5

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


[libvirt] [PATCH 20/24] src/xenxs: Refactor code formating CPU features config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenFormatXMCPUFeatures(virConfPtr conf, ..);
which formats CPU features config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 118 -
 tests/xmconfigdata/test-escape-paths.cfg   |   6 +-
 tests/xmconfigdata/test-fullvirt-force-hpet.cfg|   6 +-
 tests/xmconfigdata/test-fullvirt-force-nohpet.cfg  |   6 +-
 tests/xmconfigdata/test-fullvirt-localtime.cfg |   6 +-
 tests/xmconfigdata/test-fullvirt-net-ioemu.cfg |   6 +-
 tests/xmconfigdata/test-fullvirt-net-netfront.cfg  |   6 +-
 tests/xmconfigdata/test-fullvirt-new-cdrom.cfg |   6 +-
 tests/xmconfigdata/test-fullvirt-old-cdrom.cfg |   6 +-
 tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg  |   6 +-
 .../test-fullvirt-serial-dev-2-ports.cfg   |   6 +-
 .../test-fullvirt-serial-dev-2nd-port.cfg  |   6 +-
 tests/xmconfigdata/test-fullvirt-serial-file.cfg   |   6 +-
 tests/xmconfigdata/test-fullvirt-serial-null.cfg   |   6 +-
 tests/xmconfigdata/test-fullvirt-serial-pipe.cfg   |   6 +-
 tests/xmconfigdata/test-fullvirt-serial-pty.cfg|   6 +-
 tests/xmconfigdata/test-fullvirt-serial-stdio.cfg  |   6 +-
 .../test-fullvirt-serial-tcp-telnet.cfg|   6 +-
 tests/xmconfigdata/test-fullvirt-serial-tcp.cfg|   6 +-
 tests/xmconfigdata/test-fullvirt-serial-udp.cfg|   6 +-
 tests/xmconfigdata/test-fullvirt-serial-unix.cfg   |   6 +-
 tests/xmconfigdata/test-fullvirt-sound.cfg |   6 +-
 tests/xmconfigdata/test-fullvirt-usbmouse.cfg  |   6 +-
 tests/xmconfigdata/test-fullvirt-usbtablet.cfg |   6 +-
 tests/xmconfigdata/test-fullvirt-utc.cfg   |   6 +-
 tests/xmconfigdata/test-no-source-cdrom.cfg|   6 +-
 tests/xmconfigdata/test-pci-devs.cfg   |   6 +-
 27 files changed, 146 insertions(+), 128 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 5a585ce..6bd04ba 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1935,6 +1935,73 @@ xenFormatXMDomainDisks(virConfPtr conf, virDomainDefPtr 
def,
 virConfFreeValue(diskVal);
 return -1;
 }
+
+
+static int
+xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr def,
+   int xendConfigVersion)
+{
+char *cpus = NULL;
+size_t i;
+
+if (xenXMConfigSetInt(conf, vcpus, def-maxvcpus)  0)
+return -1;
+/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
+   either 32, or 64 on a platform where long is big enough.  */
+if (def-vcpus  def-maxvcpus 
+xenXMConfigSetInt(conf, vcpu_avail, (1UL  def-vcpus) - 1)  0)
+return -1;
+
+if ((def-cpumask != NULL) 
+((cpus = virBitmapFormat(def-cpumask)) == NULL)) {
+return -1;
+}
+
+if (cpus 
+xenXMConfigSetString(conf, cpus, cpus)  0)
+return -1;
+
+VIR_FREE(cpus);
+if (STREQ(def-os.type, hvm)) {
+if (xenXMConfigSetInt(conf, pae,
+  (def-features[VIR_DOMAIN_FEATURE_PAE] ==
+   VIR_TRISTATE_SWITCH_ON) ? 1 : 0)  0)
+return -1;
+
+if (xenXMConfigSetInt(conf, acpi,
+  (def-features[VIR_DOMAIN_FEATURE_ACPI] ==
+   VIR_TRISTATE_SWITCH_ON) ? 1 : 0)  0)
+return -1;
+
+if (xenXMConfigSetInt(conf, apic,
+  (def-features[VIR_DOMAIN_FEATURE_APIC] ==
+   VIR_TRISTATE_SWITCH_ON) ? 1 : 0)  0)
+return -1;
+
+if (xendConfigVersion = XEND_CONFIG_VERSION_3_0_4) {
+if (xenXMConfigSetInt(conf, hap,
+  (def-features[VIR_DOMAIN_FEATURE_HAP] ==
+   VIR_TRISTATE_SWITCH_ON) ? 1 : 0)  0)
+return -1;
+
+if (xenXMConfigSetInt(conf, viridian,
+  (def-features[VIR_DOMAIN_FEATURE_VIRIDIAN] 
==
+   VIR_TRISTATE_SWITCH_ON) ? 1 : 0)  0)
+return -1;
+}
+
+for (i = 0; i  def-clock.ntimers; i++) {
+if (def-clock.timers[i]-name == VIR_DOMAIN_TIMER_NAME_HPET 
+def-clock.timers[i]-present != -1 
+xenXMConfigSetInt(conf, hpet, def-clock.timers[i]-present) 
 0)
+return -1;
+}
+}
+
+return 0;
+}
+
+
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -1959,24 +2026,9 @@ xenFormatXM(virConnectPtr conn,
 if (xenFormatXMMem(conf, def)  0)
 goto cleanup;
 
-if (xenXMConfigSetInt(conf, vcpus, def-maxvcpus)  0)
-goto cleanup;
-/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
-   either 32, or 64 on a platform where long is 

[libvirt] [PATCH 21/24] src/xenxs: Refactor code formating OS config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenFormatXMOS(virConfPtr conf,);
which formats OS config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 95 --
 tests/xmconfigdata/test-escape-paths.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-force-hpet.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-force-nohpet.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-localtime.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-net-ioemu.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-net-netfront.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-new-cdrom.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-old-cdrom.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg  |  2 +-
 .../test-fullvirt-serial-dev-2-ports.cfg   |  2 +-
 .../test-fullvirt-serial-dev-2nd-port.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-file.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-null.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-pipe.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-pty.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-stdio.cfg  |  2 +-
 .../test-fullvirt-serial-tcp-telnet.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-tcp.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-udp.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-unix.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-sound.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-usbmouse.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-usbtablet.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-utc.cfg   |  2 +-
 tests/xmconfigdata/test-no-source-cdrom.cfg|  2 +-
 tests/xmconfigdata/test-pci-devs.cfg   |  2 +-
 27 files changed, 80 insertions(+), 67 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 6bd04ba..9db159d 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -2002,43 +2002,20 @@ xenFormatXMCPUFeatures(virConfPtr conf, virDomainDefPtr 
def,
 }
 
 
-/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
-   either 32, or 64 on a platform where long is big enough.  */
-verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
-
-virConfPtr
-xenFormatXM(virConnectPtr conn,
-virDomainDefPtr def,
-int xendConfigVersion)
+static int
+xenFormatXMOS(virConfPtr conf, virDomainDefPtr def,
+  int xendConfigVersion)
 {
-virConfPtr conf = NULL;
-int hvm = 0;
 size_t i;
-char *cpus = NULL;
-virConfValuePtr netVal = NULL;
-
-if (!(conf = virConfNew()))
-goto cleanup;
-
-if (xenFormatXMGeneralMeta(conf, def)  0)
-goto cleanup;
-
-if (xenFormatXMMem(conf, def)  0)
-goto cleanup;
 
-if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-hvm = STREQ(def-os.type, hvm) ? 1 : 0;
-
-if (hvm) {
+if (STREQ(def-os.type, hvm)) {
 char boot[VIR_DOMAIN_BOOT_LAST+1];
 if (xenXMConfigSetString(conf, builder, hvm)  0)
-goto cleanup;
+return -1;
 
 if (def-os.loader 
 xenXMConfigSetString(conf, kernel, def-os.loader)  0)
-goto cleanup;
+return -1;
 
 for (i = 0; i  def-os.nBootDevs; i++) {
 switch (def-os.bootDevs[i]) {
@@ -2065,7 +2042,7 @@ xenFormatXM(virConnectPtr conn,
 }
 
 if (xenXMConfigSetString(conf, boot, boot)  0)
-goto cleanup;
+return -1;
 
 if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2) {
 for (i = 0; i  def-ndisks; i++) {
@@ -2075,31 +2052,72 @@ xenFormatXM(virConnectPtr conn,
 virDomainDiskGetSource(def-disks[i])) {
 if (xenXMConfigSetString(conf, cdrom,
  
virDomainDiskGetSource(def-disks[i]))  0)
-goto cleanup;
+return -1;
+
 break;
 }
 }
 }
 
+if (def-emulator 
+xenXMConfigSetString(conf, device_model, def-emulator)  0)
+return -1;
 /* XXX floppy disks */
 } else {
 if (def-os.bootloader 
 xenXMConfigSetString(conf, bootloader, def-os.bootloader)  0)
-goto cleanup;
+return -1;
+
 if (def-os.bootloaderArgs 
 xenXMConfigSetString(conf, bootargs, def-os.bootloaderArgs)  0)
-goto cleanup;
+return -1;
+
 if (def-os.kernel 
 xenXMConfigSetString(conf, kernel, def-os.kernel)  0)
-goto cleanup;
+return -1;
+
 if (def-os.initrd 
 xenXMConfigSetString(conf, ramdisk, def-os.initrd)  0)
-goto cleanup;
+return -1;
+
 if (def-os.cmdline 
 xenXMConfigSetString(conf, 

[libvirt] [PATCH 22/24] src/xenxs: Refactor code formating Vfb config

2014-08-07 Thread Kiarie Kahurani
introduce function
   xenFormatXMVfb(virConfPtr conf,.);
which formats Vfb config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 171 ++---
 1 file changed, 97 insertions(+), 74 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 9db159d..bf5a23a 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -2087,108 +2087,65 @@ xenFormatXMOS(virConfPtr conf, virDomainDefPtr def,
 
 return 0;
 }
-/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
-   either 32, or 64 on a platform where long is big enough.  */
-verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
-
-virConfPtr
-xenFormatXM(virConnectPtr conn,
-virDomainDefPtr def,
-int xendConfigVersion)
-{
-virConfPtr conf = NULL;
-int hvm = 0;
-size_t i;
-virConfValuePtr netVal = NULL;
-
-if (!(conf = virConfNew()))
-goto cleanup;
-
-if (xenFormatXMGeneralMeta(conf, def)  0)
-goto cleanup;
-
-if (xenFormatXMMem(conf, def)  0)
-goto cleanup;
-
-if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-hvm = STREQ(def-os.type, hvm);
 
-if (xenFormatXMOS(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-if (xenFormatXMTimeOffset(conf, def, xendConfigVersion)  0)
-goto cleanup;
 
-if (xenFormatXMEventActions(conf, def)  0)
-goto cleanup;
-
-if (hvm) {
-for (i = 0; i  def-ninputs; i++) {
-if (def-inputs[i]-bus == VIR_DOMAIN_INPUT_BUS_USB) {
-if (xenXMConfigSetInt(conf, usb, 1)  0)
-goto cleanup;
-switch (def-inputs[i]-type) {
-case VIR_DOMAIN_INPUT_TYPE_MOUSE:
-if (xenXMConfigSetString(conf, usbdevice, mouse)  
0)
-goto cleanup;
-break;
-case VIR_DOMAIN_INPUT_TYPE_TABLET:
-if (xenXMConfigSetString(conf, usbdevice, tablet) 
 0)
-goto cleanup;
-break;
-case VIR_DOMAIN_INPUT_TYPE_KBD:
-if (xenXMConfigSetString(conf, usbdevice, 
keyboard)  0)
-goto cleanup;
-break;
-}
-break;
-}
-}
-}
+static int
+xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def,
+   int xendConfigVersion)
+{
+int hvm = STREQ(def-os.type, hvm);
 
 if (def-ngraphics == 1) {
 if (hvm || (xendConfigVersion  XEND_CONFIG_MIN_VERS_PVFB_NEWCONF)) {
 if (def-graphics[0]-type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
 if (xenXMConfigSetInt(conf, sdl, 1)  0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigSetInt(conf, vnc, 0)  0)
-goto cleanup;
+return -1;
+
 if (def-graphics[0]-data.sdl.display 
 xenXMConfigSetString(conf, display,
  def-graphics[0]-data.sdl.display)  0)
-goto cleanup;
+return -1;
+
 if (def-graphics[0]-data.sdl.xauth 
 xenXMConfigSetString(conf, xauthority,
  def-graphics[0]-data.sdl.xauth)  0)
-goto cleanup;
+return -1;
+
 } else {
 const char *listenAddr;
 
 if (xenXMConfigSetInt(conf, sdl, 0)  0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigSetInt(conf, vnc, 1)  0)
-goto cleanup;
+return -1;
+
 if (xenXMConfigSetInt(conf, vncunused,
   def-graphics[0]-data.vnc.autoport ? 1 : 0)  0)
-goto cleanup;
+return -1;
+
 if (!def-graphics[0]-data.vnc.autoport 
 xenXMConfigSetInt(conf, vncdisplay,
   def-graphics[0]-data.vnc.port - 5900)  0)
-goto cleanup;
+return -1;
+
 listenAddr = 
virDomainGraphicsListenGetAddress(def-graphics[0], 0);
 if (listenAddr 
 xenXMConfigSetString(conf, vnclisten, listenAddr)  0)
-goto cleanup;
+return -1;
+
 if (def-graphics[0]-data.vnc.auth.passwd 
 xenXMConfigSetString(conf, vncpasswd,
 
def-graphics[0]-data.vnc.auth.passwd)  0)
-goto cleanup;
+return -1;
+
 if (def-graphics[0]-data.vnc.keymap 

[libvirt] [PATCH 23/24] src/xenxs: Refactor code formating emulated devices config

2014-08-07 Thread Kiarie Kahurani
introduce function
  xenFormatXMEmulatedHardware(virConfPtr conf,);
which formats emulated hardware config instead

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 150 +
 tests/xmconfigdata/test-escape-paths.cfg   |   2 +-
 tests/xmconfigdata/test-fullvirt-sound.cfg |   2 +-
 3 files changed, 92 insertions(+), 62 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index bf5a23a..071802d 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -2206,6 +2206,93 @@ xenFormatXMVfb(virConfPtr conf, virDomainDefPtr def,
 
 return 0;
 }
+
+
+static int
+xenFormatXMVif(virConfPtr conf, virConnectPtr conn,
+   virDomainDefPtr def, int xendConfigVersion)
+{
+   virConfValuePtr netVal = NULL;
+   size_t i;
+   int hvm = STREQ(def-os.type, hvm);
+
+   if (VIR_ALLOC(netVal)  0)
+goto cleanup;
+netVal-type = VIR_CONF_LIST;
+netVal-list = NULL;
+
+for (i = 0; i  def-nnets; i++) {
+if (xenFormatXMNet(conn, netVal, def-nets[i],
+   hvm, xendConfigVersion)  0)
+   goto cleanup;
+}
+
+if (netVal-list != NULL) {
+int ret = virConfSetValue(conf, vif, netVal);
+netVal = NULL;
+if (ret  0)
+goto cleanup;
+}
+
+VIR_FREE(netVal);
+return 0;
+
+ cleanup:
+virConfFreeValue(netVal);
+return -1;
+}
+
+
+static int
+xenFormatXMEmulatedHardware(virConfPtr conf, virDomainDefPtr def)
+{
+size_t i;
+
+if (STREQ(def-os.type, hvm)) {
+if (def-sounds) {
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+char *str = NULL;
+int ret = xenFormatSxprSound(def, buf);
+str = virBufferContentAndReset(buf);
+if (ret == 0)
+ret = xenXMConfigSetString(conf, soundhw, str);
+
+VIR_FREE(str);
+if (ret  0)
+return -1;
+}
+
+for (i = 0; i  def-ninputs; i++) {
+if (def-inputs[i]-bus == VIR_DOMAIN_INPUT_BUS_USB) {
+if (xenXMConfigSetInt(conf, usb, 1)  0)
+return -1;
+
+switch (def-inputs[i]-type) {
+case VIR_DOMAIN_INPUT_TYPE_MOUSE:
+if (xenXMConfigSetString(conf, usbdevice, mouse)  
0)
+return -1;
+
+break;
+case VIR_DOMAIN_INPUT_TYPE_TABLET:
+if (xenXMConfigSetString(conf, usbdevice, tablet) 
 0)
+return -1;
+
+break;
+case VIR_DOMAIN_INPUT_TYPE_KBD:
+if (xenXMConfigSetString(conf, usbdevice, 
keyboard)  0)
+return -1;
+
+break;
+}
+break;
+}
+}
+}
+
+return 0;
+}
+
+
 /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
either 32, or 64 on a platform where long is big enough.  */
 verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
@@ -2216,9 +2303,6 @@ xenFormatXM(virConnectPtr conn,
 int xendConfigVersion)
 {
 virConfPtr conf = NULL;
-int hvm = 0;
-size_t i;
-virConfValuePtr netVal = NULL;
 
 if (!(conf = virConfNew()))
 goto cleanup;
@@ -2232,8 +2316,6 @@ xenFormatXM(virConnectPtr conn,
 if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
-hvm = STREQ(def-os.type, hvm);
-
 if (xenFormatXMOS(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
@@ -2243,29 +2325,8 @@ xenFormatXM(virConnectPtr conn,
 if (xenFormatXMEventActions(conf, def)  0)
 goto cleanup;
 
-if (hvm) {
-for (i = 0; i  def-ninputs; i++) {
-if (def-inputs[i]-bus == VIR_DOMAIN_INPUT_BUS_USB) {
-if (xenXMConfigSetInt(conf, usb, 1)  0)
-goto cleanup;
-switch (def-inputs[i]-type) {
-case VIR_DOMAIN_INPUT_TYPE_MOUSE:
-if (xenXMConfigSetString(conf, usbdevice, mouse)  
0)
-goto cleanup;
-break;
-case VIR_DOMAIN_INPUT_TYPE_TABLET:
-if (xenXMConfigSetString(conf, usbdevice, tablet) 
 0)
-goto cleanup;
-break;
-case VIR_DOMAIN_INPUT_TYPE_KBD:
-if (xenXMConfigSetString(conf, usbdevice, 
keyboard)  0)
-goto cleanup;
-break;
-}
-break;
-}
-}
-}
+if (xenFormatXMEmulatedHardware(conf, def)  0)
+goto cleanup;
 
 if (xenFormatXMVfb(conf, def, xendConfigVersion)  0)
 goto cleanup;
@@ -2273,23 +2334,8 @@ 

[libvirt] [PATCH 24/24] src/xenxs: Export code

2014-08-07 Thread Kiarie Kahurani
export code for reuse and some formating fix

signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
Signed-off-by: Kiarie Kahurani davidkiar...@gmail.com
---
 src/xenxs/xen_xm.c | 59 +-
 src/xenxs/xen_xm.h |  4 +-
 tests/xmconfigdata/test-escape-paths.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-force-hpet.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-force-nohpet.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-localtime.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-net-ioemu.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-net-netfront.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-new-cdrom.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-old-cdrom.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-parallel-tcp.cfg  |  2 +-
 .../test-fullvirt-serial-dev-2-ports.cfg   |  2 +-
 .../test-fullvirt-serial-dev-2nd-port.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-file.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-null.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-pipe.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-serial-pty.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-stdio.cfg  |  2 +-
 .../test-fullvirt-serial-tcp-telnet.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-tcp.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-udp.cfg|  2 +-
 tests/xmconfigdata/test-fullvirt-serial-unix.cfg   |  2 +-
 tests/xmconfigdata/test-fullvirt-sound.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-usbmouse.cfg  |  2 +-
 tests/xmconfigdata/test-fullvirt-usbtablet.cfg |  2 +-
 tests/xmconfigdata/test-fullvirt-utc.cfg   |  2 +-
 tests/xmconfigdata/test-no-source-cdrom.cfg|  2 +-
 tests/xmconfigdata/test-paravirt-net-e1000.cfg |  2 +-
 tests/xmconfigdata/test-paravirt-net-vifname.cfg   |  2 +-
 .../test-paravirt-new-pvfb-vncdisplay.cfg  |  2 +-
 tests/xmconfigdata/test-paravirt-new-pvfb.cfg  |  2 +-
 .../test-paravirt-old-pvfb-vncdisplay.cfg  |  2 +-
 tests/xmconfigdata/test-paravirt-old-pvfb.cfg  |  2 +-
 tests/xmconfigdata/test-paravirt-vcpu.cfg  |  2 +-
 tests/xmconfigdata/test-pci-devs.cfg   |  2 +-
 35 files changed, 70 insertions(+), 59 deletions(-)

diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 071802d..215dfdc 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -2293,54 +2293,63 @@ xenFormatXMEmulatedHardware(virConfPtr conf, 
virDomainDefPtr def)
 }
 
 
-/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
-   either 32, or 64 on a platform where long is big enough.  */
-verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
-
-virConfPtr
-xenFormatXM(virConnectPtr conn,
-virDomainDefPtr def,
-int xendConfigVersion)
+int xenFormatConfigCommon(virConfPtr conf, virDomainDefPtr def,
+  virConnectPtr conn, int xendConfigVersion)
 {
-virConfPtr conf = NULL;
-
-if (!(conf = virConfNew()))
-goto cleanup;
 
 if (xenFormatXMGeneralMeta(conf, def)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMMem(conf, def)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMCPUFeatures(conf, def, xendConfigVersion)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMOS(conf, def, xendConfigVersion)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMTimeOffset(conf, def, xendConfigVersion)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMEventActions(conf, def)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMEmulatedHardware(conf, def)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMVfb(conf, def, xendConfigVersion)  0)
-goto cleanup;
-
-if (xenFormatXMDomainDisks(conf, def, xendConfigVersion)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMVif(conf, conn, def, xendConfigVersion)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMPCI(conf, def)  0)
-goto cleanup;
+return -1;
 
 if (xenFormatXMCharDev(conf, def)  0)
+return -1;
+
+return 0;
+}
+/* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
+   either 32, or 64 on a platform where long is big enough.  */
+verify(MAX_VIRT_CPUS = sizeof(1UL) * CHAR_BIT);
+
+virConfPtr
+xenFormatXM(virConnectPtr conn,
+virDomainDefPtr def,
+int xendConfigVersion)
+{
+virConfPtr conf = NULL;
+
+if (!(conf = virConfNew()))
+goto cleanup;
+
+if (xenFormatConfigCommon(conf, def, conn, xendConfigVersion)  0)
+goto cleanup;
+
+if (xenFormatXMDomainDisks(conf, def, xendConfigVersion)  0)
 goto cleanup;
 
 return conf;
diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h
index 5292396..c48fa41 100644
--- a/src/xenxs/xen_xm.h
+++ b/src/xenxs/xen_xm.h
@@ -35,7 +35,9 @@ 

Re: [libvirt] [PATCH v3 0/3] Add iSCSI hostdev pass-through device

2014-08-07 Thread John Ferlan


On 08/05/2014 04:09 PM, John Ferlan wrote:
 Patches 1  2 are related to:
 
 Update to http://www.redhat.com/archives/libvir-list/2014-July/msg01098.html
 
 Patch 1/3 is already ACK'd, but felt it was easier to push together.
 
 Patch 2/3 change since last:
   - Fix typos as called in review of 8/8
   - Adjust the rng file to 
   - Change the order of things to be source, then auth to
 follow how disk (and storage pools) do things.  That resulted
 in code motion in domain_conf.c and adjustment to the *-iscsi-auth.xml
 files 
 
 Patch 3 is related to
 http://www.redhat.com/archives/libvir-list/2014-July/msg01268.html
 
 
 John Ferlan (3):
   domain_conf: Common routine to handle network storage host xml def
   hostdev: Add iSCSI hostdev XML
   qemu: Remove extraneous space in function prototypes
 
  docs/formatdomain.html.in  | 144 ++
  docs/schemas/domaincommon.rng  |  48 +++-
  src/conf/domain_conf.c | 289 
 +++--
  src/qemu/qemu_capabilities.h   |   2 +-
  src/qemu/qemu_command.h| 136 +-
  src/qemu/qemu_conf.h   |   2 +-
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args  |  14 +
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml   |  46 
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi.args   |  14 +
  .../qemuxml2argv-hostdev-scsi-lsi-iscsi.xml|  40 +++
  ...emuxml2argv-hostdev-scsi-virtio-iscsi-auth.args |  16 ++
  ...qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml |  46 
  .../qemuxml2argv-hostdev-scsi-virtio-iscsi.args|  16 ++
  .../qemuxml2argv-hostdev-scsi-virtio-iscsi.xml |  40 +++
  tests/qemuxml2argvtest.c   |  16 ++
  tests/qemuxml2xmltest.c|   5 +
  16 files changed, 672 insertions(+), 202 deletions(-)
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi-auth.xml
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-lsi-iscsi.xml
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi-auth.xml
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.args
  create mode 100644 
 tests/qemuxml2argvdata/qemuxml2argv-hostdev-scsi-virtio-iscsi.xml
 

Thanks for the review - these are now pushed with the adjustment to the
the 2/3 commit message to indicate that protocol='adapter' is possible
on read, but just not written out or documented.

Tks,

John

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


Re: [libvirt] [PATCH 1/2] blockjob: avoid memory leak during block pivot

2014-08-07 Thread Eric Blake
On 08/07/2014 12:57 AM, Peter Krempa wrote:
 On 08/06/14 23:12, Eric Blake wrote:
 Valgrind caught a memory leak:



 I traced it to the fact that blockcopy and blockcommit end up
 reparsing a backing chain on pivot, but the chain parsing code
 doesn't gracefully handle the case where the backing file is
 already known.

 
 ACK

Pushed.

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



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

Re: [libvirt] [Qemu-devel] [PATCH v2 0/2] Add machine type pc-1.0-qemu-kvm for live migrate compatibility with qemu-kvm

2014-08-07 Thread Serge E. Hallyn
Quoting Alex Bligh (a...@alex.org.uk):
 Serge,
 
 On 7 Aug 2014, at 03:50, Serge Hallyn serge.hal...@ubuntu.com wrote:
 
  This worked for me when migrating by hand.  I'm trying to make it work
  through libvirt, using the following patch.  (So whether to have
  pc-1.0 be treated as qemu's or qemu-kvm's pc-1.0 is specifed using a
  boolean in /etc/libvirt/qemu.conf)  Qemu starts with decent
  looking args, but for some reason the the migration is failing -
  still looking through the logfile to figure out why.
 
 Are you using exactly the same arguments by hand and with libvirt?
 
 Also, on reflection, given one of the changes between 1.0 and 2.0
 is ACPI, I should probably have done some testing with an ACPI
 enabled image, rather than just cirros (which not ACPI enabled);
 any chance this is ACPI related?

A-ha, acpi wasn't a problem.  I actually had a general migration
problem even when coming from other utopic hosts.  With that fixed,
I've got successful migration from qemu-kvm 1.0 in precise to
a utopic host.

-serge

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


Re: [libvirt] [libvirt-glib] [PATCH v2 1/4] GVirDomainSnapshot: Add _get_is_current

2014-08-07 Thread Zeeshan Ali (Khattak)
On Thu, Aug 7, 2014 at 12:05 PM, Christophe Fergeau cferg...@redhat.com wrote:
 Series looks good to me apart from that naming comment in 4/4.
 If someone does not like the use of gboolean *is_current as a return
 value in
 gboolean gvir_domain_snapshot_get_is_current(GVirDomainSnapshot *snapshot,
  guint flags,
  gboolean *is_current,
  GError **error) {

 now would be a good time to complain ;)

None from me at least but I only just realized now that its not really
a simple getter (with out param and error) so I take back my
suggestion to have _get_ in the name. I don't mind it being there
though so I'll let Christophe decide. :)

-- 
Regards,

Zeeshan Ali (Khattak)

Befriend GNOME: http://www.gnome.org/friends/

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


Re: [libvirt] [PATCH] audit: Fix some comments

2014-08-07 Thread Wang Rui
On 2014/8/7 17:07, Ján Tomko wrote:
 On 08/07/2014 10:12 AM, Wang Rui wrote:
 Fix a comment in virDomainAuditNetDevice.
 Fix a typo in comment of qemuPhysIfaceConnect which is
 the caller of virDomainAuditNetDevice.

 Signed-off-by: Wang Rui moon.wang...@huawei.com
 ---
  src/conf/domain_audit.c | 4 ++--
  src/qemu/qemu_command.c | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)

 
 ACK and pushed.

Thanks.
I have a question about comment style.
I see there are two comment styles in our libvirt code.

One is
/*  
 *  
 */

The other is
/* 
 *  */

Are both of them fine ?
Or which one is recommended ?
(I'm not sure about my comments when coding.)



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