Re: [libvirt] [PATCH 1/2] cleanup conf/device_conf.h reference from util/virnetdev.h

2015-03-18 Thread Shivaprasad bhat
Hi All,

This patch needs some rework as the Makefile.am change would result in
build failures
on virhostdev.h and virclosecallbacks.h. It didnt fail for me earlier
as the autogen was run
prior to the changes.

I'll be sending a v2 with the fixes for build failures.

Thanks,
Shiva

On Wed, Mar 11, 2015 at 2:40 PM, Shivaprasad G Bhat
 wrote:
> Its wrong to reference the conf/* files from util/* files. Clean up the
> Makefile.am. Also, move the struct definitions to utils and include the util
> file in conf instead. There is a similar incorrect reference to
> domain_conf.h from virclosecallbacks.h which is to be addressed in a future
> patch.
>
> Signed-off-by: Shivaprasad G Bhat 
> ---
>  src/Makefile.am|3 +--
>  src/conf/device_conf.h |   21 +
>  src/util/virnetdev.h   |   21 -
>  3 files changed, 22 insertions(+), 23 deletions(-)
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index d38432e..85d6b44 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -1014,8 +1014,7 @@ libvirt_util_la_SOURCES =   
>   \
>  libvirt_util_la_CFLAGS = $(CAPNG_CFLAGS) $(YAJL_CFLAGS) $(LIBNL_CFLAGS) \
> $(AM_CFLAGS) $(AUDIT_CFLAGS) $(DEVMAPPER_CFLAGS) \
> $(DBUS_CFLAGS) $(LDEXP_LIBM) $(NUMACTL_CFLAGS)  \
> -   $(SYSTEMD_DAEMON_CFLAGS) $(POLKIT_CFLAGS) \
> -   -I$(srcdir)/conf
> +   $(SYSTEMD_DAEMON_CFLAGS) $(POLKIT_CFLAGS)
>  libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
> $(THREAD_LIBS) $(AUDIT_LIBS) $(DEVMAPPER_LIBS) \
> $(LIB_CLOCK_GETTIME) $(DBUS_LIBS) $(MSCOM_LIBS) 
> $(LIBXML_LIBS) \
> diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
> index 7256cdc..a650189 100644
> --- a/src/conf/device_conf.h
> +++ b/src/conf/device_conf.h
> @@ -31,19 +31,7 @@
>  # include "virutil.h"
>  # include "virthread.h"
>  # include "virbuffer.h"
> -
> -typedef enum {
> -VIR_INTERFACE_STATE_UNKNOWN = 1,
> -VIR_INTERFACE_STATE_NOT_PRESENT,
> -VIR_INTERFACE_STATE_DOWN,
> -VIR_INTERFACE_STATE_LOWER_LAYER_DOWN,
> -VIR_INTERFACE_STATE_TESTING,
> -VIR_INTERFACE_STATE_DORMANT,
> -VIR_INTERFACE_STATE_UP,
> -VIR_INTERFACE_STATE_LAST
> -} virInterfaceState;
> -
> -VIR_ENUM_DECL(virInterfaceState)
> +# include "virnetdev.h"
>
>  typedef struct _virDevicePCIAddress virDevicePCIAddress;
>  typedef virDevicePCIAddress *virDevicePCIAddressPtr;
> @@ -55,13 +43,6 @@ struct _virDevicePCIAddress {
>  int  multi;  /* virTristateSwitch */
>  };
>
> -typedef struct _virInterfaceLink virInterfaceLink;
> -typedef virInterfaceLink *virInterfaceLinkPtr;
> -struct _virInterfaceLink {
> -virInterfaceState state; /* link state */
> -unsigned int speed;  /* link speed in Mbits per second */
> -};
> -
>  int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr);
>
>  int virDevicePCIAddressParseXML(xmlNodePtr node,
> diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h
> index de8b480..42cc1f8 100644
> --- a/src/util/virnetdev.h
> +++ b/src/util/virnetdev.h
> @@ -29,7 +29,6 @@
>  # include "virnetlink.h"
>  # include "virmacaddr.h"
>  # include "virpci.h"
> -# include "device_conf.h"
>
>  # ifdef HAVE_STRUCT_IFREQ
>  typedef struct ifreq virIfreq;
> @@ -73,6 +72,26 @@ struct _virNetDevRxFilter {
>  } vlan;
>  };
>
> +typedef enum {
> +VIR_INTERFACE_STATE_UNKNOWN = 1,
> +VIR_INTERFACE_STATE_NOT_PRESENT,
> +VIR_INTERFACE_STATE_DOWN,
> +VIR_INTERFACE_STATE_LOWER_LAYER_DOWN,
> +VIR_INTERFACE_STATE_TESTING,
> +VIR_INTERFACE_STATE_DORMANT,
> +VIR_INTERFACE_STATE_UP,
> +VIR_INTERFACE_STATE_LAST
> +} virInterfaceState;
> +
> +VIR_ENUM_DECL(virInterfaceState)
> +
> +typedef struct _virInterfaceLink virInterfaceLink;
> +typedef virInterfaceLink *virInterfaceLinkPtr;
> +struct _virInterfaceLink {
> +virInterfaceState state; /* link state */
> +unsigned int speed;  /* link speed in Mbits per second */
> +};
> +
>  int virNetDevSetupControl(const char *ifname,
>virIfreq *ifr)
>  ATTRIBUTE_RETURN_CHECK;
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

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


[libvirt] [PATCH] qemu: fix sometimes error overwrite when we fail to start/migrate/restore

2015-03-18 Thread Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1196934

When start/migrate/restore a vm failed, libvirt will try to catch the log in
/var/log/libvirt/qemu/vm.log and output them before. However we add a check in
qemuDomainObjExitMonitor after commit dc2fd51f, this will overwrite
the error set in priv->mon which has set by qemuMonitorIO (a qemu monitor
I/O event callback function).

Add a check in qemuDomainObjExitMonitor, if there is an error have been
set by other function, we won't overwrite it.

Signed-off-by: Luyao Huang 
---
 src/qemu/qemu_domain.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2eacef2..41d1263 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1609,8 +1609,9 @@ int qemuDomainObjExitMonitor(virQEMUDriverPtr driver,
 {
 qemuDomainObjExitMonitorInternal(driver, obj);
 if (!virDomainObjIsActive(obj)) {
-virReportError(VIR_ERR_OPERATION_FAILED, "%s",
-   _("domain is no longer running"));
+if (!virGetLastError())
+virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+   _("domain is no longer running"));
 return -1;
 }
 return 0;
-- 
1.8.3.1

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


Re: [libvirt] [PATCH] libxl: Don't overwrite errors from xenconfig

2015-03-18 Thread Jim Fehlig
Eric Blake wrote:
> On 03/18/2015 04:21 PM, Jim Fehlig wrote:
>   
>> When converting domXML from native, the libxl driver was overwriting
>> useful errors from the xenconfig parsing code with a useless, generic
>> error.  E.g. "internal error: parsing xm config failed" vs
>> "internal error: config value usbdevice was malformed".  Remove the
>> redundant (and useless) error reporting in the libxl driver.
>>
>> Signed-off-by: Jim Fehlig 
>> ---
>>  src/libxl/libxl_driver.c | 10 ++
>>  1 file changed, 2 insertions(+), 8 deletions(-)
>> 
>
> ACK
>   

Thanks; pushed.

Regards,
Jim

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


Re: [libvirt] [PATCH] libxl: Don't overwrite errors from xenconfig

2015-03-18 Thread Eric Blake
On 03/18/2015 04:21 PM, Jim Fehlig wrote:
> When converting domXML from native, the libxl driver was overwriting
> useful errors from the xenconfig parsing code with a useless, generic
> error.  E.g. "internal error: parsing xm config failed" vs
> "internal error: config value usbdevice was malformed".  Remove the
> redundant (and useless) error reporting in the libxl driver.
> 
> Signed-off-by: Jim Fehlig 
> ---
>  src/libxl/libxl_driver.c | 10 ++
>  1 file changed, 2 insertions(+), 8 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] qemu_migration: Precreate missing storage breaks with network drives

2015-03-18 Thread Nick Bartos
Actually I messed that up slightly on the case.  My C is a bit rusty:

diff -U3 -r libvirt-1.2.13.orig/src/qemu/qemu_migration.c
libvirt-1.2.13/src/qemu/qemu_migration.c
--- libvirt-1.2.13.orig/src/qemu/qemu_migration.c 2015-02-23
22:04:12.0 -0800
+++ libvirt-1.2.13/src/qemu/qemu_migration.c 2015-03-18 13:55:45.873322477
-0700
@@ -1507,9 +1507,12 @@
 flags |= VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA;
 break;

+case VIR_STORAGE_TYPE_NETWORK:
+ret = 0;
+goto cleanup;
+break;
 case VIR_STORAGE_TYPE_BLOCK:
 case VIR_STORAGE_TYPE_DIR:
-case VIR_STORAGE_TYPE_NETWORK:
 case VIR_STORAGE_TYPE_NONE:
 case VIR_STORAGE_TYPE_LAST:
 virReportError(VIR_ERR_INTERNAL_ERROR,


On Wed, Mar 18, 2015 at 1:42 PM, Noel Burton-Krahn 
wrote:

> Hi Michal,
>
> We're testing libvirt-1.2.13 and found it failed to live migrate domains
> with attached network drives.  The change to libvirt was made in commit
> cf54c606, announced here:
> https://www.redhat.com/archives/libvir-list/2014-November/msg01053.html
>
> It's not necessary to precreate network drives.  They're created during
> nova live migration in openstack.  How about this patch?
>
>
> diff -U3 -r libvirt-1.2.13.orig/src/qemu/qemu_migration.c
> libvirt-1.2.13/src/qemu/qemu_migration.c
> --- libvirt-1.2.13.orig/src/qemu/qemu_migration.c 2015-02-23
> 22:04:12.0 -0800
> +++ libvirt-1.2.13/src/qemu/qemu_migration.c 2015-03-18
> 12:18:14.137990147 -0700
> @@ -1510,6 +1510,9 @@
>  case VIR_STORAGE_TYPE_BLOCK:
>  case VIR_STORAGE_TYPE_DIR:
>  case VIR_STORAGE_TYPE_NETWORK:
> +ret = 0;
> +goto cleanup;
> +break;
>  case VIR_STORAGE_TYPE_NONE:
>  case VIR_STORAGE_TYPE_LAST:
>  virReportError(VIR_ERR_INTERNAL_ERROR,
>
>
>
> Cheers,
> --
> Noel Burton-Krahn
> Sr, Distributed Systems Engineer
> Piston Cloud Computing
>
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] libxl: use xenlight pkgconfig file if present

2015-03-18 Thread Jim Fehlig
xen.git commit babeca32 added a pkgconfig file for libxenlight,
allowing libxl apps to determine the location of Xen binaries
such as firmware blobs, device emulator, etc.

This patch adds support for xenlight.pc in the libxl driver, falling
back to the previous configure logic if not found.  It introduces
LIBXL_FIRMWARE_DIR and LIBXL_EXECBIN_DIR to define the firmware and
libexec_bin locations.  If xenlight.pc does not exist, the defines
are set to the current hardcoded paths.  The capabilities'
 and  elements are updated to use the paths.

Signed-off-by: Jim Fehlig 
---
 configure.ac   | 47 +--
 src/libxl/libxl_conf.c |  7 ++-
 src/libxl/libxl_conf.h |  8 
 3 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index 412a23d..b1193a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -873,24 +873,37 @@ old_LIBS="$LIBS"
 old_CFLAGS="$CFLAGS"
 LIBXL_LIBS=""
 LIBXL_CFLAGS=""
+LIBXL_FIRMWARE_DIR=""
+LIBXL_EXECBIN_DIR=""
+
 dnl search for libxl, aka libxenlight
+dnl Xen > 4.5 introduced a pkgconfig file, check for it first
 fail=0
 if test "$with_libxl" != "no" ; then
-if test "$with_libxl" != "yes" && test "$with_libxl" != "check" ; then
-LIBXL_CFLAGS="-I$with_libxl/include"
-LIBXL_LIBS="-L$with_libxl"
-fi
-CFLAGS="$CFLAGS $LIBXL_CFLAGS"
-LIBS="$LIBS $LIBXL_LIBS"
-AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
-with_libxl=yes
-LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl"
-],[
-if test "$with_libxl" = "yes"; then
-fail=1
+PKG_CHECK_MODULES([LIBXL], [xenlight], [
+ LIBXL_FIRMWARE_DIR=`$PKG_CONFIG --variable xenfirmwaredir xenlight`
+ LIBXL_EXECBIN_DIR=`$PKG_CONFIG --variable libexec_bin xenlight`
+ LIBXL_LIBS="$LIBXL_LIBS -lxenctrl"
+ with_libxl=yes
+], [LIBXL_FOUND=no])
+if test "$LIBXL_FOUND" = "no"; then
+dnl No xenlight pkg-config file
+if test "$with_libxl" != "yes" && test "$with_libxl" != "check" ; then
+LIBXL_CFLAGS="-I$with_libxl/include"
+LIBXL_LIBS="-L$with_libxl"
 fi
-with_libxl=no
-])
+CFLAGS="$CFLAGS $LIBXL_CFLAGS"
+LIBS="$LIBS $LIBXL_LIBS"
+AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
+with_libxl=yes
+LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl"
+],[
+if test "$with_libxl" = "yes"; then
+fail=1
+fi
+with_libxl=no
+])
+fi
 fi
 
 LIBS="$old_LIBS"
@@ -905,6 +918,12 @@ if test "$with_libxl" = "yes"; then
 AC_CHECK_HEADERS([libxlutil.h])
 LIBXL_LIBS="$LIBXL_LIBS -lxlutil"
 AC_DEFINE_UNQUOTED([WITH_LIBXL], 1, [whether libxenlight driver is 
enabled])
+if test "x$LIBXL_FIRMWARE_DIR" != "x"; then
+AC_DEFINE_UNQUOTED([LIBXL_FIRMWARE_DIR], ["$LIBXL_FIRMWARE_DIR"], 
[directory containing Xen firmware blobs])
+fi
+if test "x$LIBXL_EXECBIN_DIR" != "x"; then
+AC_DEFINE_UNQUOTED([LIBXL_EXECBIN_DIR], ["$LIBXL_EXECBIN_DIR"], 
[directory containing Xen libexec binaries])
+fi
 fi
 AM_CONDITIONAL([WITH_LIBXL], [test "$with_libxl" = "yes"])
 
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 80dd5a8..9b3c949 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -305,7 +305,6 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
 regmatch_t subs[4];
 char *saveptr = NULL;
 size_t i;
-virArch hostarch = caps->host.arch;
 
 struct guest_arch guest_archs[32];
 int nr_guest_archs = 0;
@@ -428,11 +427,9 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
 if ((guest = virCapabilitiesAddGuest(caps,
  guest_archs[i].hvm ? "hvm" : 
"xen",
  guest_archs[i].arch,
- ((hostarch == VIR_ARCH_X86_64) ?
-  "/usr/lib64/xen/bin/qemu-dm" :
-  "/usr/lib/xen/bin/qemu-dm"),
+ LIBXL_EXECBIN_DIR 
"/qemu-system-i386",
  (guest_archs[i].hvm ?
-  "/usr/lib/xen/boot/hvmloader" :
+  LIBXL_FIRMWARE_DIR "/hvmloader" :
   NULL),
  1,
  machines)) == NULL) {
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 5d6f87d..59389d1 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -55,6 +55,14 @@
 # define LIBXL_DUMP_DIR LIBXL_LIB_DIR "/dump"
 # define LIBXL_BOOTLOADER_PATH "pygrub"
 
+# ifndef LIBXL_FIRMWARE_DIR
+#  define LIBXL_FIRMWARE_DIR "/usr/lib/xen/boot"
+# endif
+# ifndef LIBXL_EXECBIN_DIR
+#  define LIBXL_E

[libvirt] [PATCH] libxl: Don't overwrite errors from xenconfig

2015-03-18 Thread Jim Fehlig
When converting domXML from native, the libxl driver was overwriting
useful errors from the xenconfig parsing code with a useless, generic
error.  E.g. "internal error: parsing xm config failed" vs
"internal error: config value usbdevice was malformed".  Remove the
redundant (and useless) error reporting in the libxl driver.

Signed-off-by: Jim Fehlig 
---
 src/libxl/libxl_driver.c | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index e555ca4..1c1af79 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -,22 +,16 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
 goto cleanup;
 if (!(def = xenParseXL(conf,
cfg->caps,
-   cfg->verInfo->xen_version_major))) {
-virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-   _("parsing xl config failed"));
+   cfg->verInfo->xen_version_major)))
 goto cleanup;
-}
 } else if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) {
 if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0)))
 goto cleanup;
 
 if (!(def = xenParseXM(conf,
cfg->verInfo->xen_version_major,
-   cfg->caps))) {
-virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-   _("parsing xm config failed"));
+   cfg->caps)))
 goto cleanup;
-}
 } else if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_SEXPR)) {
 /* only support latest xend config format */
 if (!(def = xenParseSxprString(nativeConfig,
-- 
1.8.4.5

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


Re: [libvirt] [PATCH] Add vircgroupdata dir to tests/Makefile.am

2015-03-18 Thread Eric Blake
On 03/18/2015 08:04 AM, Nehal J Wani wrote:
> The folder vircgroupdata was introduced in commit 2dbfa716 as part of
> the test suite for virCgroupDetectMounts
> 
> ---
>  tests/Makefile.am | 1 +
>  1 file changed, 1 insertion(+)

NACK; it was already added several lines later (after
virsh-uriprecedence) in commit 9c23b32.


> 
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 9277c13..27cee63 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -128,6 +128,7 @@ EXTRA_DIST =  \
>   storagevolxml2xmlout \
>   sysinfodata \
>   test-lib.sh \
> + vircgroupdata \
>   vircaps2xmldata \
>   vboxsnapshotxmldata \
>   virsh-uriprecedence \
> 

-- 
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 v2] doc: Fix doc for backingStore

2015-03-18 Thread Eric Blake
On 03/18/2015 07:48 AM, Deepak Shetty wrote:
> I spent quite some time figuring that backingStore info
> isn't included in the dom xml, unless guest is up and
> running. Hopefully putting that in the doc should help.
> 
> This patch adds that info to the doc.
> 
> Signed-off-by: Deepak C Shetty 
> ---
>  docs/formatdomain.html.in | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

I hope you don't mind that I took liberty with your wording, and added
myself as a second signoff.  Here's the text that I committed:

This element describes the backing store used by the disk
specified by sibling source element. It is
currently ignored on input and only used for output to
describe the detected backing chains of running
domains since 1.2.4 (although a
future version of libvirt may start accepting chains on input,
or output information for offline domains). An empty
backingStore element means the sibling source is
self-contained and is not based on any backing store. For
backing chain information to be accurate, the backing format
must be correctly specified in the metadata of each file of
the chain (files created by libvirt satisfy this property, but
using existing external files for snapshot or block copy
operations requires the end user to pre-create the file
correctly). The following attributes and sub-elements are
supported in backingStore:

-- 
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] qemu: track 'cancelling' migration state

2015-03-18 Thread Eric Blake
On 03/09/2015 03:07 AM, Jiri Denemark wrote:
> On Fri, Mar 06, 2015 at 09:34:59 -0700, Eric Blake wrote:
>> In qemu 2.3, the migration status will include 'cancelling' in the
>> window between when an asynchronous cancel has been requested and
>> when the migration is actually halted.  Previously, qemu hid this
>> state and reported 'active'.  Libvirt manages the sequence okay
>> even when the string is unrecognized (that is, it will report an
>> unknown state:
>>
>> Migration: [ 69 %]^Cerror: internal error: unexpected migration status in 
>> cancelling.
>>
>> but the migration is still cancelled), but recognizing the string
>> makes for a smoother user experience.
> 
> ACK once the change is merged to QEMU.

qemu commit cde63fbe, so I'm now pushing this to libvirt.

-- 
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] qemu_migration: Precreate missing storage breaks with network drives

2015-03-18 Thread Noel Burton-Krahn
Hi Michal,

We're testing libvirt-1.2.13 and found it failed to live migrate domains
with attached network drives.  The change to libvirt was made in commit
cf54c606, announced here:
https://www.redhat.com/archives/libvir-list/2014-November/msg01053.html

It's not necessary to precreate network drives.  They're created during
nova live migration in openstack.  How about this patch?


diff -U3 -r libvirt-1.2.13.orig/src/qemu/qemu_migration.c
libvirt-1.2.13/src/qemu/qemu_migration.c
--- libvirt-1.2.13.orig/src/qemu/qemu_migration.c 2015-02-23
22:04:12.0 -0800
+++ libvirt-1.2.13/src/qemu/qemu_migration.c 2015-03-18 12:18:14.137990147
-0700
@@ -1510,6 +1510,9 @@
 case VIR_STORAGE_TYPE_BLOCK:
 case VIR_STORAGE_TYPE_DIR:
 case VIR_STORAGE_TYPE_NETWORK:
+ret = 0;
+goto cleanup;
+break;
 case VIR_STORAGE_TYPE_NONE:
 case VIR_STORAGE_TYPE_LAST:
 virReportError(VIR_ERR_INTERNAL_ERROR,



Cheers,
--
Noel Burton-Krahn
Sr, Distributed Systems Engineer
Piston Cloud Computing
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [libvirt-cmdref PATCH] Adding Documentation for cd

2015-03-18 Thread Swaathi Ramesh
The documentation for command cd did not have information about the command. 
Added the required information.
---
 source/cd.xml | 38 ++
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/source/cd.xml b/source/cd.xml
index 78a13df..d15c74c 100644
--- a/source/cd.xml
+++ b/source/cd.xml
@@ -9,16 +9,46 @@
 
   
 
-  
+  
+   
+ --dir
+ path
+ 
+
+  directory to switch to (default: home or else root)
+   
+   
+ --dir itself is optional
+   
+   
+
+  
 
   
  
   
  
-  
+  
+   
+
+virsh #  cd  /tmp 
+
+   Changes the current working directory to  /tmp 
+
+   
+  
 
   
 
-  
-
+  
+   
+
+
+pwd
+
+
+Displays the current directory
+
+   
+  
 
-- 
1.9.1

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


Re: [libvirt] [PATCH] util: more verbose error when failing to create macvtap device

2015-03-18 Thread Michal Privoznik
On 18.03.2015 19:30, Laine Stump wrote:
> Investigation of a problem with creating passthrough macvtap devices
> (https://bugzilla.redhat.com/show_bug.cgi?id=1185501) has shown that
> this slightly more verbose failure message is useful. In particular,
> the mac address can be used to determine the domain. You could also
> figure this out by looking at preceding messages in a debug log, but
> this gets it in a single place.
> ---
>  src/util/virnetdevmacvlan.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
> index dd66955..5fd2097 100644
> --- a/src/util/virnetdevmacvlan.c
> +++ b/src/util/virnetdevmacvlan.c
> @@ -107,6 +107,7 @@ virNetDevMacVLanCreate(const char *ifname,
>  unsigned int recvbuflen;
>  struct nl_msg *nl_msg;
>  struct nlattr *linkinfo, *info_data;
> +char macstr[VIR_MAC_STRING_BUFLEN];
>  
>  if (virNetDevGetIndex(srcdev, &ifindex) < 0)
>  return -1;
> @@ -177,8 +178,9 @@ virNetDevMacVLanCreate(const char *ifname,
>  
>  default:
>  virReportSystemError(-err->error,
> - _("error creating %s type of interface 
> attach to %s"),
> - type, srcdev);
> + _("error creating %s interface %s@%s (%s)"),
> + type, ifname, srcdev,
> + virMacAddrFormat(macaddress, macstr));
>  goto cleanup;
>  }
>  break;
> 

ACK

Michal

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


[libvirt] [PATCH] util: more verbose error when failing to create macvtap device

2015-03-18 Thread Laine Stump
Investigation of a problem with creating passthrough macvtap devices
(https://bugzilla.redhat.com/show_bug.cgi?id=1185501) has shown that
this slightly more verbose failure message is useful. In particular,
the mac address can be used to determine the domain. You could also
figure this out by looking at preceding messages in a debug log, but
this gets it in a single place.
---
 src/util/virnetdevmacvlan.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index dd66955..5fd2097 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -107,6 +107,7 @@ virNetDevMacVLanCreate(const char *ifname,
 unsigned int recvbuflen;
 struct nl_msg *nl_msg;
 struct nlattr *linkinfo, *info_data;
+char macstr[VIR_MAC_STRING_BUFLEN];
 
 if (virNetDevGetIndex(srcdev, &ifindex) < 0)
 return -1;
@@ -177,8 +178,9 @@ virNetDevMacVLanCreate(const char *ifname,
 
 default:
 virReportSystemError(-err->error,
- _("error creating %s type of interface attach 
to %s"),
- type, srcdev);
+ _("error creating %s interface %s@%s (%s)"),
+ type, ifname, srcdev,
+ virMacAddrFormat(macaddress, macstr));
 goto cleanup;
 }
 break;
-- 
2.1.0

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


Re: [libvirt] [PATCH] util: vhost user: support for bootindex

2015-03-18 Thread Michal Privoznik
On 13.03.2015 10:17, zhang bo wrote:
> Problem Description:
> When we set boot order for a vhost-user network interface, we found the boot 
> index
> doesn't work.
> 
> Cause of the Problem:
> In the function qemuBuildVhostuserCommandLine(), it forcely set the arg 
> bootindex of
> function qemuBuildNicDevStr() to 0. Thus, the bootindex parameter got missing.
> 
> Solution:
> Trans the arg bootindex down.
> 
> Signed-off-by: Gao Haifeng 
> Signed-off-by: Zhang Bo 
> ---
>  src/qemu/qemu_command.c | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 5303de5..2f37812 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -7767,7 +7767,8 @@ static int
>  qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>virDomainDefPtr def,
>virDomainNetDefPtr net,
> -  virQEMUCapsPtr qemuCaps)
> +  virQEMUCapsPtr qemuCaps,
> +  int bootindex)
>  {
>  virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
>  virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
> @@ -7814,7 +7815,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>  virCommandAddArg(cmd, "-netdev");
>  virCommandAddArgBuffer(cmd, &netdev_buf);
> 
> -if (!(nic = qemuBuildNicDevStr(def, net, -1, 0, 0, qemuCaps))) {
> +if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex, 0, qemuCaps))) {
>  virReportError(VIR_ERR_INTERNAL_ERROR,
> "%s", _("Error generating NIC -device string"));
>  goto error;
> @@ -7859,8 +7860,12 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
>  virNetDevBandwidthPtr actualBandwidth;
>  size_t i;
> 
> +
> +if (!bootindex)
> +bootindex = net->info.bootIndex;
> +
>  if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER)
> -return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps);
> +return qemuBuildVhostuserCommandLine(cmd, def, net, qemuCaps, 
> bootindex);
> 
>  if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
>  /* NET_TYPE_HOSTDEV devices are really hostdev devices, so
> @@ -7869,9 +7874,6 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
>  return 0;
>  }
> 
> -if (!bootindex)
> -bootindex = net->info.bootIndex;
> -
>  /* Currently nothing besides TAP devices supports multiqueue. */
>  if (net->driver.virtio.queues > 0 &&
>  !(actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
> 

ACKed and pushed.

Michal

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


Re: [libvirt] [PATCH v4 0/7] bridge network support enhancement and other network fixes

2015-03-18 Thread Maxim Nestratov

18.03.2015 20:34, Michal Privoznik пишет:

I've fixed all the nits I've found, ACKed and pushed whole series.


Thank you!


One more thing though, look at the rest of our commit messages. They
usually consist of small subject, and start freshly with new sentence.
For some reason we don't like if the sentence form subject continues at
the start of commit message.

Michal

Sure. Will do next time.

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

Re: [libvirt] [PATCH v4 3/7] parallels: better bridge network interface support

2015-03-18 Thread Michal Privoznik
On 18.03.2015 09:33, Maxim Nestratov wrote:
> In order to support 'bridge' network adapters in parallels
> driver we need to plug our veth devices into corresponding
> linux bridges.
> We are going to do this by reusing our abstraction of
> Virtual Networks in terms of PCS. On a domain creation, we
> create a new Virtual Network naming it with the same name
> as a source bridge for each network  interface.
> Having done this, we plug PCS veth interfaces created with names of
> target dev into specified bridges using our standard PCS procedures
> 
> Signed-off-by: Maxim Nestratov 
> ---
>  src/parallels/parallels_sdk.c |   99 +++-
>  1 files changed, 86 insertions(+), 13 deletions(-)
> 
> diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
> index d3fb5d4..58c52a8 100644
> --- a/src/parallels/parallels_sdk.c
> +++ b/src/parallels/parallels_sdk.c
> @@ -691,9 +691,6 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, 
> virDomainNetDefPtr net, bool isCt)
>  
>  /* use device name, shown by prlctl as target device
>   * for identifying network adapter in virDomainDefineXML */
> -pret = PrlVmDev_GetIndex(netAdapter, &netAdapterIndex);
> -prlsdkCheckRetGoto(pret, cleanup);
> -
>  pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, NULL, &buflen);
>  prlsdkCheckRetGoto(pret, cleanup);
>  
> @@ -703,6 +700,9 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, 
> virDomainNetDefPtr net, bool isCt)
>  pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net->ifname, 
> &buflen);
>  prlsdkCheckRetGoto(pret, cleanup);
>  
> +pret = PrlVmDev_GetIndex(netAdapter, &netAdapterIndex);
> +prlsdkCheckRetGoto(pret, cleanup);
> +
>  if (isCt && netAdapterIndex == (PRL_UINT32) -1) {
>  /* venet devices don't have mac address and
>   * always up */
> @@ -740,6 +740,16 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, 
> virDomainNetDefPtr net, bool isCt)
> net->data.network.name,
> &buflen);
>  prlsdkCheckRetGoto(pret, cleanup);
> +
> +/*
> + * We use VIR_DOMAIN_NET_TYPE_NETWORK for all network adapters
> + * except those whose Virtual Network Id differ from Parallels
> + * predefined ones such as PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME
> + * and PARALLELS_DONAIN_ROUTED_NETWORK_NAME
> + */
> +if (!STREQ(net->data.network.name, 
> PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME))

s/!STREQ/STRNEQ/

I'll fix that when pushing.

Michal

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


Re: [libvirt] [PATCH v4 5/7] parallels: make E1000 network adapter model default

2015-03-18 Thread Michal Privoznik
On 18.03.2015 09:33, Maxim Nestratov wrote:
> and set adapter model specified in xml
> 
> Signed-off-by: Maxim Nestratov 
> ---
>  src/parallels/parallels_driver.c |7 ++-
>  src/parallels/parallels_sdk.c|   15 +++
>  2 files changed, 21 insertions(+), 1 deletions(-)
> 
> diff --git a/src/parallels/parallels_driver.c 
> b/src/parallels/parallels_driver.c
> index 1a6d6e6..807c1b1 100644
> --- a/src/parallels/parallels_driver.c
> +++ b/src/parallels/parallels_driver.c
> @@ -168,13 +168,18 @@ parallelsDomainDefPostParse(virDomainDefPtr def 
> ATTRIBUTE_UNUSED,
>  return 0;
>  }
>  
> -
>  static int
>  parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,

@dev is now clearly used.

>const virDomainDef *def ATTRIBUTE_UNUSED,
>virCapsPtr caps ATTRIBUTE_UNUSED,
>void *opaque ATTRIBUTE_UNUSED)
>  {
> +if (dev->type == VIR_DOMAIN_DEVICE_NET &&
> +(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
> +dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
> +!dev->data.net->model)
> +return VIR_STRDUP(dev->data.net->model, "e1000");
> +
>  return 0;
>  }
>  
> diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
> index d699613..8deebd4 100644
> --- a/src/parallels/parallels_sdk.c
> +++ b/src/parallels/parallels_sdk.c
> @@ -2672,6 +2672,21 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
> parallelsConnPtr privconn, virDomainN
>  pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
>  prlsdkCheckRetGoto(pret, cleanup);
>  
> +if (STREQ(net->model, "rtl8139"))
> +pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
> +else if (STREQ(net->model, "e1000"))
> +pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
> +else if (STREQ(net->model, "virtio"))
> +pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
> +else {

We have this rule, that if one arm of if-else is in curly braces, the
other one has to be too. Even if it is a oneliner.

> +

Whitespace.

> +virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +   _("Specified network adapter model is not "
> + "supported by Parallels Cloud Server."));
> +goto cleanup;
> +}
> +prlsdkCheckRetGoto(pret, cleanup);
> +

Awesome! The code is much cleaner now.

Michal

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


Re: [libvirt] [PATCH v4 0/7] bridge network support enhancement and other network fixes

2015-03-18 Thread Michal Privoznik
On 18.03.2015 09:33, Maxim Nestratov wrote:
> v2-v4 change:
>   Addressed Michal Privoznik's comments
>  
> 
> Maxim Nestratov (7):
>   parallels: introduce and use string constants for network types and
> names
>   parallels: fix parallelsLoadNetworks
>   parallels: better bridge network interface support
>   parallels: set correct network adapter device state
>   parallels: make E1000 network adapter model default
>   parallels: switch off offline management feature
>   parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE
> 

I've fixed all the nits I've found, ACKed and pushed whole series.

One more thing though, look at the rest of our commit messages. They
usually consist of small subject, and start freshly with new sentence.
For some reason we don't like if the sentence form subject continues at
the start of commit message.

Michal

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


Re: [libvirt] [PATCH v4 4/7] parallels: set correct network adapter device state

2015-03-18 Thread Michal Privoznik
On 18.03.2015 09:33, Maxim Nestratov wrote:
> when a new network adapter device is added

s/device/link/ in $SUBJ.
> 
> Signed-off-by: Maxim Nestratov 
> ---
>  src/parallels/parallels_sdk.c |4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
> index 58c52a8..d699613 100644
> --- a/src/parallels/parallels_sdk.c
> +++ b/src/parallels/parallels_sdk.c
> @@ -2658,7 +2658,9 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
> parallelsConnPtr privconn, virDomainN
>  pret = PrlVmDev_SetEnabled(sdknet, 1);
>  prlsdkCheckRetGoto(pret, cleanup);
>  
> -pret = PrlVmDev_SetConnected(sdknet, net->linkstate);
> +pret = PrlVmDev_SetConnected(sdknet, net->linkstate !=
> + VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN);
> +
>  prlsdkCheckRetGoto(pret, cleanup);
>  
>  if (net->ifname) {
> 

Michal

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


Re: [libvirt] [PATCH v4 2/7] parallels: fix parallelsLoadNetworks

2015-03-18 Thread Michal Privoznik
On 18.03.2015 09:33, Maxim Nestratov wrote:
> Don't fail initialization of parallels driver if
> parallelsLoadNetwork fails for optional networks.
> This can happen when some of them are added manually
> and configured incompletely. PCS requires only two networks
> created automatically (named Host-Only and Bridged), others
> are optional and their incompletenes can be ignored.

s/incompletenes/incompleteness/

> 
> Signed-off-by: Maxim Nestratov 
> ---
>  src/parallels/parallels_network.c |   43 +++-
>  1 files changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/src/parallels/parallels_network.c 
> b/src/parallels/parallels_network.c
> index bb7ec5e..1d0ee1c 100644
> --- a/src/parallels/parallels_network.c
> +++ b/src/parallels/parallels_network.c
> @@ -180,9 +180,10 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr 
> def, const char *name)
>  return ret;
>  }
>  
> -static virNetworkObjPtr
> +static int
>  parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
>  {
> +int ret = -1;
>  virNetworkObjPtr net;
>  virNetworkDefPtr def;
>  const char *tmp;
> @@ -214,13 +215,25 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
> virJSONValuePtr jobj)
>  if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
>  def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
>  
> -if (parallelsGetBridgedNetInfo(def, jobj) < 0)
> +if (parallelsGetBridgedNetInfo(def, jobj) < 0) {
> +
> +/* Only mandatory networks are required to be configured 
> completely */
> +if (STRNEQ(def->name, PARALLELS_REQUIRED_BRIDGED_NETWORK))
> +ret = 0;
> +
>  goto cleanup;
> +}
>  } else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
>  def->forward.type = VIR_NETWORK_FORWARD_NONE;
>  
> -if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
> +if (parallelsGetHostOnlyNetInfo(def, def->name) < 0) {
> +
> +/* Only mandatory networks are required to be configured 
> completely */
> +if (STRNEQ(def->name, PARALLELS_REQUIRED_HOSTONLY_NETWORK))
> +ret = 0;
> +
>  goto cleanup;
> +}
>  } else {
>  parallelsParseError();
>  goto cleanup;
> @@ -230,14 +243,16 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
> virJSONValuePtr jobj)
>  goto cleanup;
>  net->active = 1;
>  net->autostart = 1;
> -return net;
> +virNetworkObjEndAPI(&net);
> +ret = 0;
> +def = NULL;

So if everything goes well, zero is returned ...

>  
>   cleanup:
>  virNetworkDefFree(def);
> -return NULL;
> +return ret;
>  }
>  
> -static virNetworkObjPtr
> +static int
>  parallelsAddRoutedNetwork(parallelsConnPtr privconn)
>  {
>  virNetworkObjPtr net = NULL;
> @@ -264,18 +279,18 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
>  }
>  net->active = 1;
>  net->autostart = 1;
> +virNetworkObjEndAPI(&net);
>  
> -return net;
> +return 0;
>  
>   cleanup:
>  virNetworkDefFree(def);

OUCH! Not to be seen in this context, but if virNetworkAssignDef() called a few 
lines above fails, it'll call virNetworkDefFree() and goto 'cleanup' 
subsequently where @def is freed the second time.

> -return NULL;
> +return -1;
>  }
>  
>  static int parallelsLoadNetworks(parallelsConnPtr privconn)
>  {
>  virJSONValuePtr jobj, jobj2;
> -virNetworkObjPtr net = NULL;
>  int ret = -1;
>  int count;
>  size_t i;
> @@ -300,22 +315,18 @@ static int parallelsLoadNetworks(parallelsConnPtr 
> privconn)
>  goto cleanup;
>  }
>  
> -net = parallelsLoadNetwork(privconn, jobj2);
> -if (!net)
> +ret = parallelsLoadNetwork(privconn, jobj2);
> +if (!ret)

... so this should have been (ret) instead of (!ret).

>  goto cleanup;
> -else
> -virNetworkObjEndAPI(&net);
> -
>  }
>  
> -if (!(net = parallelsAddRoutedNetwork(privconn)))
> +if (!(ret = parallelsAddRoutedNetwork(privconn)))

Again, parallelsAddRoutedNetwork() returns zero on success.

>  goto cleanup;
>  
>  ret = 0;
>  
>   cleanup:
>  virJSONValueFree(jobj);
> -virNetworkObjEndAPI(&net);
>  return ret;
>  }
>  
> 

I'm squashing this in:

diff --git a/src/parallels/parallels_network.c 
b/src/parallels/parallels_network.c
index 1d0ee1c..8cc0582 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -184,7 +184,7 @@ static int
 parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
 {
 int ret = -1;
-virNetworkObjPtr net;
+virNetworkObjPtr net = NULL;
 virNetworkDefPtr def;
 const char *tmp;
 /* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */
@@ -241,13 +241,13 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 
 if (!(net = virNetworkAssignDef(privconn->networks, def, fal

Re: [libvirt] Domain XML isn't dumping full backing chain

2015-03-18 Thread Kashyap Chamarthy
On Wed, Mar 18, 2015 at 07:21:22AM -0600, Eric Blake wrote:
> On 03/18/2015 07:03 AM, Deepak Shetty wrote:
> 
> [please don't top-post on technical lists]
> 
> > Hmm interesting, so without adding backing_fmt, if i enable the below in
> > /etc/libvirt/qemu.conf, will it work ?
> > 
> > # If allow_disk_format_probing is enabled, libvirt will probe disk
> > # images to attempt to identify their format, when not otherwise
> > # specified in the XML. This is disabled by default.
> > #
> > # WARNING: Enabling probing is a security hole in almost all
> > # deployments. It is strongly recommended that users update their
> > # guest XML  elements to include  
> > # elements instead of enabling this option.
> > #
> > #allow_disk_format_probing = 1

Along with what Eric says, here's some detailed description of issues
(that are fixed) from Daniel Berrange:

https://www.redhat.com/archives/libvir-list/2010-July/msg00221.html
 
> It _might_ work in that libvirt will then probe the backing chain as
> qcow2, rather than treating it as raw; on the other hand, the upcoming
> qemu 2.3 is trying to deprecate probing altogether because of the
> security problems it represented, and so you may reach a point where
> even if you tell libvirt it is okay to probe, that qemu will refuse to
> open your image if you didn't specify backing format.

-- 
/kashyap

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


[libvirt] [PATCH] maint: Distribute tests/vircgroupdata

2015-03-18 Thread Jiri Denemark
My commit 2dbfa71 added test data for vircgrouptest but forgot to
distribute the new directory.

Signed-off-by: Jiri Denemark 
---

Pushed as a build-breaker.

 tests/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9277c13..bd2ea16 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -131,6 +131,7 @@ EXTRA_DIST =\
vircaps2xmldata \
vboxsnapshotxmldata \
virsh-uriprecedence \
+   vircgroupdata \
virfiledata \
virpcitestdata \
virscsidata \
-- 
2.3.3

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


[libvirt] [PATCH] Add vircgroupdata dir to tests/Makefile.am

2015-03-18 Thread Nehal J Wani
The folder vircgroupdata was introduced in commit 2dbfa716 as part of
the test suite for virCgroupDetectMounts

---
 tests/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9277c13..27cee63 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -128,6 +128,7 @@ EXTRA_DIST =\
storagevolxml2xmlout \
sysinfodata \
test-lib.sh \
+   vircgroupdata \
vircaps2xmldata \
vboxsnapshotxmldata \
virsh-uriprecedence \
-- 
2.1.0

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


Re: [libvirt] [PATCH 7/7] parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

2015-03-18 Thread Dmitry Guryanov

On 03/17/2015 05:14 PM, Michal Privoznik wrote:

On 13.03.2015 16:52, Maxim Nestratov wrote:

network adapter is used
---
  src/parallels/parallels_sdk.c |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index a0a2ba0..4c90a18 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2246,7 +2246,8 @@ static int 
prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr)
  
  static int prlsdkCheckNetUnsupportedParams(virDomainNetDefPtr net)

  {
-if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
+if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK &&
+net->type != VIR_DOMAIN_NET_TYPE_BRIDGE) {
  virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
 _("Specified network adapter type is not "
   "supported by Parallels Cloud Server."));


I really, really hate how the whole 'is this configuration supported'
thing is handled in parallels. Instead of enumerating what it does not
know, it should do it the other way round. Do a positive checking, if
configuration is supported. Then, even if we introduce yet another
device, or device attribute in other hypervisors, we don't need to
update parallels driver (which we permanently keep forgetting about).


I also don't like, that this function will fail, if some unsupported 
option is provided. It was long time ago when Peter told me, that I 
should report error, if there are some unsupported parameters: 
https://www.redhat.com/archives/libvir-list/2012-July/msg00602.html.


It should be possible to define a domain if some unsupported parameters 
are provided, which wouldn't affect domain behaviour very much.



ACK though.

Michal

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



--
Dmitry Guryanov

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


Re: [libvirt] Domain XML isn't dumping full backing chain

2015-03-18 Thread Eric Blake
On 03/18/2015 07:03 AM, Deepak Shetty wrote:

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

> Hmm interesting, so without adding backing_fmt, if i enable the below in
> /etc/libvirt/qemu.conf, will it work ?
> 
> # If allow_disk_format_probing is enabled, libvirt will probe disk
> # images to attempt to identify their format, when not otherwise
> # specified in the XML. This is disabled by default.
> #
> # WARNING: Enabling probing is a security hole in almost all
> # deployments. It is strongly recommended that users update their
> # guest XML  elements to include  
> # elements instead of enabling this option.
> #
> #allow_disk_format_probing = 1

It _might_ work in that libvirt will then probe the backing chain as
qcow2, rather than treating it as raw; on the other hand, the upcoming
qemu 2.3 is trying to deprecate probing altogether because of the
security problems it represented, and so you may reach a point where
even if you tell libvirt it is okay to probe, that qemu will refuse to
open your image if you didn't specify backing format.

-- 
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] Domain XML isn't dumping full backing chain

2015-03-18 Thread Deepak Shetty
Hmm interesting, so without adding backing_fmt, if i enable the below in
/etc/libvirt/qemu.conf, will it work ?

# If allow_disk_format_probing is enabled, libvirt will probe disk
# images to attempt to identify their format, when not otherwise
# specified in the XML. This is disabled by default.
#
# WARNING: Enabling probing is a security hole in almost all
# deployments. It is strongly recommended that users update their
# guest XML  elements to include  
# elements instead of enabling this option.
#
#allow_disk_format_probing = 1


On Wed, Mar 18, 2015 at 5:33 PM, Shanzhi Yu  wrote:

>
>
> --
>
> *From: *"Deepak Shetty" 
> *To: *libvir-list@redhat.com
> *Sent: *Wednesday, March 18, 2015 7:19:05 PM
> *Subject: *[libvirt] Domain XML isn't dumping full backing chain
>
>
> Hi,
> I am using libvirt version 1.2.9.2 on F21 and i am unable to get the
> complete backing chain info in the virsh dumpxml output. Details below :
>
> *My backing chain per qemu-img :*
>
> [stack@devstack-f21 test]$ qemu-img info --backing-chain snap4.qcow2
> image: snap4.qcow2
> file format: qcow2
> virtual size: 1.0G (1073741824 bytes)
> disk size: 196K
> cluster_size: 65536
> backing file: ./snap3.qcow2
> Format specific information:
> compat: 1.1
> lazy refcounts: false
>
> image: ./snap3.qcow2
> file format: qcow2
> virtual size: 1.0G (1073741824 bytes)
> disk size: 196K
> cluster_size: 65536
> backing file: ./snap2.qcow2 (actual path: ././snap2.qcow2)
> Format specific information:
> compat: 1.1
> lazy refcounts: false
>
> image: ././snap2.qcow2
> file format: qcow2
> virtual size: 1.0G (1073741824 bytes)
> disk size: 196K
> cluster_size: 65536
> backing file: ./snap1.qcow2 (actual path: ./././snap1.qcow2)
> Format specific information:
> compat: 1.1
> lazy refcounts: false
>
> image: ./././snap1.qcow2
> file format: qcow2
> virtual size: 1.0G (1073741824 bytes)
> disk size: 196K
> cluster_size: 65536
> backing file: ./base.qcow2 (actual path: ././././base.qcow2)
> Format specific information:
> compat: 1.1
> lazy refcounts: false
>
> image: ././././base.qcow2
> file format: qcow2
> virtual size: 1.0G (1073741824 bytes)
> disk size: 196K
> cluster_size: 65536
> Format specific information:
> compat: 1.1
> lazy refcounts: false
>
> If you want prepare the backing chain yourself, you should  add "-o
> backing_fmt=$farmat" options,
> like "qemu-img create -f qcow2 base.s1 -b base.qcow2 -o backing_fmt=qcow2"
>
> I created 4 snapshots using commands (similar to the below, just dumping
> the last one here ):
>
> [stack@devstack-f21 test]$ virsh snapshot-create-as test-domain
> on-test-snap4  --disk-only --reuse-external --diskspec
> hda,snapshot=external,file=/home/stack/test/snap4.qcow2
> Domain snapshot on-test-snap4 created
>
> [stack@devstack-f21 test]$ virsh domblklist test-domain
> Target Source
> 
> hda/home/stack/test/snap4.qcow2
>
>
>
> virsh dumpxml test-domain|more
> 
>
> 
>   
>   
>   
> 
>
> If you don't add "-o backing_fmt=qcow2", it will treat backing file format
> as raw format.
> Since a raw format file doesn't have a backing file, so you only see
> snap4.qcow2 and
> snap3.qcow2
>
>
> 
> 
>   
>   
>   
>   
> 
>
>
> .
>
> I think thats happening beccause the backingStore format is coming as 'raw'
> What am i missing ?
>
> thanx,
> deepak
>
>
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
>
>
>
> --
> Regards
> shyu
>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] doc: Fix doc for backingStore

2015-03-18 Thread Eric Blake
On 03/18/2015 03:47 AM, Deepak Shetty wrote:
> I spent quite some time figuring that backingStore info
> isn't included in the dom xml, unless guest is up and
> running. Hopefully putting that in the doc should help.
> 
> This patch adds that info to the doc.
> 
> Signed-off-by: Deepak C Shetty 
> ---
>  docs/formatdomain.html.in | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index ab51982..dfd4f3a 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -2113,7 +2113,9 @@
>  and only used for output to describe the detected backing chains.
>  Since 1.2.4. An empty
>  backingStore element means the sibling source is
> -self-contained and is not based on any backing store. The following
> +self-contained and is not based on any backing store. Note that
> +backingStore info is included in the output only when
> +the guest is up and running, otherwise its not included. The

s/its/it's/

> following

We aim to fix that in the future (that is, eventually libvirt will track
backing information even for offline domains), but until that happens, I
can agree with documenting the limitation.  I will touch this up and
push it later today.

-- 
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 2/2] qemu: add a max_core setting to qemu.conf for core dump size

2015-03-18 Thread Daniel P. Berrange
Currently the QEMU processes inherit their core dump rlimit
from libvirtd, which is really suboptimal. This change allows
their limit to be directly controller from qemu.conf instead.
---
 src/libvirt_private.syms   |  2 ++
 src/qemu/libvirtd_qemu.aug |  1 +
 src/qemu/qemu.conf | 12 
 src/qemu/qemu_conf.c   |  3 +++
 src/qemu/qemu_conf.h   |  2 ++
 src/qemu/qemu_process.c|  2 ++
 src/qemu/test_libvirtd_qemu.aug.in |  1 +
 src/util/vircommand.c  | 14 ++
 src/util/vircommand.h  |  1 +
 src/util/virprocess.c  | 35 +++
 src/util/virprocess.h  |  1 +
 11 files changed, 74 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index ca3520d..7446357 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1240,6 +1240,7 @@ virCommandSetErrorFD;
 virCommandSetGID;
 virCommandSetInputBuffer;
 virCommandSetInputFD;
+virCommandSetMaxCoreSize;
 virCommandSetMaxFiles;
 virCommandSetMaxMemLock;
 virCommandSetMaxProcesses;
@@ -1951,6 +1952,7 @@ virProcessRunInMountNamespace;
 virProcessSchedPolicyTypeFromString;
 virProcessSchedPolicyTypeToString;
 virProcessSetAffinity;
+virProcessSetMaxCoreSize;
 virProcessSetMaxFiles;
 virProcessSetMaxMemLock;
 virProcessSetMaxProcesses;
diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 62951da..029a55a 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -71,6 +71,7 @@ module Libvirtd_qemu =
  | bool_entry "set_process_name"
  | int_entry "max_processes"
  | int_entry "max_files"
+ | int_entry "max_core"
 
let device_entry = bool_entry "mac_filter"
  | bool_entry "relaxed_acs_check"
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 1c589a2..12e4326 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -390,6 +390,18 @@
 #max_processes = 0
 #max_files = 0
 
+# If max_core is set to a positive integer, then QEMU will be
+# permitted to create core dumps when it crashes, provided its
+# RAM size is smaller than the limit set. Be warned that the
+# core dump will include a full copy of the guest RAM, so if
+# the largest guest is 32 GB in size, the max_core limit will
+# have to be at least 33/34 GB to allow enough overhead.
+#
+# By default it will inherit core limit from libvirtd, which
+# is usually set to 0 by systemd/init.
+#
+# Size is in bytes
+#max_core = 0
 
 
 # mac_filter enables MAC addressed based filtering on bridge ports.
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index bca05c9..97bb8b8 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -770,6 +770,9 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
 GET_VALUE_BOOL("set_process_name", cfg->setProcessName);
 GET_VALUE_ULONG("max_processes", cfg->maxProcesses);
 GET_VALUE_ULONG("max_files", cfg->maxFiles);
+GET_VALUE_ULONG("max_core", cfg->maxCore);
+if (virConfGetValue(conf, "max_core"))
+cfg->setMaxCore = true;
 
 GET_VALUE_STR("lock_manager", cfg->lockManagerName);
 
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index cb01fb6..ac7a1bf 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -143,6 +143,8 @@ struct _virQEMUDriverConfig {
 
 int maxProcesses;
 int maxFiles;
+bool setMaxCore;
+unsigned long long maxCore;
 
 int maxQueuedJobs;
 
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 37cdb8f..995d6ef 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4731,6 +4731,8 @@ int qemuProcessStart(virConnectPtr conn,
 virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData);
 virCommandSetMaxProcesses(cmd, cfg->maxProcesses);
 virCommandSetMaxFiles(cmd, cfg->maxFiles);
+if (cfg->setMaxCore)
+virCommandSetMaxCoreSize(cmd, cfg->maxCore);
 virCommandSetUmask(cmd, 0x002);
 
 VIR_DEBUG("Setting up security labelling");
diff --git a/src/qemu/test_libvirtd_qemu.aug.in 
b/src/qemu/test_libvirtd_qemu.aug.in
index fc4935b..9bb3683 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -61,6 +61,7 @@ module Test_libvirtd_qemu =
 { "set_process_name" = "1" }
 { "max_processes" = "0" }
 { "max_files" = "0" }
+{ "max_core" = "0" }
 { "mac_filter" = "1" }
 { "relaxed_acs_check" = "1" }
 { "allow_disk_format_probing" = "1" }
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 648f5ed..1982401 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -123,6 +123,8 @@ struct _virCommand {
 unsigned long long maxMemLock;
 unsigned int maxProcesses;
 unsigned int maxFiles;
+bool setMaxCore;
+unsigned long long maxCore;
 
 uid_t uid;
 gid_t gid;
@@ -686,6 +688,9 @@ virExec(virCommandPtr cmd)
 goto fork_error;
 if (v

[libvirt] [PATCH 0/2] Support core file limit settings for QEMU

2015-03-18 Thread Daniel P. Berrange
Currently QEMU inherits core size limits from libvirtd which
is rather inconvenient

Daniel P. Berrange (2):
  conf: parse integers into long long, instead of long
  qemu: add a max_core setting to qemu.conf for core dump size

 daemon/libvirtd-config.c   |   6 +--
 src/libvirt_private.syms   |   2 +
 src/locking/lock_daemon_config.c   |   4 +-
 src/locking/lock_driver_lockd.c|   4 +-
 src/locking/lock_driver_sanlock.c  |   6 +--
 src/lxc/lxc_conf.c |   6 +--
 src/qemu/libvirtd_qemu.aug |   1 +
 src/qemu/qemu.conf |  12 +
 src/qemu/qemu_conf.c   |   9 ++--
 src/qemu/qemu_conf.h   |   2 +
 src/qemu/qemu_process.c|   2 +
 src/qemu/test_libvirtd_qemu.aug.in |   1 +
 src/util/vircommand.c  |  14 +
 src/util/vircommand.h  |   1 +
 src/util/virconf.c |  22 
 src/util/virconf.h |   6 +--
 src/util/virprocess.c  |  35 +
 src/util/virprocess.h  |   1 +
 src/xenconfig/xen_common.c |   8 +--
 tests/Makefile.am  |   5 ++
 tests/libvirtdconftest.c   |   4 +-
 tests/virconftest.c| 105 +
 22 files changed, 220 insertions(+), 36 deletions(-)
 create mode 100644 tests/virconftest.c

-- 
2.1.0

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


[libvirt] [PATCH 1/2] conf: parse integers into long long, instead of long

2015-03-18 Thread Daniel P. Berrange
When parsing integer values, we only used 'long' data type
in the virConfValue struct. This is insufficiently large
to deal with things like guest memory sizes on 32-bit platforms
which are using PAE for addressing > 4 GB of RAM.
---
 daemon/libvirtd-config.c  |   6 +--
 src/locking/lock_daemon_config.c  |   4 +-
 src/locking/lock_driver_lockd.c   |   4 +-
 src/locking/lock_driver_sanlock.c |   6 +--
 src/lxc/lxc_conf.c|   6 +--
 src/qemu/qemu_conf.c  |   6 +--
 src/util/virconf.c|  22 
 src/util/virconf.h|   6 +--
 src/xenconfig/xen_common.c|   8 +--
 tests/Makefile.am |   5 ++
 tests/libvirtdconftest.c  |   4 +-
 tests/virconftest.c   | 105 ++
 12 files changed, 146 insertions(+), 36 deletions(-)
 create mode 100644 tests/virconftest.c

diff --git a/daemon/libvirtd-config.c b/daemon/libvirtd-config.c
index 3694455..9344ccc 100644
--- a/daemon/libvirtd-config.c
+++ b/daemon/libvirtd-config.c
@@ -151,8 +151,8 @@ checkType(virConfValuePtr p, const char *filename,
 do {\
 virConfValuePtr p = virConfGetValue(conf, #var_name);   \
 if (p) {\
-if (p->type != VIR_CONF_ULONG &&\
-checkType(p, filename, #var_name, VIR_CONF_LONG) < 0)   \
+if (p->type != VIR_CONF_ULLONG &&   \
+checkType(p, filename, #var_name, VIR_CONF_LLONG) < 0)  \
 goto error; \
 data->var_name = p->l;  \
 }   \
@@ -163,7 +163,7 @@ checkType(virConfValuePtr p, const char *filename,
 do {\
 virConfValuePtr p = virConfGetValue(conf, #var_name);   \
 if (p) {\
-if (checkType(p, filename, #var_name, VIR_CONF_ULONG) < 0)  \
+if (checkType(p, filename, #var_name, VIR_CONF_ULLONG) < 0) \
 goto error; \
 data->var_name = p->l;  \
 }   \
diff --git a/src/locking/lock_daemon_config.c b/src/locking/lock_daemon_config.c
index 8a6d18f..20718a2 100644
--- a/src/locking/lock_daemon_config.c
+++ b/src/locking/lock_daemon_config.c
@@ -75,7 +75,7 @@ checkType(virConfValuePtr p, const char *filename,
 do {\
 virConfValuePtr p = virConfGetValue(conf, #var_name);   \
 if (p) {\
-if (p->type != VIR_CONF_ULONG &&\
+if (p->type != VIR_CONF_ULLONG &&   \
 checkType(p, filename, #var_name, VIR_CONF_LONG) < 0)   \
 goto error; \
 data->var_name = p->l;  \
@@ -87,7 +87,7 @@ checkType(virConfValuePtr p, const char *filename,
 do {\
 virConfValuePtr p = virConfGetValue(conf, #var_name);   \
 if (p) {\
-if (checkType(p, filename, #var_name, VIR_CONF_ULONG) < 0)  \
+if (checkType(p, filename, #var_name, VIR_CONF_ULLONG) < 0) \
 goto error; \
 data->var_name = p->l;  \
 }   \
diff --git a/src/locking/lock_driver_lockd.c b/src/locking/lock_driver_lockd.c
index 72a4a0c..59cdd45 100644
--- a/src/locking/lock_driver_lockd.c
+++ b/src/locking/lock_driver_lockd.c
@@ -108,7 +108,7 @@ static int virLockManagerLockDaemonLoadConfig(const char 
*configFile)
 }
 
 p = virConfGetValue(conf, "auto_disk_leases");
-CHECK_TYPE("auto_disk_leases", VIR_CONF_ULONG);
+CHECK_TYPE("auto_disk_leases", VIR_CONF_ULLONG);
 if (p) driver->autoDiskLease = p->l;
 
 p = virConfGetValue(conf, "file_lockspace_dir");
@@ -142,7 +142,7 @@ static int virLockManagerLockDaemonLoadConfig(const char 
*configFile)
 }
 
 p = virConfGetValue(conf, "require_lease_for_disks");
-CHECK_TYPE("require_lease_for_disks", VIR_CONF_ULONG);
+CHECK_TYPE("require_lease_for_disks", VIR_CONF_ULLONG);
 if (p)
 driver->requireLeaseForDisks = p->l;
 else
diff --git a/src/locking/loc

Re: [libvirt] [PATCH] qemu: Fix two issues in qemuDomainSetVcpus error handling

2015-03-18 Thread Martin Kletzander

On Wed, Mar 18, 2015 at 07:25:29AM -0400, John Ferlan wrote:

Issue #1 - A call to virBitmapNew did not check if the allocation
failed which could lead to a NULL dereference

Issue #2 - When deleting the pin entries from the config file, the
code loops from the number of elements down to the "new" vcpu count;
however, the pin id values are numbered 0..n-1 not 1..n, so the "first"
pin attempt would never work. Luckily the check was for whether the
incoming 'n' (vcpu id) matched the entry in the array from 0..arraysize
rather than a dereference of the 'n' entry

Signed-off-by: John Ferlan 
---

NOTE: These were found on inspection while working/debugging the a IOThreads
series which borrows from the SetVcpus code.  I can separate the two if
desired, but I think the second issue is mostly an optimization.



If you want to, but in this particular case I think it has no difference.



src/qemu/qemu_driver.c | 8 ++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ed6764d..6d9217b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4752,7 +4752,11 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr 
driver,
if (VIR_ALLOC(vcpupin) < 0)
goto cleanup;

-vcpupin->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
+if (!(vcpupin->cpumask =
+  virBitmapNew(VIR_DOMAIN_CPUMASK_LEN))) {
+VIR_FREE(vcpupin);
+goto cleanup;
+}
virBitmapCopy(vcpupin->cpumask, vm->def->cpumask);
vcpupin->id = i;
if (VIR_APPEND_ELEMENT_COPY(vm->def->cputune.vcpupin,
@@ -4987,7 +4991,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
/* remove vcpupin entries for vcpus that were unplugged */
if (nvcpus < persistentDef->vcpus) {
-for (i = persistentDef->vcpus; i >= nvcpus; i--)
+for (i = persistentDef->vcpus - 1; i >= nvcpus; i--)


for (i = nvcpus; i < persistentDef->vcpus, i++)

would be easily readable (I guess the construct in the code might be
just a leftover when it was an array).

ACK with any of the versions.


virDomainPinDel(&persistentDef->cputune.vcpupin,
&persistentDef->cputune.nvcpupin,
i);
--
2.1.0

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


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

Re: [libvirt] Domain XML isn't dumping full backing chain

2015-03-18 Thread Shanzhi Yu
- Original Message -

| From: "Deepak Shetty" 
| To: libvir-list@redhat.com
| Sent: Wednesday, March 18, 2015 7:19:05 PM
| Subject: [libvirt] Domain XML isn't dumping full backing chain

| Hi,
| I am using libvirt version 1.2.9.2 on F21 and i am unable to get the complete
| backing chain info in the virsh dumpxml output. Details below :

| My backing chain per qemu-img :

| [stack@devstack-f21 test]$ qemu-img info --backing-chain snap4.qcow2
| image: snap4.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./snap3.qcow2
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ./snap3.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./snap2.qcow2 (actual path: ././snap2.qcow2)
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ././snap2.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./snap1.qcow2 (actual path: ./././snap1.qcow2)
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ./././snap1.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| backing file: ./base.qcow2 (actual path: ././././base.qcow2)
| Format specific information:
| compat: 1.1
| lazy refcounts: false

| image: ././././base.qcow2
| file format: qcow2
| virtual size: 1.0G (1073741824 bytes)
| disk size: 196K
| cluster_size: 65536
| Format specific information:
| compat: 1.1
| lazy refcounts: false

If you want prepare the backing chain yourself, you should add "-o 
backing_fmt=$farmat" options, 
like "qemu-img create -f qcow2 base.s1 -b base.qcow2 -o backing_fmt=qcow2" 

| I created 4 snapshots using commands (similar to the below, just dumping the
| last one here ):

| [stack@devstack-f21 test]$ virsh snapshot-create-as test-domain on-test-snap4
| --disk-only --reuse-external --diskspec
| hda,snapshot=external,file=/home/stack/test/snap4.qcow2
| Domain snapshot on-test-snap4 created

| [stack@devstack-f21 test]$ virsh domblklist test-domain
| Target Source
| 
| hda /home/stack/test/snap4.qcow2

| virsh dumpxml test-domain|more
| 

| 
| 
| 
| 
| 

If you don't add "-o backing_fmt=qcow2", it will treat backing file format as 
raw format. 
Since a raw format file doesn't have a backing file, so you only see 
snap4.qcow2 and 
snap3.qcow2 

| 
| 
| 
| 
| 
| 
| 

| .

| I think thats happening beccause the backingStore format is coming as 'raw'
| What am i missing ?

| thanx,
| deepak

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

[libvirt] [PATCH] qemu: Fix two issues in qemuDomainSetVcpus error handling

2015-03-18 Thread John Ferlan
Issue #1 - A call to virBitmapNew did not check if the allocation
failed which could lead to a NULL dereference

Issue #2 - When deleting the pin entries from the config file, the
code loops from the number of elements down to the "new" vcpu count;
however, the pin id values are numbered 0..n-1 not 1..n, so the "first"
pin attempt would never work. Luckily the check was for whether the
incoming 'n' (vcpu id) matched the entry in the array from 0..arraysize
rather than a dereference of the 'n' entry

Signed-off-by: John Ferlan 
---

NOTE: These were found on inspection while working/debugging the a IOThreads
series which borrows from the SetVcpus code.  I can separate the two if
desired, but I think the second issue is mostly an optimization.


 src/qemu/qemu_driver.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ed6764d..6d9217b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4752,7 +4752,11 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr 
driver,
 if (VIR_ALLOC(vcpupin) < 0)
 goto cleanup;
 
-vcpupin->cpumask = virBitmapNew(VIR_DOMAIN_CPUMASK_LEN);
+if (!(vcpupin->cpumask =
+  virBitmapNew(VIR_DOMAIN_CPUMASK_LEN))) {
+VIR_FREE(vcpupin);
+goto cleanup;
+}
 virBitmapCopy(vcpupin->cpumask, vm->def->cpumask);
 vcpupin->id = i;
 if (VIR_APPEND_ELEMENT_COPY(vm->def->cputune.vcpupin,
@@ -4987,7 +4991,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int 
nvcpus,
 if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
 /* remove vcpupin entries for vcpus that were unplugged */
 if (nvcpus < persistentDef->vcpus) {
-for (i = persistentDef->vcpus; i >= nvcpus; i--)
+for (i = persistentDef->vcpus - 1; i >= nvcpus; i--)
 virDomainPinDel(&persistentDef->cputune.vcpupin,
 &persistentDef->cputune.nvcpupin,
 i);
-- 
2.1.0

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


[libvirt] Domain XML isn't dumping full backing chain

2015-03-18 Thread Deepak Shetty
Hi,
I am using libvirt version 1.2.9.2 on F21 and i am unable to get the
complete backing chain info in the virsh dumpxml output. Details below :

*My backing chain per qemu-img :*

[stack@devstack-f21 test]$ qemu-img info --backing-chain snap4.qcow2
image: snap4.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
backing file: ./snap3.qcow2
Format specific information:
compat: 1.1
lazy refcounts: false

image: ./snap3.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
backing file: ./snap2.qcow2 (actual path: ././snap2.qcow2)
Format specific information:
compat: 1.1
lazy refcounts: false

image: ././snap2.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
backing file: ./snap1.qcow2 (actual path: ./././snap1.qcow2)
Format specific information:
compat: 1.1
lazy refcounts: false

image: ./././snap1.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
backing file: ./base.qcow2 (actual path: ././././base.qcow2)
Format specific information:
compat: 1.1
lazy refcounts: false

image: ././././base.qcow2
file format: qcow2
virtual size: 1.0G (1073741824 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false

I created 4 snapshots using commands (similar to the below, just dumping
the last one here ):

[stack@devstack-f21 test]$ virsh snapshot-create-as test-domain
on-test-snap4  --disk-only --reuse-external --diskspec
hda,snapshot=external,file=/home/stack/test/snap4.qcow2
Domain snapshot on-test-snap4 created

[stack@devstack-f21 test]$ virsh domblklist test-domain
Target Source

hda/home/stack/test/snap4.qcow2



virsh dumpxml test-domain|more



  
  
  



  
  
  
  



.

I think thats happening beccause the backingStore format is coming as 'raw'
What am i missing ?

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

Re: [libvirt] [PATCH] libvirt: move default nwfilters to datadir.

2015-03-18 Thread Daniel P. Berrange
On Wed, Mar 18, 2015 at 10:09:53AM +, Dimitri John Ledkov wrote:
> On 17 March 2015 at 19:04, Daniel P. Berrange  wrote:
> > On Tue, Mar 17, 2015 at 06:52:31PM +, Dimitri John Ledkov wrote:
> >> libvirt runs correctly without any configuration files, as sensible
> >> defaults are used throughout. This commit introduces a layer for
> >> nwfilter configuration. This means that default filters are shipped in
> >> /usr/share/libvirt/nwfilter/ directory, which can be overridden by
> >> things in /etc/libvirt/nwfilter. This is similar to configuration
> >> splits as observed in udev, systemd, XDG Base Directory Specification
> >> and so on. This will make a distinction and make it obvious if any of
> >> the nwfilters are modified by the administrator.
> >
> > I think this is really not something we want to do. Having multiple
> > directories to store configs in is going to have more fallout than
> > your patch shows. For a start this breaks the ability to delete these
> > filters, since the deletion code assumes they're in a particular
> > directory. Now if the same named filter is present in both locations
> > the delete API does not know which to delete.
> >
> 
> OK, I'll check that. So far I did simplistic testing and
> overwrote/remove filters by placing a filter without any rules but
> with the same name attribute in /etc and nwfilter-list / dumpxml still
> worked correctly. I will check the behaviour of define/undefine/edit
> as well.
> 
> > If we were doing this again today, we'd simply not ever install  any
> > filters by default. Leave it entirely upto the app/admin using libvirt
> > to decide which filters are present. To that end we already split the
> > filters off into a separate optional RPM, so that users can skip their
> > installation.  So if people want to modify these, we should really
> > just be recommending that they not install this RPM in the first place
> >
> 
> Well... OpenStack software Nova component references the stock filters
> in their base configuration, e.g. no-mac-spoofing, no-ip-spoofing,
> no-arp-spoofing, allow-dhcp-server and so on. Thus these filters
> whilst example content, ended up being an API (removing them will
> break OpenStack Nova component). Hence the desire to move them away to
> /usr, as these shouldn't be modified, or at least that one can revert
> to stock versions of these.

I think i'd be better if Nova just defined its own set of rules for
everything it needs rather than relying on what happens to be prsent,
or not present, by default.

> Would you be at all open to any other semantics with stock filters
> moved out of /etc? E.g. have filters loaded from /usr to not be
> modifiable / marked read-only from the API, or only allowed to be
> referenced using filterref? (thus making these filters essentially
> builtin/well-known aliases for typical filtering pieces).

No, that would be a semantic change in behaviour of the API which would
potentially break applications

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

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


[libvirt] [PATCH v11] Expose virDomainInterfacesAddresses to python binding

2015-03-18 Thread Daniel P. Berrange
From: Nehal J Wani 

examples/Makefile.am:
  * Add new file domipaddrs.py

examples/README:
  * Add documentation for the python example

libvirt-override-api.xml:
  * Add new symbol for virDomainInterfacesAddresses

libvirt-override.c:
  * Hand written python api

Example:
  $ python examples/domipaddrs.py qemu:///system f18
Interface  MAC address  Protocol Address
vnet0  52:54:00:20:70:3dipv4 192.168.105.240/16

In v11:
 - Cope with hwaddr being NULL by filling in PY_NONE
---
 MANIFEST.in  |   1 +
 examples/README  |   1 +
 examples/domipaddrs.py   |  57 
 generator.py |   2 +
 libvirt-override-api.xml |   9 +++-
 libvirt-override.c   | 110 +++
 sanitytest.py|   3 ++
 7 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100755 examples/domipaddrs.py

diff --git a/MANIFEST.in b/MANIFEST.in
index d7bc545..dd05221 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,6 +4,7 @@ include COPYING
 include COPYING.LESSER
 include ChangeLog
 include examples/consolecallback.py
+include examples/domipaddrs.py
 include examples/dominfo.py
 include examples/domrestore.py
 include examples/domsave.py
diff --git a/examples/README b/examples/README
index 5b5d405..1d4b425 100644
--- a/examples/README
+++ b/examples/README
@@ -11,6 +11,7 @@ domrestore.py - restore domU's from their saved files in a 
directory
 esxlist.py  - list active domains of an VMware ESX host and print some info.
   also demonstrates how to use the libvirt.openAuth() method
 dhcpleases.py - list dhcp leases for a given virtual network
+domipaddrs.py - list IP addresses for guest domains
 
 The XML files in this directory are examples of the XML format that libvirt
 expects, and will have to be adapted for your setup. They are only needed
diff --git a/examples/domipaddrs.py b/examples/domipaddrs.py
new file mode 100755
index 000..d6d5cac
--- /dev/null
+++ b/examples/domipaddrs.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# domipaddrs - print domain interfaces along with their MAC and IP addresses
+
+import libvirt
+import sys
+
+def usage():
+print "Usage: %s [URI] DOMAIN" % sys.argv[0]
+print "Print domain interfaces along with their MAC and IP 
addresses"
+
+uri = None
+name = None
+args = len(sys.argv)
+
+if args == 2:
+name = sys.argv[1]
+elif args == 3:
+uri = sys.argv[1]
+name = sys.argv[2]
+else:
+usage()
+sys.exit(2)
+
+conn = libvirt.open(uri)
+if conn == None:
+print "Unable to open connection to libvirt"
+sys.exit(1)
+
+try:
+dom = conn.lookupByName(name)
+except libvirt.libvirtError:
+print "Domain %s not found" % name
+sys.exit(0)
+
+ifaces = 
dom.interfaceAddresses(libvirt.VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE);
+if (ifaces == None):
+print "Failed to get domain interfaces"
+sys.exit(0)
+
+print " {0:10} {1:20} {2:12} {3}".format("Interface", "MAC address", 
"Protocol", "Address")
+
+def toIPAddrType(addrType):
+if addrType == libvirt.VIR_IP_ADDR_TYPE_IPV4:
+return "ipv4"
+elif addrType == libvirt.VIR_IP_ADDR_TYPE_IPV6:
+return "ipv6"
+
+for (name, val) in ifaces.iteritems():
+if val['addrs']:
+for addr in val['addrs']:
+   print " {0:10} {1:19}".format(name, val['hwaddr']),
+   print " {0:12} {1}/{2} ".format(toIPAddrType(addr['type']), 
addr['addr'], addr['prefix']),
+   print
+else:
+print " {0:10} {1:19}".format(name, val['hwaddr']),
+print " {0:12} {1}".format("N/A", "N/A"),
+print
diff --git a/generator.py b/generator.py
index df7a74d..8c1c48e 100755
--- a/generator.py
+++ b/generator.py
@@ -483,6 +483,7 @@ skip_impl = (
 'virDomainBlockCopy',
 'virNodeAllocPages',
 'virDomainGetFSInfo',
+'virDomainInterfaceAddresses',
 )
 
 lxc_skip_impl = (
@@ -595,6 +596,7 @@ skip_function = (
 'virDomainStatsRecordListFree', # only useful in C, python uses dict
 'virDomainFSInfoFree', # only useful in C, python code uses list
 'virDomainIOThreadsInfoFree', # only useful in C, python code uses list
+'virDomainInterfaceFree', # only useful in C, python code uses list
 )
 
 lxc_skip_function = (
diff --git a/libvirt-override-api.xml b/libvirt-override-api.xml
index 4660c9f..b197639 100644
--- a/libvirt-override-api.xml
+++ b/libvirt-override-api.xml
@@ -678,5 +678,12 @@
   
   
 
-  
+
+  returns a dictionary of domain interfaces along with their MAC and 
IP addresses
+  
+  
+  
+  
+
+
 
diff --git a/libvirt-override.c b/libvirt-override.c
index 1241305..548be24 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -5120,6 +5120,113 @@ cleanup:
 return py_retval;
 }
 
+
+static PyObject *
+libvirt_virDomainInterfaceAddresses(PyObject *self ATTRIBUTE_UNUSED,
+PyObject *args)
+{
+PyObject *py_retval = VIR

Re: [libvirt] [PATCH] libvirt: move default nwfilters to datadir.

2015-03-18 Thread Dimitri John Ledkov
On 17 March 2015 at 19:04, Daniel P. Berrange  wrote:
> On Tue, Mar 17, 2015 at 06:52:31PM +, Dimitri John Ledkov wrote:
>> libvirt runs correctly without any configuration files, as sensible
>> defaults are used throughout. This commit introduces a layer for
>> nwfilter configuration. This means that default filters are shipped in
>> /usr/share/libvirt/nwfilter/ directory, which can be overridden by
>> things in /etc/libvirt/nwfilter. This is similar to configuration
>> splits as observed in udev, systemd, XDG Base Directory Specification
>> and so on. This will make a distinction and make it obvious if any of
>> the nwfilters are modified by the administrator.
>
> I think this is really not something we want to do. Having multiple
> directories to store configs in is going to have more fallout than
> your patch shows. For a start this breaks the ability to delete these
> filters, since the deletion code assumes they're in a particular
> directory. Now if the same named filter is present in both locations
> the delete API does not know which to delete.
>

OK, I'll check that. So far I did simplistic testing and
overwrote/remove filters by placing a filter without any rules but
with the same name attribute in /etc and nwfilter-list / dumpxml still
worked correctly. I will check the behaviour of define/undefine/edit
as well.

> If we were doing this again today, we'd simply not ever install  any
> filters by default. Leave it entirely upto the app/admin using libvirt
> to decide which filters are present. To that end we already split the
> filters off into a separate optional RPM, so that users can skip their
> installation.  So if people want to modify these, we should really
> just be recommending that they not install this RPM in the first place
>

Well... OpenStack software Nova component references the stock filters
in their base configuration, e.g. no-mac-spoofing, no-ip-spoofing,
no-arp-spoofing, allow-dhcp-server and so on. Thus these filters
whilst example content, ended up being an API (removing them will
break OpenStack Nova component). Hence the desire to move them away to
/usr, as these shouldn't be modified, or at least that one can revert
to stock versions of these.

Would you be at all open to any other semantics with stock filters
moved out of /etc? E.g. have filters loaded from /usr to not be
modifiable / marked read-only from the API, or only allowed to be
referenced using filterref? (thus making these filters essentially
builtin/well-known aliases for typical filtering pieces).

-- 
Regards,

Dimitri.

Open Source Technology Center
Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ.

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


Re: [libvirt] [PATCH] Use PAUSED state for domains that are starting up

2015-03-18 Thread Jiri Denemark
On Wed, Mar 11, 2015 at 14:20:02 -0600, Jim Fehlig wrote:
> Jiri Denemark wrote:
> > When libvirt is starting a domain, it reports the state as SHUTOFF until
> > it's RUNNING. This is not ideal because domain startup may take a long
> > time (usually because of some configuration issues, firewalls blocking
> > access to network disks, etc.) and domain lists provided by libvirt look
> > awkward. One can see weird shutoff domains with IDs in a list of active
> > domains or even shutoff transient domains. In any case, it looks more
> > like a bug in libvirt than a normal state a domain goes through.
> >   
> 
> I recently noticed similar behavior in the libxl driver when starting
> large memory domains, which can take considerable time.
> 
> > Signed-off-by: Jiri Denemark 
> > ---
> >
> > After going through all hypervisor drivers it seems none of them needs
> > to be updated. That is, this patch matches the one I sent as RFC for
> > design discussions.
> >
> >  include/libvirt/libvirt-domain.h |  1 +
> >  src/conf/domain_conf.c   |  3 ++-
> >  src/qemu/qemu_process.c  | 22 ++
> >  tools/virsh-domain-monitor.c |  3 ++-
> >  4 files changed, 19 insertions(+), 10 deletions(-)
> >
> > diff --git a/include/libvirt/libvirt-domain.h 
> > b/include/libvirt/libvirt-domain.h
> > index 9487b80..d5c148b 100644
> > --- a/include/libvirt/libvirt-domain.h
> > +++ b/include/libvirt/libvirt-domain.h
> > @@ -116,6 +116,7 @@ typedef enum {
> >  VIR_DOMAIN_PAUSED_SHUTTING_DOWN = 8, /* paused during shutdown process 
> > */
> >  VIR_DOMAIN_PAUSED_SNAPSHOT = 9,  /* paused while creating a 
> > snapshot */
> >  VIR_DOMAIN_PAUSED_CRASHED = 10, /* paused due to a guest crash */
> > +VIR_DOMAIN_PAUSED_STARTING_UP = 11, /* the domain is being started */
> >   
> 
> Cool.  I'll use this in libxlDomainStart() in the libxl driver.

Hmm, I looked at all drivers including libxl and didn't find a good
place put this change. I guess it's because I'm totally unfamiliar with
libxl (driver).

> I'm no expert in the qemu driver code, but this looks sane to me.  ACK.

OK, given the previous design ACK from Daniel, I pushed this patch.

Jirka

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


Re: [libvirt] [PATCH] update documentation for command cd

2015-03-18 Thread Michal Privoznik
On 15.03.2015 18:15, swat wrote:
> Updated the documentation for command cd
> 
> The documentation for command cd did not have information about the command. 
> Added the required information.
> ---
>  source/cd.xml | 36 +---
>  1 file changed, 33 insertions(+), 3 deletions(-)

As Jan said, please resend the patch according to his suggestions.

Michal

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


Re: [libvirt] [test-API][PATCH] Add connection_security_model test case

2015-03-18 Thread hongming


On 03/17/2015 11:49 AM, lcheng wrote:

The connection_security_model.py uses getSecurityModel() to validate new API 
virNodeGetSecurityModel of libvirt.
---
  cases/linux_domain.conf|   4 ++
  repos/virconn/connection_security_model.py | 101 +
  2 files changed, 105 insertions(+)
  create mode 100644 repos/virconn/connection_security_model.py

diff --git a/cases/linux_domain.conf b/cases/linux_domain.conf
index 903fdb5..a7015f0 100644
--- a/cases/linux_domain.conf
+++ b/cases/linux_domain.conf
@@ -233,6 +233,10 @@ domain:domain_fsthaw
  guestname
  $defaultname
  
+virconn:connection_security_model

+guestname
+$defaultname
+
  domain:destroy
  guestname
  $defaultname
diff --git a/repos/virconn/connection_security_model.py 
b/repos/virconn/connection_security_model.py
new file mode 100644
index 000..b44d78c
--- /dev/null
+++ b/repos/virconn/connection_security_model.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+# To test "getSecurityModel"
+
+import libvirt
+
+from xml.dom import minidom
+from libvirt import libvirtError
+from src import sharedmod
+from utils import utils
+
+required_params = ('guestname',)
+optional_params = {}
+
+def get_security_driver(logger):
+"""get security driver from /etc/libvirt/qemu.conf"""
+
+cmds = "grep \"^security_driver\" /etc/libvirt/qemu.conf"
+(ret, conf) = utils.exec_cmd(cmds, shell=True)
+if ret:
+cmds = "getenforce"
+(ret, policy) = utils.exec_cmd(cmds, shell=True)
+
+if policy[0] == "Disabled":
+return "none"
+else:
+return "selinux"
+
+tmp = conf[0].split(' = ')
+if len(tmp[1].split(', ')) > 1:
+driver = tmp[1].split(', ')
+return (filter(str.isalpha, driver[0]))
+else:
+cmds = "echo '%s' | awk -F '\"' '{print $2}'" % conf[0]
+(ret, driver) = utils.exec_cmd(cmds, shell=True)
+
+if driver[0] == "selinux":
+return "selinux"
+elif driver[0] == "none":
+return "none"
+elif driver[0] == "apparmor":
+return "apparmor"
+elif driver[0] == "stack":
+return "stack"
+else:
+return ""
+
+def get_security_model(logger, domname):
+"""get security model from process"""
+
+PID = "ps aux | grep -v grep | grep %s | awk '{print $2}'" % domname
+ret, pid = utils.exec_cmd(PID, shell=True)
+if ret:
+logger.error("get domain pid failed.")
+return ""
+
+LABEL = "ls -nZd /proc/%s" % pid[0]
+ret, label = utils.exec_cmd(LABEL, shell=True)
+if ret:
+logger.error("get domain process's label failed.")
+return ""
+
+if "system_u:system_r:svirt_t:s0" in label[0]:
+return "selinux"
+else:
+return "none"
+
+def check_security_model(logger, domname, model):
+""" check security model"""
+
+dommodel = get_security_model(logger, domname)
+driver = get_security_driver(logger)
+
+logger.info("domain security model is %s." % dommodel)
+logger.info("get security driver is %s." % driver)
+logger.info("get security model is %s." % model)
+
+if driver == dommodel and dommodel == model:
+return True
+else:
+return False
+
+def connection_security_model(params):
+"""test API for getSecurityModel"""
+
+logger = params['logger']
+domname = params['guestname']
+conn = sharedmod.libvirtobj['conn']
+
+try:
+model = conn.getSecurityModel()
+
+if not check_security_model(logger, domname, model[0]):
+logger.error("Fail : get a error security model.")
+return 1
+else:
+logger.info("Pass : get security model successful.")
+return 0
+except libvirtError, e:
+logger.error("API error message: %s" % e.message)
+return 1
+

ACK and Pushed
NOTE: don't add blank line at EOF next time

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


Re: [libvirt] [PATCH] tests: Add tests for virCgroupDetectMounts

2015-03-18 Thread Jiri Denemark
On Tue, Mar 17, 2015 at 11:57:20 -0600, Eric Blake wrote:
> On 03/17/2015 06:39 AM, Jiri Denemark wrote:
> > Signed-off-by: Jiri Denemark 
> > ---
> >  src/libvirt_private.syms  |   1 +
> >  src/util/vircgroup.c  |  19 ++--
> >  src/util/vircgrouppriv.h  |   4 +
> 
> >  tests/vircgrouptest.c |  71 +++
> 
> Bulk of the important changes here; the rest is the use of the new
> function to provide several useful tests.  And since 'make check' still
> passes, it's worth having the extra coverage :)
> 
> ACK.

Pushed, thanks.

Jirka

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


[libvirt] [PATCH v4 1/7] parallels: introduce and use string constants for network types and names

2015-03-18 Thread Maxim Nestratov
Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_network.c |6 +++---
 src/parallels/parallels_sdk.c |6 +++---
 src/parallels/parallels_utils.h   |8 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/parallels/parallels_network.c 
b/src/parallels/parallels_network.c
index 1d3b694..bb7ec5e 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -211,12 +211,12 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 goto cleanup;
 }
 
-if (STREQ(tmp, "bridged")) {
+if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
 
 if (parallelsGetBridgedNetInfo(def, jobj) < 0)
 goto cleanup;
-} else if (STREQ(tmp, "host-only")) {
+} else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_NONE;
 
 if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
@@ -248,7 +248,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 
 def->forward.type = VIR_NETWORK_FORWARD_ROUTE;
 
-if (VIR_STRDUP(def->name, PARALLELS_ROUTED_NETWORK_NAME) < 0)
+if (VIR_STRDUP(def->name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
 goto cleanup;
 
 if (virUUIDParse(PARALLELS_ROUTED_NETWORK_UUID, def->uuid) < 0) {
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index a0b62cd..d3fb5d4 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -708,7 +708,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
  * always up */
 net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
 if (VIR_STRDUP(net->data.network.name,
-   PARALLELS_ROUTED_NETWORK_NAME) < 0)
+   PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
 goto cleanup;
 return 0;
 }
@@ -727,7 +727,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 
 if (emulatedType == PNA_ROUTED) {
 if (VIR_STRDUP(net->data.network.name,
-   PARALLELS_ROUTED_NETWORK_NAME) < 0)
+   PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
 goto cleanup;
 } else {
 pret = PrlVmDevNet_GetVirtualNetworkId(netAdapter, NULL, &buflen);
@@ -2658,8 +2658,8 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
virDomainNetDefPtr net)
 pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
 prlsdkCheckRetGoto(pret, cleanup);
 
-if (STREQ(net->data.network.name, PARALLELS_ROUTED_NETWORK_NAME)) {
 pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
+if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
 prlsdkCheckRetGoto(pret, cleanup);
 } else {
 pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 394548a..0f29374 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -47,7 +47,13 @@
_("no domain with matching uuid '%s'"), uuidstr); \
 } while (0)
 
-# define PARALLELS_ROUTED_NETWORK_NAME   "Routed"
+# define PARALLELS_DOMAIN_ROUTED_NETWORK_NAME   "Routed"
+# define PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME  "Bridged"
+
+# define PARALLELS_REQUIRED_HOSTONLY_NETWORK "Host-Only"
+# define PARALLELS_HOSTONLY_NETWORK_TYPE "host-only"
+# define PARALLELS_REQUIRED_BRIDGED_NETWORK  "Bridged"
+# define PARALLELS_BRIDGED_NETWORK_TYPE  "bridged"
 
 struct _parallelsConn {
 virMutex lock;
-- 
1.7.1

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


[libvirt] [PATCH v4 4/7] parallels: set correct network adapter device state

2015-03-18 Thread Maxim Nestratov
when a new network adapter device is added

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_sdk.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 58c52a8..d699613 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2658,7 +2658,9 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
parallelsConnPtr privconn, virDomainN
 pret = PrlVmDev_SetEnabled(sdknet, 1);
 prlsdkCheckRetGoto(pret, cleanup);
 
-pret = PrlVmDev_SetConnected(sdknet, net->linkstate);
+pret = PrlVmDev_SetConnected(sdknet, net->linkstate !=
+ VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN);
+
 prlsdkCheckRetGoto(pret, cleanup);
 
 if (net->ifname) {
-- 
1.7.1

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


[libvirt] [PATCH v4 3/7] parallels: better bridge network interface support

2015-03-18 Thread Maxim Nestratov
In order to support 'bridge' network adapters in parallels
driver we need to plug our veth devices into corresponding
linux bridges.
We are going to do this by reusing our abstraction of
Virtual Networks in terms of PCS. On a domain creation, we
create a new Virtual Network naming it with the same name
as a source bridge for each network  interface.
Having done this, we plug PCS veth interfaces created with names of
target dev into specified bridges using our standard PCS procedures

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_sdk.c |   99 +++-
 1 files changed, 86 insertions(+), 13 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d3fb5d4..58c52a8 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -691,9 +691,6 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 
 /* use device name, shown by prlctl as target device
  * for identifying network adapter in virDomainDefineXML */
-pret = PrlVmDev_GetIndex(netAdapter, &netAdapterIndex);
-prlsdkCheckRetGoto(pret, cleanup);
-
 pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, NULL, &buflen);
 prlsdkCheckRetGoto(pret, cleanup);
 
@@ -703,6 +700,9 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net->ifname, &buflen);
 prlsdkCheckRetGoto(pret, cleanup);
 
+pret = PrlVmDev_GetIndex(netAdapter, &netAdapterIndex);
+prlsdkCheckRetGoto(pret, cleanup);
+
 if (isCt && netAdapterIndex == (PRL_UINT32) -1) {
 /* venet devices don't have mac address and
  * always up */
@@ -740,6 +740,16 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
net->data.network.name,
&buflen);
 prlsdkCheckRetGoto(pret, cleanup);
+
+/*
+ * We use VIR_DOMAIN_NET_TYPE_NETWORK for all network adapters
+ * except those whose Virtual Network Id differ from Parallels
+ * predefined ones such as PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME
+ * and PARALLELS_DONAIN_ROUTED_NETWORK_NAME
+ */
+if (!STREQ(net->data.network.name, 
PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME))
+net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+
 }
 
 pret = PrlVmDev_IsConnected(netAdapter, &isConnected);
@@ -2630,10 +2640,12 @@ static const char * prlsdkFormatMac(virMacAddrPtr mac, 
char *macstr)
 return macstr;
 }
 
-static int prlsdkAddNet(PRL_HANDLE sdkdom, virDomainNetDefPtr net)
+static int prlsdkAddNet(PRL_HANDLE sdkdom, parallelsConnPtr privconn, 
virDomainNetDefPtr net)
 {
 PRL_RESULT pret;
 PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
+PRL_HANDLE vnet = PRL_INVALID_HANDLE;
+PRL_HANDLE job = PRL_INVALID_HANDLE;
 int ret = -1;
 char macstr[PRL_MAC_STRING_BUFNAME];
 
@@ -2658,10 +2670,39 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
virDomainNetDefPtr net)
 pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
 prlsdkCheckRetGoto(pret, cleanup);
 
-pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
-if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
+if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
+if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
+pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
+prlsdkCheckRetGoto(pret, cleanup);
+} else if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME)) {
+pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
+prlsdkCheckRetGoto(pret, cleanup);
+
+pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, 
net->data.network.name);
+prlsdkCheckRetGoto(pret, cleanup);
+}
+} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+/*
+ * For this type of adapter we create a new
+ * Virtual Network assuming that bridge with given name exists
+ * Failing creating this means domain creation failure
+ */
+pret = PrlVirtNet_Create(&vnet);
 prlsdkCheckRetGoto(pret, cleanup);
-} else {
+
+pret = PrlVirtNet_SetNetworkId(vnet, net->data.network.name);
+prlsdkCheckRetGoto(pret, cleanup);
+
+pret = PrlVirtNet_SetNetworkType(vnet, PVN_BRIDGED_ETHERNET);
+prlsdkCheckRetGoto(pret, cleanup);
+
+job = PrlSrv_AddVirtualNetwork(privconn->server, vnet, 0);
+if (PRL_FAILED(pret = waitJob(job, privconn->jobTimeout)))
+goto cleanup;
+
+pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
+prlsdkCheckRetGoto(pret, cleanup);
+
 pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
 prlsdkCheckRetGoto(pret, cleanup);
 }
@@ -2674,10 +2715,34 @

[libvirt] [PATCH v4 5/7] parallels: make E1000 network adapter model default

2015-03-18 Thread Maxim Nestratov
and set adapter model specified in xml

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_driver.c |7 ++-
 src/parallels/parallels_sdk.c|   15 +++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 1a6d6e6..807c1b1 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -168,13 +168,18 @@ parallelsDomainDefPostParse(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 return 0;
 }
 
-
 static int
 parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
   const virDomainDef *def ATTRIBUTE_UNUSED,
   virCapsPtr caps ATTRIBUTE_UNUSED,
   void *opaque ATTRIBUTE_UNUSED)
 {
+if (dev->type == VIR_DOMAIN_DEVICE_NET &&
+(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
+dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
+!dev->data.net->model)
+return VIR_STRDUP(dev->data.net->model, "e1000");
+
 return 0;
 }
 
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d699613..8deebd4 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2672,6 +2672,21 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
parallelsConnPtr privconn, virDomainN
 pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
 prlsdkCheckRetGoto(pret, cleanup);
 
+if (STREQ(net->model, "rtl8139"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
+else if (STREQ(net->model, "e1000"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
+else if (STREQ(net->model, "virtio"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
+else {
+
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Specified network adapter model is not "
+ "supported by Parallels Cloud Server."));
+goto cleanup;
+}
+prlsdkCheckRetGoto(pret, cleanup);
+
 if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
 if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
 pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
-- 
1.7.1

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


[libvirt] [PATCH v4 7/7] parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

2015-03-18 Thread Maxim Nestratov
network adapter is used
---
 src/parallels/parallels_sdk.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 3140757..1a448f1 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2251,7 +2251,8 @@ static int 
prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr)
 
 static int prlsdkCheckNetUnsupportedParams(virDomainNetDefPtr net)
 {
-if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
+if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK &&
+net->type != VIR_DOMAIN_NET_TYPE_BRIDGE) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Specified network adapter type is not "
  "supported by Parallels Cloud Server."));
-- 
1.7.1

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


[libvirt] [PATCH v4 6/7] parallels: switch off offline management feature

2015-03-18 Thread Maxim Nestratov
which is on by default when a new VM/CT is created.
We should do this because this feature can't be controlled
by libvirt now and it sets up some iptables rules. So it's
better to do this to avoid potential conflict of different
set of rules or to avoid unexpected behavior.

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_sdk.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 8deebd4..3140757 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -3095,6 +3095,9 @@ prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def)
 pret = PrlVmCfg_SetDefaultConfig(sdkdom, srvconf, 
PVS_GUEST_VER_LIN_REDHAT, 0);
 prlsdkCheckRetGoto(pret, cleanup);
 
+pret = PrlVmCfg_SetOfflineManagementEnabled(sdkdom, 0);
+prlsdkCheckRetGoto(pret, cleanup);
+
 ret = prlsdkDoApplyConfig(conn, sdkdom, def);
 if (ret)
 goto cleanup;
-- 
1.7.1

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


[libvirt] [PATCH v4 0/7] bridge network support enhancement and other network fixes

2015-03-18 Thread Maxim Nestratov
v2-v4 change:
  Addressed Michal Privoznik's comments
 

Maxim Nestratov (7):
  parallels: introduce and use string constants for network types and
names
  parallels: fix parallelsLoadNetworks
  parallels: better bridge network interface support
  parallels: set correct network adapter device state
  parallels: make E1000 network adapter model default
  parallels: switch off offline management feature
  parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

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


[libvirt] [PATCH v4 2/7] parallels: fix parallelsLoadNetworks

2015-03-18 Thread Maxim Nestratov
Don't fail initialization of parallels driver if
parallelsLoadNetwork fails for optional networks.
This can happen when some of them are added manually
and configured incompletely. PCS requires only two networks
created automatically (named Host-Only and Bridged), others
are optional and their incompletenes can be ignored.

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_network.c |   43 +++-
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/parallels/parallels_network.c 
b/src/parallels/parallels_network.c
index bb7ec5e..1d0ee1c 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -180,9 +180,10 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr 
def, const char *name)
 return ret;
 }
 
-static virNetworkObjPtr
+static int
 parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
 {
+int ret = -1;
 virNetworkObjPtr net;
 virNetworkDefPtr def;
 const char *tmp;
@@ -214,13 +215,25 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
 
-if (parallelsGetBridgedNetInfo(def, jobj) < 0)
+if (parallelsGetBridgedNetInfo(def, jobj) < 0) {
+
+/* Only mandatory networks are required to be configured 
completely */
+if (STRNEQ(def->name, PARALLELS_REQUIRED_BRIDGED_NETWORK))
+ret = 0;
+
 goto cleanup;
+}
 } else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_NONE;
 
-if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
+if (parallelsGetHostOnlyNetInfo(def, def->name) < 0) {
+
+/* Only mandatory networks are required to be configured 
completely */
+if (STRNEQ(def->name, PARALLELS_REQUIRED_HOSTONLY_NETWORK))
+ret = 0;
+
 goto cleanup;
+}
 } else {
 parallelsParseError();
 goto cleanup;
@@ -230,14 +243,16 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 goto cleanup;
 net->active = 1;
 net->autostart = 1;
-return net;
+virNetworkObjEndAPI(&net);
+ret = 0;
+def = NULL;
 
  cleanup:
 virNetworkDefFree(def);
-return NULL;
+return ret;
 }
 
-static virNetworkObjPtr
+static int
 parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 {
 virNetworkObjPtr net = NULL;
@@ -264,18 +279,18 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 }
 net->active = 1;
 net->autostart = 1;
+virNetworkObjEndAPI(&net);
 
-return net;
+return 0;
 
  cleanup:
 virNetworkDefFree(def);
-return NULL;
+return -1;
 }
 
 static int parallelsLoadNetworks(parallelsConnPtr privconn)
 {
 virJSONValuePtr jobj, jobj2;
-virNetworkObjPtr net = NULL;
 int ret = -1;
 int count;
 size_t i;
@@ -300,22 +315,18 @@ static int parallelsLoadNetworks(parallelsConnPtr 
privconn)
 goto cleanup;
 }
 
-net = parallelsLoadNetwork(privconn, jobj2);
-if (!net)
+ret = parallelsLoadNetwork(privconn, jobj2);
+if (!ret)
 goto cleanup;
-else
-virNetworkObjEndAPI(&net);
-
 }
 
-if (!(net = parallelsAddRoutedNetwork(privconn)))
+if (!(ret = parallelsAddRoutedNetwork(privconn)))
 goto cleanup;
 
 ret = 0;
 
  cleanup:
 virJSONValueFree(jobj);
-virNetworkObjEndAPI(&net);
 return ret;
 }
 
-- 
1.7.1

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


Re: [libvirt] [PATCH v3 0/7] bridge network support enhancement and other network fixes

2015-03-18 Thread Maxim Nestratov

18.03.2015 10:20, Maxim Nestratov пишет:

v3 change:
   Addressed Michal Privoznik's comments

Maxim Nestratov (7):
   parallels: introduce and use string constants for network types and
 names
   parallels: fix parallelsLoadNetworks
   parallels: better bridge network interface support
   parallels: set correct network adapter device state
   parallels: make E1000 network adapter model default
   parallels: switch off offline management feature
   parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

please disregard this v3 series, since "make E1000 network adapter model 
default" contains errors.

I'm resending it corrected in v4

Best regards,
Maxim

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

Re: [libvirt] [PATCH] util: vhost user: support for bootindex

2015-03-18 Thread zhang bo
On 2015/3/13 17:17, zhang bo wrote:

> Problem Description:
> When we set boot order for a vhost-user network interface, we found the boot 
> index
> doesn't work.
> 
> Cause of the Problem:
> In the function qemuBuildVhostuserCommandLine(), it forcely set the arg 
> bootindex of
> function qemuBuildNicDevStr() to 0. Thus, the bootindex parameter got missing.
> 
> Solution:
> Trans the arg bootindex down.
> 
> Signed-off-by: Gao Haifeng 
> Signed-off-by: Zhang Bo 
..


ping ...


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


Re: [libvirt] [libvirt-test-API][PATCH v2 0/2] Add test cases for setTime and getTime

2015-03-18 Thread hongming


On 03/12/2015 04:10 PM, hujianwei wrote:

On 12/03/15 11:11, Jincheng Miao wrote:

create some test cases for libvirt-python API setTime and getTime

v2:
   user should pass 'seconds' to set_guest_time, and 'nseconds' is 
optional.


Jincheng Miao (2):
   Add guest setTime and getTime testing
   Add test cases for linux_domain

  cases/linux_domain.conf|   30 ++
  repos/domain/guest_time.py |   98 
  repos/domain/set_guest_time.py |  122 


  3 files changed, 250 insertions(+), 0 deletions(-)
  create mode 100644 repos/domain/guest_time.py
  create mode 100644 repos/domain/set_guest_time.py


ACK

Please see my comments in the below patch mail.
[libvirt] [libvirt-test-API][PATCH v2 2/2] Add test cases for 
linux_domain

ACK and Pushed after adding the seconds param in "domain:set_guest_time" .



BR,
Jianwei


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


Re: [libvirt] [PATCH 5/7] parallels: make E1000 network adapter model default

2015-03-18 Thread Maxim Nestratov

18.03.2015 10:20, Maxim Nestratov пишет:

and set adapter model specified in xml

Signed-off-by: Maxim Nestratov 
---
  src/parallels/parallels_driver.c |7 ++-
  src/parallels/parallels_sdk.c|   17 +
  2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 1a6d6e6..807c1b1 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -168,13 +168,18 @@ parallelsDomainDefPostParse(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
  return 0;
  }
  
-

  static int
  parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
const virDomainDef *def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
  {
+if (dev->type == VIR_DOMAIN_DEVICE_NET &&
+(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
+dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
+!dev->data.net->model)
+return VIR_STRDUP(dev->data.net->model, "e1000");
+
  return 0;
  }
  
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c

index d699613..d34c814 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2672,6 +2672,23 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
parallelsConnPtr privconn, virDomainN
  pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
  prlsdkCheckRetGoto(pret, cleanup);
  
+if (STREQ(net->model, "rtl8139"))

+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
+else if (STREQ(net->model, "e1000"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
+else if (STREQ(net->model, "virtio"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
+else {
+
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Specified network adapter model is not "
+ "supported by Parallels Cloud Server."));
+goto cleanup;
+}

+prlsdkCheckRetGoto(pret, cleanup);

Noticed after sending that I forgot to include this line here


+
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
+prlsdkCheckRetGoto(pret, cleanup);
+
  if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
  if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
  pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);


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

[libvirt] [PATCH 4/7] parallels: set correct network adapter device state

2015-03-18 Thread Maxim Nestratov
when a new network adapter device is added

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_sdk.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 58c52a8..d699613 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2658,7 +2658,9 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
parallelsConnPtr privconn, virDomainN
 pret = PrlVmDev_SetEnabled(sdknet, 1);
 prlsdkCheckRetGoto(pret, cleanup);
 
-pret = PrlVmDev_SetConnected(sdknet, net->linkstate);
+pret = PrlVmDev_SetConnected(sdknet, net->linkstate !=
+ VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN);
+
 prlsdkCheckRetGoto(pret, cleanup);
 
 if (net->ifname) {
-- 
1.7.1

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


[libvirt] [PATCH 6/7] parallels: switch off offline management feature

2015-03-18 Thread Maxim Nestratov
which is on by default when a new VM/CT is created.
We should do this because this feature can't be controlled
by libvirt now and it sets up some iptables rules. So it's
better to do this to avoid potential conflict of different
set of rules or to avoid unexpected behavior.

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_sdk.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d34c814..465cc41 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -3097,6 +3097,9 @@ prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def)
 pret = PrlVmCfg_SetDefaultConfig(sdkdom, srvconf, 
PVS_GUEST_VER_LIN_REDHAT, 0);
 prlsdkCheckRetGoto(pret, cleanup);
 
+pret = PrlVmCfg_SetOfflineManagementEnabled(sdkdom, 0);
+prlsdkCheckRetGoto(pret, cleanup);
+
 ret = prlsdkDoApplyConfig(conn, sdkdom, def);
 if (ret)
 goto cleanup;
-- 
1.7.1

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


[libvirt] [PATCH 7/7] parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

2015-03-18 Thread Maxim Nestratov
network adapter is used
---
 src/parallels/parallels_sdk.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 465cc41..fb75d2d 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2251,7 +2251,8 @@ static int 
prlsdkCheckSerialUnsupportedParams(virDomainChrDefPtr chr)
 
 static int prlsdkCheckNetUnsupportedParams(virDomainNetDefPtr net)
 {
-if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK) {
+if (net->type != VIR_DOMAIN_NET_TYPE_NETWORK &&
+net->type != VIR_DOMAIN_NET_TYPE_BRIDGE) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Specified network adapter type is not "
  "supported by Parallels Cloud Server."));
-- 
1.7.1

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


[libvirt] [PATCH 5/7] parallels: make E1000 network adapter model default

2015-03-18 Thread Maxim Nestratov
and set adapter model specified in xml

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_driver.c |7 ++-
 src/parallels/parallels_sdk.c|   17 +
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 1a6d6e6..807c1b1 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -168,13 +168,18 @@ parallelsDomainDefPostParse(virDomainDefPtr def 
ATTRIBUTE_UNUSED,
 return 0;
 }
 
-
 static int
 parallelsDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
   const virDomainDef *def ATTRIBUTE_UNUSED,
   virCapsPtr caps ATTRIBUTE_UNUSED,
   void *opaque ATTRIBUTE_UNUSED)
 {
+if (dev->type == VIR_DOMAIN_DEVICE_NET &&
+(dev->data.net->type == VIR_DOMAIN_NET_TYPE_NETWORK ||
+dev->data.net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) &&
+!dev->data.net->model)
+return VIR_STRDUP(dev->data.net->model, "e1000");
+
 return 0;
 }
 
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d699613..d34c814 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2672,6 +2672,23 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
parallelsConnPtr privconn, virDomainN
 pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
 prlsdkCheckRetGoto(pret, cleanup);
 
+if (STREQ(net->model, "rtl8139"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_RTL);
+else if (STREQ(net->model, "e1000"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
+else if (STREQ(net->model, "virtio"))
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_VIRTIO);
+else {
+
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+   _("Specified network adapter model is not "
+ "supported by Parallels Cloud Server."));
+goto cleanup;
+}
+
+pret = PrlVmDevNet_SetAdapterType(sdknet, PNT_E1000);
+prlsdkCheckRetGoto(pret, cleanup);
+
 if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
 if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
 pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
-- 
1.7.1

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


[libvirt] [PATCH 3/7] parallels: better bridge network interface support

2015-03-18 Thread Maxim Nestratov
In order to support 'bridge' network adapters in parallels
driver we need to plug our veth devices into corresponding
linux bridges.
We are going to do this by reusing our abstraction of
Virtual Networks in terms of PCS. On a domain creation, we
create a new Virtual Network naming it with the same name
as a source bridge for each network  interface.
Having done this, we plug PCS veth interfaces created with names of
target dev into specified bridges using our standard PCS procedures

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_sdk.c |   99 +++-
 1 files changed, 86 insertions(+), 13 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index d3fb5d4..58c52a8 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -691,9 +691,6 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 
 /* use device name, shown by prlctl as target device
  * for identifying network adapter in virDomainDefineXML */
-pret = PrlVmDev_GetIndex(netAdapter, &netAdapterIndex);
-prlsdkCheckRetGoto(pret, cleanup);
-
 pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, NULL, &buflen);
 prlsdkCheckRetGoto(pret, cleanup);
 
@@ -703,6 +700,9 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net->ifname, &buflen);
 prlsdkCheckRetGoto(pret, cleanup);
 
+pret = PrlVmDev_GetIndex(netAdapter, &netAdapterIndex);
+prlsdkCheckRetGoto(pret, cleanup);
+
 if (isCt && netAdapterIndex == (PRL_UINT32) -1) {
 /* venet devices don't have mac address and
  * always up */
@@ -740,6 +740,16 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
net->data.network.name,
&buflen);
 prlsdkCheckRetGoto(pret, cleanup);
+
+/*
+ * We use VIR_DOMAIN_NET_TYPE_NETWORK for all network adapters
+ * except those whose Virtual Network Id differ from Parallels
+ * predefined ones such as PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME
+ * and PARALLELS_DONAIN_ROUTED_NETWORK_NAME
+ */
+if (!STREQ(net->data.network.name, 
PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME))
+net->type = VIR_DOMAIN_NET_TYPE_BRIDGE;
+
 }
 
 pret = PrlVmDev_IsConnected(netAdapter, &isConnected);
@@ -2630,10 +2640,12 @@ static const char * prlsdkFormatMac(virMacAddrPtr mac, 
char *macstr)
 return macstr;
 }
 
-static int prlsdkAddNet(PRL_HANDLE sdkdom, virDomainNetDefPtr net)
+static int prlsdkAddNet(PRL_HANDLE sdkdom, parallelsConnPtr privconn, 
virDomainNetDefPtr net)
 {
 PRL_RESULT pret;
 PRL_HANDLE sdknet = PRL_INVALID_HANDLE;
+PRL_HANDLE vnet = PRL_INVALID_HANDLE;
+PRL_HANDLE job = PRL_INVALID_HANDLE;
 int ret = -1;
 char macstr[PRL_MAC_STRING_BUFNAME];
 
@@ -2658,10 +2670,39 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
virDomainNetDefPtr net)
 pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
 prlsdkCheckRetGoto(pret, cleanup);
 
-pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
-if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
+if (net->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
+if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
+pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
+prlsdkCheckRetGoto(pret, cleanup);
+} else if (STREQ(net->data.network.name, 
PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME)) {
+pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
+prlsdkCheckRetGoto(pret, cleanup);
+
+pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, 
net->data.network.name);
+prlsdkCheckRetGoto(pret, cleanup);
+}
+} else if (net->type == VIR_DOMAIN_NET_TYPE_BRIDGE) {
+/*
+ * For this type of adapter we create a new
+ * Virtual Network assuming that bridge with given name exists
+ * Failing creating this means domain creation failure
+ */
+pret = PrlVirtNet_Create(&vnet);
 prlsdkCheckRetGoto(pret, cleanup);
-} else {
+
+pret = PrlVirtNet_SetNetworkId(vnet, net->data.network.name);
+prlsdkCheckRetGoto(pret, cleanup);
+
+pret = PrlVirtNet_SetNetworkType(vnet, PVN_BRIDGED_ETHERNET);
+prlsdkCheckRetGoto(pret, cleanup);
+
+job = PrlSrv_AddVirtualNetwork(privconn->server, vnet, 0);
+if (PRL_FAILED(pret = waitJob(job, privconn->jobTimeout)))
+goto cleanup;
+
+pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
+prlsdkCheckRetGoto(pret, cleanup);
+
 pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
 prlsdkCheckRetGoto(pret, cleanup);
 }
@@ -2674,10 +2715,34 @

[libvirt] [PATCH 1/7] parallels: introduce and use string constants for network types and names

2015-03-18 Thread Maxim Nestratov
Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_network.c |6 +++---
 src/parallels/parallels_sdk.c |6 +++---
 src/parallels/parallels_utils.h   |8 +++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/parallels/parallels_network.c 
b/src/parallels/parallels_network.c
index 1d3b694..bb7ec5e 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -211,12 +211,12 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 goto cleanup;
 }
 
-if (STREQ(tmp, "bridged")) {
+if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
 
 if (parallelsGetBridgedNetInfo(def, jobj) < 0)
 goto cleanup;
-} else if (STREQ(tmp, "host-only")) {
+} else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_NONE;
 
 if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
@@ -248,7 +248,7 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 
 def->forward.type = VIR_NETWORK_FORWARD_ROUTE;
 
-if (VIR_STRDUP(def->name, PARALLELS_ROUTED_NETWORK_NAME) < 0)
+if (VIR_STRDUP(def->name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
 goto cleanup;
 
 if (virUUIDParse(PARALLELS_ROUTED_NETWORK_UUID, def->uuid) < 0) {
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index a0b62cd..d3fb5d4 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -708,7 +708,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
  * always up */
 net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
 if (VIR_STRDUP(net->data.network.name,
-   PARALLELS_ROUTED_NETWORK_NAME) < 0)
+   PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
 goto cleanup;
 return 0;
 }
@@ -727,7 +727,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 
 if (emulatedType == PNA_ROUTED) {
 if (VIR_STRDUP(net->data.network.name,
-   PARALLELS_ROUTED_NETWORK_NAME) < 0)
+   PARALLELS_DOMAIN_ROUTED_NETWORK_NAME) < 0)
 goto cleanup;
 } else {
 pret = PrlVmDevNet_GetVirtualNetworkId(netAdapter, NULL, &buflen);
@@ -2658,8 +2658,8 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
virDomainNetDefPtr net)
 pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
 prlsdkCheckRetGoto(pret, cleanup);
 
-if (STREQ(net->data.network.name, PARALLELS_ROUTED_NETWORK_NAME)) {
 pret = PrlVmDev_SetEmulatedType(sdknet, PNA_ROUTED);
+if (STREQ(net->data.network.name, PARALLELS_DOMAIN_ROUTED_NETWORK_NAME)) {
 prlsdkCheckRetGoto(pret, cleanup);
 } else {
 pret = PrlVmDevNet_SetVirtualNetworkId(sdknet, net->data.network.name);
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 394548a..0f29374 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -47,7 +47,13 @@
_("no domain with matching uuid '%s'"), uuidstr); \
 } while (0)
 
-# define PARALLELS_ROUTED_NETWORK_NAME   "Routed"
+# define PARALLELS_DOMAIN_ROUTED_NETWORK_NAME   "Routed"
+# define PARALLELS_DOMAIN_BRIDGED_NETWORK_NAME  "Bridged"
+
+# define PARALLELS_REQUIRED_HOSTONLY_NETWORK "Host-Only"
+# define PARALLELS_HOSTONLY_NETWORK_TYPE "host-only"
+# define PARALLELS_REQUIRED_BRIDGED_NETWORK  "Bridged"
+# define PARALLELS_BRIDGED_NETWORK_TYPE  "bridged"
 
 struct _parallelsConn {
 virMutex lock;
-- 
1.7.1

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


[libvirt] [PATCH 2/7] parallels: fix parallelsLoadNetworks

2015-03-18 Thread Maxim Nestratov
Don't fail initialization of parallels driver if
parallelsLoadNetwork fails for optional networks.
This can happen when some of them are added manually
and configured incompletely. PCS requires only two networks
created automatically (named Host-Only and Bridged), others
are optional and their incompletenes can be ignored.

Signed-off-by: Maxim Nestratov 
---
 src/parallels/parallels_network.c |   43 +++-
 1 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/parallels/parallels_network.c 
b/src/parallels/parallels_network.c
index bb7ec5e..1d0ee1c 100644
--- a/src/parallels/parallels_network.c
+++ b/src/parallels/parallels_network.c
@@ -180,9 +180,10 @@ static int parallelsGetHostOnlyNetInfo(virNetworkDefPtr 
def, const char *name)
 return ret;
 }
 
-static virNetworkObjPtr
+static int
 parallelsLoadNetwork(parallelsConnPtr privconn, virJSONValuePtr jobj)
 {
+int ret = -1;
 virNetworkObjPtr net;
 virNetworkDefPtr def;
 const char *tmp;
@@ -214,13 +215,25 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 if (STREQ(tmp, PARALLELS_BRIDGED_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_BRIDGE;
 
-if (parallelsGetBridgedNetInfo(def, jobj) < 0)
+if (parallelsGetBridgedNetInfo(def, jobj) < 0) {
+
+/* Only mandatory networks are required to be configured 
completely */
+if (STRNEQ(def->name, PARALLELS_REQUIRED_BRIDGED_NETWORK))
+ret = 0;
+
 goto cleanup;
+}
 } else if (STREQ(tmp, PARALLELS_HOSTONLY_NETWORK_TYPE)) {
 def->forward.type = VIR_NETWORK_FORWARD_NONE;
 
-if (parallelsGetHostOnlyNetInfo(def, def->name) < 0)
+if (parallelsGetHostOnlyNetInfo(def, def->name) < 0) {
+
+/* Only mandatory networks are required to be configured 
completely */
+if (STRNEQ(def->name, PARALLELS_REQUIRED_HOSTONLY_NETWORK))
+ret = 0;
+
 goto cleanup;
+}
 } else {
 parallelsParseError();
 goto cleanup;
@@ -230,14 +243,16 @@ parallelsLoadNetwork(parallelsConnPtr privconn, 
virJSONValuePtr jobj)
 goto cleanup;
 net->active = 1;
 net->autostart = 1;
-return net;
+virNetworkObjEndAPI(&net);
+ret = 0;
+def = NULL;
 
  cleanup:
 virNetworkDefFree(def);
-return NULL;
+return ret;
 }
 
-static virNetworkObjPtr
+static int
 parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 {
 virNetworkObjPtr net = NULL;
@@ -264,18 +279,18 @@ parallelsAddRoutedNetwork(parallelsConnPtr privconn)
 }
 net->active = 1;
 net->autostart = 1;
+virNetworkObjEndAPI(&net);
 
-return net;
+return 0;
 
  cleanup:
 virNetworkDefFree(def);
-return NULL;
+return -1;
 }
 
 static int parallelsLoadNetworks(parallelsConnPtr privconn)
 {
 virJSONValuePtr jobj, jobj2;
-virNetworkObjPtr net = NULL;
 int ret = -1;
 int count;
 size_t i;
@@ -300,22 +315,18 @@ static int parallelsLoadNetworks(parallelsConnPtr 
privconn)
 goto cleanup;
 }
 
-net = parallelsLoadNetwork(privconn, jobj2);
-if (!net)
+ret = parallelsLoadNetwork(privconn, jobj2);
+if (!ret)
 goto cleanup;
-else
-virNetworkObjEndAPI(&net);
-
 }
 
-if (!(net = parallelsAddRoutedNetwork(privconn)))
+if (!(ret = parallelsAddRoutedNetwork(privconn)))
 goto cleanup;
 
 ret = 0;
 
  cleanup:
 virJSONValueFree(jobj);
-virNetworkObjEndAPI(&net);
 return ret;
 }
 
-- 
1.7.1

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


[libvirt] [PATCH v3 0/7] bridge network support enhancement and other network fixes

2015-03-18 Thread Maxim Nestratov
v3 change:
  Addressed Michal Privoznik's comments

Maxim Nestratov (7):
  parallels: introduce and use string constants for network types and
names
  parallels: fix parallelsLoadNetworks
  parallels: better bridge network interface support
  parallels: set correct network adapter device state
  parallels: make E1000 network adapter model default
  parallels: switch off offline management feature
  parallels: don't prevent domain define if VIR_DOMAIN_NET_TYPE_BRIDGE

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