Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-03-17 Thread Laine Stump
On 02/24/2015 04:17 AM, Antoni Segura Puimedon wrote:


 On Tue, Feb 24, 2015 at 3:30 AM, Laine Stump la...@redhat.com
 mailto:la...@redhat.com wrote:

 On 02/23/2015 08:48 PM, YAMAMOTO Takashi wrote:
  On Tue, Feb 24, 2015 at 2:20 AM, YAMAMOTO Takashi
 yamam...@valinux.co.jp mailto:yamam...@valinux.co.jp
  wrote:
 
  Adds the port type definitions and methods that will be used
 to bind
  interfaces to the Midonet virtual ports.
 
  virtnetdevmidonet.c adds the way to bind and unbind the ports by
  calling into the Midonet Host Agent control command line
 (installed
  with the midolman package).
 
  Signed-off-by: Antoni Segura Puimedon
 toni+libv...@midokura.com mailto:toni%2blibv...@midokura.com
 
  have you considered a script-based solution which would be able
  to cover openvswitch case as well?
 
 
  Can you elaborate? For script I can only think about having an
 xml node
  that can be specified for the port type that says what should
 be run for
  attachment (like with the ethernet mode). But I'm not sure how
 it would fit
  right now.
 
  i meant to have a run a script port type.
  the script runs ovs-vsctl, mm-ctl, or whatever internally.

 We actively avoid calling free-form scripts as much as possible. It is
 too difficult to support, and opens the possibility of security
 problems.

 For that matter, we even prefer to not call external binaries if
 we can
 avoid it, and eliminate existing executions of external binaries
 whenever we get the change. The only reason we agreed to executing
 ovs-vsctl is because there is no defined public API for Open vSwitch
 that uses a library, netlink message, ioctl, etc. (at least there
 wasn't
 at the time that code was added).


 I was wondering for some time if it would make it better for ovs and
  midonet, in terms of interoperability with the rest of the linux stack
 (in this case libvirt) if they exposed their methods to dbus. What do
  you think about that? (obviously that would take a few releases of
 both.


Just now saw this message. It would be really nice if they exposed their
methods *somehow* (I'm curious why you suggest dbus; what about netlink?
I have no love for netlink (or dbus), but other network things (aside
from NetworkManager) seem to use netlink.

The really important thing, though, is that whatever API is provided,
that it be *set in stone* and never change in a way that isn't backward
compatible. libvirt's API is an example of doing this successfully -
years have gone by and we haven't had to increment the .so major version.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PULL 13/13] migration: Expose 'cancelling' status to user

2015-03-17 Thread Juan Quintela
From: zhanghailiang zhang.zhanghaili...@huawei.com

'cancelling' status was introduced by commit 51cf4c1a, mainly to avoid a
possible start of a new migration process while the previous one still exists.
But we didn't expose this status to user, instead we returned the 'active' 
state.

Here, we expose it to the user (such as libvirt), 'cancelling' status only
occurs for a short window before the migration aborts, so for users,
if they cancel a migration process, it will observe 'cancelling' status
occasionally.

Testing revealed that with older libvirt (anything 1.2.13 or less) will
print an odd error message if the state is seen, but that the migration
is still properly cancelled. Newer libvirt will be patched to recognize
the new state without the odd error message.

Signed-off-by: zhanghailiang zhang.zhanghaili...@huawei.com
Reviewed-by: Eric Blake ebl...@redhat.com
Cc: libvir-list@redhat.com
Signed-off-by: Juan Quintela quint...@redhat.com
---
 migration/migration.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index d7a1e7d..bc42490 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -195,13 +195,11 @@ MigrationInfo *qmp_query_migrate(Error **errp)
 break;
 case MIGRATION_STATUS_SETUP:
 info-has_status = true;
-info-status = MIGRATION_STATUS_SETUP;
 info-has_total_time = false;
 break;
 case MIGRATION_STATUS_ACTIVE:
 case MIGRATION_STATUS_CANCELLING:
 info-has_status = true;
-info-status = MIGRATION_STATUS_ACTIVE;
 info-has_total_time = true;
 info-total_time = qemu_clock_get_ms(QEMU_CLOCK_REALTIME)
 - s-total_time;
@@ -237,7 +235,6 @@ MigrationInfo *qmp_query_migrate(Error **errp)
 get_xbzrle_cache_stats(info);

 info-has_status = true;
-info-status = MIGRATION_STATUS_COMPLETED;
 info-has_total_time = true;
 info-total_time = s-total_time;
 info-has_downtime = true;
@@ -259,13 +256,12 @@ MigrationInfo *qmp_query_migrate(Error **errp)
 break;
 case MIGRATION_STATUS_FAILED:
 info-has_status = true;
-info-status = MIGRATION_STATUS_FAILED;
 break;
 case MIGRATION_STATUS_CANCELLED:
 info-has_status = true;
-info-status = MIGRATION_STATUS_CANCELLED;
 break;
 }
+info-status = s-state;

 return info;
 }
-- 
2.1.0

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


Re: [libvirt] [PATCH 4/4] parallels: minor cleanup

2015-03-17 Thread Maxim Nestratov

17.03.2015 17:51, Michal Privoznik пишет:

On 13.03.2015 16:40, Maxim Nestratov wrote:

indentation is fixed, unnecessary error message removed,
unnecessary job freeing removed

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

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 1025da5..f6350df 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -698,7 +698,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
  goto cleanup;
  
  pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net-ifname, buflen);

-prlsdkCheckRetGoto(pret, cleanup);
+prlsdkCheckRetGoto(pret, cleanup);
  
  pret = PrlVmDev_GetIndex(netAdapter, netAdapterIndex);

  prlsdkCheckRetGoto(pret, cleanup);
@@ -1360,7 +1360,6 @@ prlsdkLoadDomains(parallelsConnPtr privconn)
  
   error:

  PrlHandle_Free(result);
-PrlHandle_Free(job);
  return -1;
  }
  
@@ -1740,8 +1739,6 @@ prlsdkDomainChangeState(virDomainPtr domain,
  
  pdom = dom-privateData;

  pret = chstate(privconn, pdom-sdkdom);
-virReportError(VIR_ERR_OPERATION_FAILED,
-   _(Can't change domain state: %d), pret);
  if (PRL_FAILED(pret)) {
  virResetLastError();
  


I'm having some difficulties applying this patch. Can you rebase to the
current master and resend? The problem is in the first chunk, I guess.

Michal

Sure. In a minute.

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

[libvirt] [PATCH v2] parallels: minor cleanup

2015-03-17 Thread Maxim Nestratov
v2 change:
rebased to the current master

indentation is fixed, unnecessary error message removed,
unnecessary job freeing removed

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

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index ee71bd6..a0b62cd 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -701,7 +701,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, virDomainNetDefPtr 
net, bool isCt)
 goto cleanup;
 
 pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net-ifname, buflen);
-prlsdkCheckRetGoto(pret, cleanup);
+prlsdkCheckRetGoto(pret, cleanup);
 
 if (isCt  netAdapterIndex == (PRL_UINT32) -1) {
 /* venet devices don't have mac address and
@@ -1350,7 +1350,6 @@ prlsdkLoadDomains(parallelsConnPtr privconn)
 
  error:
 PrlHandle_Free(result);
-PrlHandle_Free(job);
 return -1;
 }
 
@@ -1730,8 +1729,6 @@ prlsdkDomainChangeState(virDomainPtr domain,
 
 pdom = dom-privateData;
 pret = chstate(privconn, pdom-sdkdom);
-virReportError(VIR_ERR_OPERATION_FAILED,
-   _(Can't change domain state: %d), pret);
 if (PRL_FAILED(pret)) {
 virResetLastError();
 
-- 
1.7.1

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


[libvirt] [PATCH v2] rpm-build: use pkg-config to detect wireshark presence

2015-03-17 Thread Pavel Hrdina
Wireshark supports pkg-config since 1.11.3.  Right now we build
wireshark-dissectior tool as default trough rpm build only on
fedora = 21 and there is new wireshark that supports pkg-config.
If someone wants to build libvirt with wireshark-dissector against old
wireshark, they should specify the location by hand.

This patch is mainly to fix wrong dependency on wireshark binary as it
doesn't make sense to require that binary file to just get version info
of that package in makefile.

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---
 configure.ac| 66 ++---
 m4/virt-wireshark.m4| 44 +++
 tools/wireshark/src/Makefile.am |  2 +-
 3 files changed, 47 insertions(+), 65 deletions(-)
 create mode 100644 m4/virt-wireshark.m4

diff --git a/configure.ac b/configure.ac
index 2fedd1a..b5a05bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -247,6 +247,7 @@ LIBVIRT_CHECK_SELINUX
 LIBVIRT_CHECK_SSH2
 LIBVIRT_CHECK_SYSTEMD_DAEMON
 LIBVIRT_CHECK_UDEV
+LIBVIRT_CHECK_WIRESHARK
 LIBVIRT_CHECK_YAJL
 
 AC_MSG_CHECKING([for CPUID instruction])
@@ -2642,70 +2643,6 @@ AM_CONDITIONAL([HAVE_LIBNL], [test $have_libnl = 
yes])
 AC_SUBST([LIBNL_CFLAGS])
 AC_SUBST([LIBNL_LIBS])
 
-dnl wireshark dissector
-
-AC_ARG_WITH([wireshark-dissector],
-  [AS_HELP_STRING([--with-wireshark-dissector],
-[enable wireshark dissector plugin support @:@default=check@:@])],
-  [ with_wireshark_dissector=$withval ],
-  [ with_wireshark_dissector=check ])
-
-AC_DEFUN([LIBVIRT_WS_HANDLE_ERROR], [
-  if test $with_wireshark_dissector = yes; then
-AC_MSG_ERROR([$1])
-  else
-with_wireshark_dissector=no
-  fi
-])
-if test $with_wireshark_dissector != no; then
-dnl Check for XDR headers existence
-AC_CHECK_HEADERS([rpc/types.h])
-
-dnl Check for glib-2.0 existence
-PKG_CHECK_MODULES([GLIB], [glib-2.0], [
-  WS_DISSECTOR_CPPFLAGS=$WS_DISSECTOR_CPPFLAGS `$PKG_CONFIG --cflags 
glib-2.0`
-], [
-  LIBVIRT_WS_HANDLE_ERROR([pkg-config 'glib-2.0' is required for 
wireshark-dissector support])
-])
-
-dnl Search for wireshark(or tshark) command
-AC_PATH_PROG([WIRESHARK], [wireshark])
-AC_PATH_PROG([WIRESHARK], [tshark])
-if test -z $WIRESHARK; then
-LIBVIRT_WS_HANDLE_ERROR([command not found wireshark or tshark])
-else
-dnl Check for wireshark headers
-save_CPPFLAGS=$CPPFLAGS
-WS_DISSECTOR_CPPFLAGS=$WS_DISSECTOR_CPPFLAGS -I`dirname 
$WIRESHARK`/../include/wireshark
-CPPFLAGS=$CPPFLAGS $WS_DISSECTOR_CPPFLAGS
-AC_CHECK_HEADERS([wireshark/config.h],, [
-LIBVIRT_WS_HANDLE_ERROR([wireshark/config.h is required for 
wireshark-dissector support])
-])
-AC_CHECK_HEADERS([wireshark/epan/packet.h 
wireshark/epan/dissectors/packet-tcp.h],, [
-LIBVIRT_WS_HANDLE_ERROR([wireshark/epan/{packet,packet-tcp}.h are 
required for wireshark-dissector support])
-], [
-  #include wireshark/config.h
-])
-CPPFLAGS=$save_CPPFLAGS
-fi
-if test $with_wireshark_dissector != no; then
-with_wireshark_dissector=yes
-fi
-fi
-AC_SUBST([WS_DISSECTOR_CPPFLAGS])
-AM_CONDITIONAL([WITH_WIRESHARK_DISSECTOR], [test $with_wireshark_dissector = 
yes])
-
-AC_ARG_WITH([ws-plugindir],
-  [AS_HELP_STRING([--with-ws-plugindir],
-[wireshark plugins directory for use when installing wireshark plugin])],
-  [ws_plugindir=$withval])
-
-if test $with_wireshark_dissector != no  test -z $ws_plugindir; then
-ws_version=`$WIRESHARK -v | head -1 | cut -f 2 -d' '`
-ws_plugindir=$libdir/wireshark/plugins/$ws_version
-fi
-AC_SUBST([ws_plugindir])
-
 # Check for Linux vs. BSD ifreq members
 AC_CHECK_MEMBERS([struct ifreq.ifr_newname,
   struct ifreq.ifr_ifindex,
@@ -2937,6 +2874,7 @@ LIBVIRT_RESULT_SELINUX
 LIBVIRT_RESULT_SSH2
 LIBVIRT_RESULT_SYSTEMD_DAEMON
 LIBVIRT_RESULT_UDEV
+LIBVIRT_RESULT_WIRESHARK
 LIBVIRT_RESULT_YAJL
 AC_MSG_NOTICE([  libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
 AC_MSG_NOTICE([  dlopen: $DLOPEN_LIBS])
diff --git a/m4/virt-wireshark.m4 b/m4/virt-wireshark.m4
new file mode 100644
index 000..47204ed
--- /dev/null
+++ b/m4/virt-wireshark.m4
@@ -0,0 +1,44 @@
+dnl The libvirt.so wireshark plugin
+dnl
+dnl Copyright (C) 2015 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library.  If not, see
+dnl 

Re: [libvirt] [PATCH v2 3/4] qemu: Don't duplicate errors when settings stats period

2015-03-17 Thread Erik Skultety


On 03/16/2015 05:42 PM, Martin Kletzander wrote:
 On Mon, Mar 16, 2015 at 02:09:39PM +0100, Erik Skultety wrote:


 On 03/13/2015 05:17 PM, Martin Kletzander wrote:
 In order not to leave old error messages set, this patch refactors the
 code so the error is reported only when acted upon.  The only such place
 already rewrites any error, so cleaning up all the error reporting in
 qemuMonitorSetMemoryStatsPeriod() is enough.

 +/**
 + * qemuMonitorSetMemoryStatsPeriod:
 + *
 + * This function sets balloon stats update period.
 + *
 + * Returns 0 on success and -1 on error, but does *not* set an error.
 + */
  int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon,
  int period)
  {
  int ret = -1;
  VIR_DEBUG(mon=%p period=%d, mon, period);

 -if (!mon) {
 -virReportError(VIR_ERR_INVALID_ARG, %s,
 -   _(monitor must not be NULL));
 +if (!mon)
  return -1;
 -}

 -if (!mon-json) {
 -virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
 -   _(JSON monitor is required));
 +if (!mon-json)
 +return -1;
 +
 +if (period  0)
  return -1;
 -}

 Hmm. It is a nice idea, but I guess you might have forgotten to check
 the actual return value in qemuProcessStart (there are actually 2
 appearances in qemu_process.c) like we do in most cases.
 I found a piece of code (see below) where we check this correctly (so
 it's great you refactored this, otherwise reporting 2 identical messages
 would be sort of confusing)

 
 This function is called from three places.  When starting a domain,
 when attaching to a domain and from an API that requests change to
 this particular value.  First two calls are intentionally non-fatal
 and hence not acted upon, since such minor issue as setting the
 statistics gathering period shouldn't make domains non-startable.
 
In that case, it's an ACK.
Erik

--
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-17 Thread Ján Tomko
Hello and welcome!

Thanks for sending a patch to the part of documentation that has not
been touched for over 3 years.

Can you set your name in git to your full name? We prefer using those
instead of nicknames.

Since this patch is against the libvirt-cmdref.git repo, not the
libvirt.git repo, using --subject-prefix 'libvirt-cmdref PATCH' makes it
easier for reviewers - it took me a while to figure it out.

Jan

On Sun, Mar 15, 2015 at 10:45:46PM +0530, 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(-)
 
 diff --git a/source/cd.xml b/source/cd.xml
 index 78a13df..d4afbc9 100644
 --- a/source/cd.xml
 +++ b/source/cd.xml
 @@ -9,16 +9,46 @@
  /text
/description
  
 -  options /
 +  options
 +   parameter requirement=optional
 + keyword requirement=optional--dir/keyword
 + value type=string requirement=optionalpath/value
 + description
 +   text 
 +  directory to switch to (default: home or else root)
 +   /text
 +   text
 +   --dir itself is optional
 +   /text
 + /description  
 +/parameter
 +  /options
  
availability from=0.7.0 /
   
notes /
   
 -  examples type=usage /
 +  examples type=usage 
 +   example
 +terminal
 +virsh # bold cd /bold value/tmp/value /terminal
 +text
 + Changes the current working directory to value /tmp /tmp
 +/text
 +   /example
 +  /examples
  
examples type=fullcontext /
  
reference type=seealso /
 -
 +   item
 +link type=internal href=pwd/
 +name
 +  pwd
 +/name
 +description
 +  Displays the current directory
 +/description
 +   /item
 +  /reference
  /command
 -- 
 1.9.1
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list


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

Re: [libvirt] [PATCH python v10] Expose virDomainInterfacesAddresses to python binding

2015-03-17 Thread Nehal J Wani
On Mon, Mar 16, 2015 at 8:25 PM, Daniel P. Berrange berra...@redhat.com wrote:
 From: Nehal J Wani nehaljw.k...@gmail.com

 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
 lo 00:00:00:00:00:00ipv4 127.0.0.1/8
 lo 00:00:00:00:00:00ipv6 ::1/128
 eth3   52:54:00:20:70:3dipv4 192.168.105.240/16
 eth3   52:54:00:20:70:3dipv6 fe80::5054:ff:fe20:703d/64
 eth2   52:54:00:36:2a:e5N/A  N/A
 eth1   52:54:00:b1:70:19ipv4 192.168.105.201/16
 eth1   52:54:00:b1:70:19ipv4 192.168.201.195/16
 eth1   52:54:00:b1:70:19ipv6 fe80::5054:ff:feb1:7019/64
 eth0   52:54:00:2e:45:ceipv4 10.1.33.188/24
 eth0   52:54:00:2e:45:ceipv6 2001:db8:0:f101::2/64
 eth0   52:54:00:2e:45:ceipv6 fe80::5054:ff:fe2e:45ce/64

This example uses VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE, so the
commit message should be showing vnetX instead of ethX.


-- 
Nehal J Wani

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


Re: [libvirt] [PATCH v10 0/4] Introduce API to query IP addresses for given domain

2015-03-17 Thread Nehal J Wani
On Wed, Mar 11, 2015 at 4:39 PM, Daniel P. Berrange berra...@redhat.com wrote:
 In v10

  - Remove 'if' tests before access of hwaddr as it is always present
  - Switch remote protocol to use  remote_nonnull_string for hwaddr
as it can never be NUL
  - Misc typos Eric pointed out

 Nehal J Wani (4):
   domifaddr: Implement the public APIs
   domifaddr: Implement the remote protocol
   domifaddr: Implement the API for qemu
   domifaddr: Add virsh support

  daemon/remote.c  | 124 
  include/libvirt/libvirt-domain.h |  32 ++
  src/driver-hypervisor.h  |   6 ++
  src/libvirt-domain.c | 123 +++
  src/libvirt_public.syms  |   2 +
  src/qemu/qemu_agent.c| 204 
 +++
  src/qemu/qemu_agent.h|   4 +
  src/qemu/qemu_driver.c   | 175 +
  src/remote/remote_driver.c   | 103 
  src/remote/remote_protocol.x |  37 ++-
  src/remote_protocol-structs  |  25 +
  tests/qemuagenttest.c| 188 
  tools/virsh-domain-monitor.c | 146 
  tools/virsh.pod  |  16 +++
  14 files changed, 1184 insertions(+), 1 deletion(-)

 --
 2.1.0


Thank You, Daniel, for v9 and v10. I am quite elated to see this
pushed :) The quest started in June 2012
(https://www.redhat.com/archives/libvir-list/2012-June/msg00904.html),
resumed in July 2013
(http://www.redhat.com/archives/libvir-list/2013-July/msg01553.html)
and was granted entry in March 2015 :) Quite a long journey!

-- 
Nehal J Wani

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


Re: [libvirt] [PATCH 3/5] qemuAgentGetInterfaces: Don't error out on missing HW address

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 06:09:17PM +0100, Michal Privoznik wrote:
 On 17.03.2015 18:00, Michal Privoznik wrote:
  On 17.03.2015 17:58, Daniel P. Berrange wrote:
  On Tue, Mar 17, 2015 at 05:52:55PM +0100, Michal Privoznik wrote:
  Now that we allow HW address to be not present on our RPC layer,
  don't error out if qemu-ga hasn't provided any.
 
  Signed-off-by: Michal Privoznik mpriv...@redhat.com
  ---
   src/qemu/qemu_agent.c | 7 ---
   1 file changed, 7 deletions(-)
 
  diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
  index 5f90b15..a7b3279 100644
  --- a/src/qemu/qemu_agent.c
  +++ b/src/qemu/qemu_agent.c
  @@ -2054,13 +2054,6 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
   goto error;
   
   hwaddr = virJSONValueObjectGetString(tmp_iface, 
  hardware-address);
  -if (!hwaddr) {
  -virReportError(VIR_ERR_INTERNAL_ERROR, %s,
  -   _(qemu agent didn't provide
  -  'hardware-address' field));
  -goto error;
  -}
 
  Why would QEMU guest agent not provide the MAC address ? That sounds
  like it would be a bug if that ever happened surely.
  
  Not every network interface has a HW address, e.g. PTP devices don't
  have one. Therefore, qemu-ga doesn't return any if that's the case.
 
 This is from qga/qapi-schema.json:
 ##
 # @GuestNetworkInterface:
 #
 # @name: The name of interface for which info are being delivered
 #
 # @hardware-address: Hardware address of @name
 #
 # @ip-addresses: List of addresses assigned to @name
 #
 # Since: 1.1
 ##
 { 'type': 'GuestNetworkInterface',
   'data': {'name': 'str',
'*hardware-address': 'str',
'*ip-addresses': ['GuestIpAddress'] } }
 
 So the hardware address field is optional.

Ah, ok then.

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

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


Re: [libvirt] [PATCH 1/5] RPC: Allow HW address in remote_domain_interface struct to be NULL

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 05:52:53PM +0100, Michal Privoznik wrote:
 Not all NICs (esp. the virtual ones like TUN) must have a hardware
 address. Learn our RPC that it's possible.

s/Learn/Teach/

 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  daemon/remote.c  | 5 -
  include/libvirt/libvirt-domain.h | 2 +-
  src/libvirt-domain.c | 3 ++-
  src/remote/remote_driver.c   | 3 ++-
  src/remote/remote_protocol.x | 2 +-
  src/remote_protocol-structs  | 2 +-
  6 files changed, 11 insertions(+), 6 deletions(-)
 
 diff --git a/daemon/remote.c b/daemon/remote.c
 index 1dca64a..b6ea236 100644
 --- a/daemon/remote.c
 +++ b/daemon/remote.c
 @@ -6525,7 +6525,9 @@ remoteSerializeDomainInterface(virDomainInterfacePtr 
 *ifaces,
  if ((VIR_STRDUP(iface_ret-name, iface-name))  0)
  goto cleanup;
  
 -if ((VIR_STRDUP(iface_ret-hwaddr, iface-hwaddr))  0)
 +if (iface-hwaddr 
 +(VIR_ALLOC(iface_ret-hwaddr)  0 ||
 + VIR_STRDUP(*iface_ret-hwaddr, iface-hwaddr)  0))
  goto cleanup;
  
  if (iface-naddrs  REMOTE_DOMAIN_IP_ADDR_MAX) {
 @@ -6561,6 +6563,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr 
 *ifaces,
  for (i = 0; i  ifaces_count; i++) {
  remote_domain_interface *iface_ret = 
 (ret-ifaces.ifaces_val[i]);
  VIR_FREE(iface_ret-name);
 +VIR_FREE(*iface_ret-hwaddr);

This will crash if hwaddr was NULL, and also leak

   if (iface_ret-hwaddr)
   VIR_FREE(*iface_ret-hwaddr);
   VIR_FREE(iface_ret-hwaddr);

  VIR_FREE(iface_ret-hwaddr);
  for (j = 0; j  iface_ret-addrs.addrs_len; j++) {
  remote_domain_ip_addr *ip_addr =
 diff --git a/include/libvirt/libvirt-domain.h 
 b/include/libvirt/libvirt-domain.h
 index a026b9a..79ba3d7 100644
 --- a/include/libvirt/libvirt-domain.h
 +++ b/include/libvirt/libvirt-domain.h
 @@ -3760,7 +3760,7 @@ typedef struct _virDomainInterface virDomainInterface;
  typedef virDomainInterface *virDomainInterfacePtr;
  struct _virDomainInterface {
  char *name; /* interface name */
 -char *hwaddr;   /* hardware address */
 +char *hwaddr;   /* hardware address, may be NULL */
  unsigned int naddrs;/* number of items in @addrs */
  virDomainIPAddressPtr addrs;/* array of IP addresses */
  };
 diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
 index a3f179d..0bd9274 100644
 --- a/src/libvirt-domain.c
 +++ b/src/libvirt-domain.c
 @@ -11460,7 +11460,8 @@ virDomainFSInfoFree(virDomainFSInfoPtr info)
   *  ... do something with returned values, for example:
   *  for (i = 0; i  ifaces_count; i++) {
   *  printf(name: %s, ifaces[i]-name);
 - *  printf( hwaddr: %s, ifaces[i]-hwaddr);
 + *  if (ifaces[i]-hwaddr)
 + *  printf( hwaddr: %s, ifaces[i]-hwaddr);
   *
   *  for (j = 0; j  ifaces[i]-naddrs; j++) {
   *  virDomainIPAddressPtr ip_addr = ifaces[i]-addrs + j;
 diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
 index d89db47..e69f235 100644
 --- a/src/remote/remote_driver.c
 +++ b/src/remote/remote_driver.c
 @@ -7963,7 +7963,8 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
  if (VIR_STRDUP(iface-name, iface_ret-name)  0)
  goto cleanup;
  
 -if (VIR_STRDUP(iface-hwaddr, iface_ret-hwaddr)  0)
 +if (iface_ret-hwaddr 
 +VIR_STRDUP(iface-hwaddr, *iface_ret-hwaddr)  0)
  goto cleanup;
  
  if (iface_ret-addrs.addrs_len  REMOTE_DOMAIN_IP_ADDR_MAX) {
 diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
 index fe5fcdc..eb862e1 100644
 --- a/src/remote/remote_protocol.x
 +++ b/src/remote/remote_protocol.x
 @@ -3191,7 +3191,7 @@ struct remote_domain_ip_addr {
  
  struct remote_domain_interface {
  remote_nonnull_string name;
 -remote_nonnull_string hwaddr;
 +remote_string hwaddr;
  remote_domain_ip_addr addrsREMOTE_DOMAIN_IP_ADDR_MAX;
  };
  
 diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
 index 5f4ebff..b3e2e40 100644
 --- a/src/remote_protocol-structs
 +++ b/src/remote_protocol-structs
 @@ -2646,7 +2646,7 @@ struct remote_domain_ip_addr {
  };
  struct remote_domain_interface {
  remote_nonnull_string  name;
 -remote_nonnull_string  hwaddr;
 +remote_string  hwaddr;
  struct {
  u_int  addrs_len;
  remote_domain_ip_addr * addrs_val;

ACK with the inline fix applied

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 :|

--

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

2015-03-17 Thread Eric Blake
On 03/17/2015 06:39 AM, Jiri Denemark wrote:
 Signed-off-by: Jiri Denemark jdene...@redhat.com
 ---
  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.

-- 
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] rpm-build: use pkg-config to detect wireshark presence

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 09:18:06AM +0100, Pavel Hrdina wrote:
 Wireshark supports pkg-config since 1.11.3.  Right now we build
 wireshark-dissectior tool as default trough rpm build only on
 fedora = 21 and there is new wireshark that supports pkg-config.
 If someone wants to build libvirt with wireshark-dissector against old
 wireshark, they should specify the location by hand.
 
 This patch is mainly to fix wrong dependency on wireshark binary as it
 doesn't make sense to require that binary file to just get version info
 of that package in makefile.
 
 Signed-off-by: Pavel Hrdina phrd...@redhat.com

ACK


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

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


Re: [libvirt] [PATCH v2] rpm-build: use pkg-config to detect wireshark presence

2015-03-17 Thread Pavel Hrdina
On Tue, Mar 17, 2015 at 10:04:18AM +, Daniel P. Berrange wrote:
 On Tue, Mar 17, 2015 at 09:18:06AM +0100, Pavel Hrdina wrote:
  Wireshark supports pkg-config since 1.11.3.  Right now we build
  wireshark-dissectior tool as default trough rpm build only on
  fedora = 21 and there is new wireshark that supports pkg-config.
  If someone wants to build libvirt with wireshark-dissector against old
  wireshark, they should specify the location by hand.
  
  This patch is mainly to fix wrong dependency on wireshark binary as it
  doesn't make sense to require that binary file to just get version info
  of that package in makefile.
  
  Signed-off-by: Pavel Hrdina phrd...@redhat.com
 
 ACK

Thanks, pushed now.

Pavel

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

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


Re: [libvirt] [PATCH v2 4/4] conf: Use correct type for balloon stats period

2015-03-17 Thread Martin Kletzander

On Mon, Mar 16, 2015 at 02:10:35PM +0100, Erik Skultety wrote:



On 03/13/2015 05:17 PM, Martin Kletzander wrote:

We're parsing memballoon status period as unsigned int, but when we're
trying to set it, both we and qemu use signed int.  That means large
values will get wrapped around to negative one resulting in error.
Basically the same problem as commit e3a7b874 was dealing with when
updating live domain.

QEMU changed the accepted value to int64 in commit 1f9296b5, but even
values as INT_MAX don't make sense since the value passed means seconds.
Hence adding capability flag for this change isn't worth it.

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

Signed-off-by: Luyao Huang lhu...@redhat.com
Signed-off-by: Martin Kletzander mklet...@redhat.com
---
 docs/formatdomain.html.in | 2 ++
 src/conf/domain_conf.c| 9 +++--
 src/conf/domain_conf.h| 2 +-
 src/qemu/qemu_process.c   | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 40e2b29..7a11cc7 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5630,6 +5630,8 @@ qemu-kvm -net nic,model=? /dev/null
   only be made to the active guest.
   If the QEMU driver is not at the right
   revision, the attempt to set the period will fail.
+  Large values might be ignored, but this only affects
+  non-sensical numbers (i.e. many years).
   span class='since'Since 1.1.1, requires QEMU 1.5/span
 /p
   /dd


Just a nitpick, I'd probably avoid word construction non-sensical in our
docs (it's not even correct -- nonsensical) and simplify this to Large
values (i.e. many years) might be ignored.



In that case, I changed it to 'e.g.', adjusted the column width and
pushed.  Thanks for the reviews.


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

Re: [libvirt] [PATCHv2.5 05/10] qemu: memdev: Add infrastructure to load memory device information

2015-03-17 Thread Peter Krempa
On Fri, Mar 13, 2015 at 10:38:51 -0400, John Ferlan wrote:
 On 03/04/2015 11:24 AM, Peter Krempa wrote:
  When using 'dimm' memory devices with qemu, some of the information
  like the slot number and base address need to be reloaded from qemu
  after process start so that it reflects the actual state. The state then
  allows to use memory devices across migrations.
  ---
   src/qemu/qemu_domain.c   |  49 +
   src/qemu/qemu_domain.h   |   4 ++
   src/qemu/qemu_monitor.c  |  42 +++
   src/qemu/qemu_monitor.h  |  14 +
   src/qemu/qemu_monitor_json.c | 122 
  +++
   src/qemu/qemu_monitor_json.h |   5 ++
   src/qemu/qemu_process.c  |   4 ++
   7 files changed, 240 insertions(+)

...

  
  +
   /* Technically, qemuProcessStart can be called from inside
* QEMU_ASYNC_JOB_MIGRATION_IN, but we are okay treating this like
* a sync job since no other job can call into the domain until
  
 
 
 There's nothing through the qemuProcessAttach processing for this data
 (although there is balloon info processing)
 
 - Decision on error handling of -2 or not

All other places should handle well if qemu did not report the data.

 - Don't drop into the loop to look at returned data if we had -2 returned

I've added this, it would probably cause a crash.

 - And add some sort of qemuProcessAttach handling...

Since the command line parser is not implemeneted for memory devices and
I don't really find it worth bothering with making qemuProcessAttach
work with every new feature I would rather not try doing this.

 
 Just so it doesn't impede progress, I'm fine with a future follow-up
 patch for the qemuProcessAttach. Leaving only handling the second point
 above for an ACK

Peter


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

Re: [libvirt] [PATCH] qemu: fix some wrong indentation or types

2015-03-17 Thread Michal Privoznik
On 17.03.2015 03:34, Luyao Huang wrote:
 ---
  src/qemu/qemu_command.c | 23 +++
  1 file changed, 11 insertions(+), 12 deletions(-)

Tweaked the commit message a bit, ACKed and pushed.

Michal

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


[libvirt] [PATCH][libvirt-ruby] Rakefile: Build on Mac OS-X cleanly

2015-03-17 Thread Michal Privoznik
https://bugzilla.redhat.com/show_bug.cgi?id=1161338

There's this bug report, which suggests using '-arch x86_64' on
Macs. Otherwise one gets unclear error messages when building.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 Rakefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/Rakefile b/Rakefile
index 5ea1f41..e73eaee 100644
--- a/Rakefile
+++ b/Rakefile
@@ -148,6 +148,10 @@ SPEC = Gem::Specification.new do |s|
 s.license = LGPLv2
 end
 
+if RUBY_PLATFORM =~ /universal.x86_64-darwin/
+ENV['ARCHFLAGS'] = '-arch x86_64'
+end
+
 Gem::PackageTask.new(SPEC) do |pkg|
 pkg.need_tar = true
 pkg.need_zip = true
-- 
2.0.5

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


[libvirt] [PATCH][libvirt-ruby] Introduce .gitignore

2015-03-17 Thread Michal Privoznik
When building the project from a clean repo, there are some blobs
we don't want git to bother about. Just ignore them.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 .gitignore | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..68ad1d3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+ext/
+pkg/
-- 
2.0.5

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


Re: [libvirt] [PATCH v3] qemu: read backing chain names from qemu

2015-03-17 Thread Peter Krempa
On Mon, Mar 16, 2015 at 12:17:58 -0600, Eric Blake wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=1199182 documents that
 after a series of disk snapshots into existing destination images,
 followed by active commits of the top image, it is possible for
 qemu 2.2 and earlier to end up tracking a different name for the
 image than what it would have had when opening the chain afresh.
 That is, when starting with the chain 'a - b - c', the name
 associated with 'b' is how it was spelled in the metadata of 'c',
 but when starting with 'a', taking two snapshots into 'a - b - c',
 then committing 'c' back into 'b', the name associated with 'b' is
 now the name used when taking the first snapshot.
 
 Sadly, older qemu doesn't know how to treat different spellings of
 the same filename as identical files (it uses strcmp() instead of
 checking for the same inode), which means libvirt's attempt to
 commit an image using solely the names learned from qcow2 metadata
 fails with a cryptic:
 
 error: internal error: unable to execute QEMU command 'block-commit': Top 
 image file /tmp/images/c/../b/b not found
 
 even though the file exists.  Trying to teach libvirt the rules on
 which name qemu will expect is not worth the effort (besides, we'd
 have to remember it across libvirtd restarts, and track whether a
 file was opened via metadata or via snapshot creation for a given
 qemu process); it is easier to just always directly ask qemu what
 string it expects to see in the first place.
 
 As a safety valve, we validate that any name returned by qemu
 still maps to the same local file as we have tracked it, so that
 a compromised qemu cannot accidentally cause us to act on an
 incorrect file.
 
 * src/qemu/qemu_monitor.h (qemuMonitorDiskNameLookup): New
 prototype.
 * src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskNameLookup):
 Likewise.
 * src/qemu/qemu_monitor.c (qemuMonitorDiskNameLookup): New function.
 * src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskNameLookup)
 (qemuMonitorJSONDiskNameLookupOne): Likewise.
 * src/qemu/qemu_driver.c (qemuDomainBlockCommit)
 (qemuDomainBlockJobImpl): Use it.
 
 Signed-off-by: Eric Blake ebl...@redhat.com
 ---
 
 v3: better sanity checks in qemu_monitor_json, rebase
 and retested atop Peter's fixes for interlocking block jobs
 
  src/qemu/qemu_driver.c   |  28 ++--
  src/qemu/qemu_monitor.c  |  20 -
  src/qemu/qemu_monitor.h  |   8 +++-
  src/qemu/qemu_monitor_json.c | 102 
 ++-
  src/qemu/qemu_monitor_json.h |   9 +++-
  5 files changed, 149 insertions(+), 18 deletions(-)

ACK,

Peter


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

[libvirt] [PATCH] wireshark: fix VPATH build

2015-03-17 Thread Pavel Hrdina
Add $(top_builddir) paths to INCLUDES to fix VPATH build.

Signed-off-by: Pavel Hrdina phrd...@redhat.com
---

Pushed under build-breaker rule.

 tools/wireshark/src/Makefile.am | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/wireshark/src/Makefile.am b/tools/wireshark/src/Makefile.am
index d4edc65..a7d775f 100644
--- a/tools/wireshark/src/Makefile.am
+++ b/tools/wireshark/src/Makefile.am
@@ -20,9 +20,9 @@
 
 INCLUDES = \
   -I$(top_srcdir) \
-  -I$(top_srcdir)/src \
-  -I$(top_srcdir)/include \
-  -I$(top_srcdir)/gnulib/lib
+  -I$(top_srcdir)/src -I$(top_builddir)/src\
+  -I$(top_srcdir)/include -I$(top_builddir)/include\
+  -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib
 
 ws_plugin_LTLIBRARIES = libvirt.la
 libvirt_la_SOURCES= packet-libvirt.h packet-libvirt.c plugin.c
-- 
2.0.5

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


Re: [libvirt] [PATCH] network: Resolve Coverity FORWARD_NULL

2015-03-17 Thread Michal Privoznik
On 16.03.2015 14:16, John Ferlan wrote:
 The following is a long winded way to say this patch is avoiding a
 false positive.
 
 Coverity complains that calling networkPlugBandwidth() could eventually
 end up with a NULL dereference on iface-bandwidth because in the
 networkAllocateActualDevice there's a check of 'iface-bandwidth'
 before deciding to try to use the 'portgroup' if it exists or to not
 perferm the virNetDevBandwidthCopy if 'bandwidth' is not NULL.
 
 Later in networkPlugBandwidth the 'iface-bandwidth' is sourced from
 virDomainNetGetActualBandwidth - which would be either iface-bandwidth
 or (preferably) iface-data.network.actual-bandwidth which would have
 been filled in from either 'iface-bandwidth' or 'portgroup-bandwidth'
 back in networkAllocateActualDevice
 
 There *is* a check in networkCheckBandwidth for the result of the
 virDomainNetGetActualBandwidth being NULL and a return 1 based on
 that which would cause networkPlugBandwidth to exit properly and thus
 never hit the condition that Coverity complains about.
 
 However, since Coverity checks all paths - it somehow believes that
 a return of 0 by networkCheckBandwidth in this condition would end
 up causing the possible NULL dereference. The fix to silence Coverity
 is to not have networkCheckBandwidth also call virDomainNetGetActualBandwidth
 in order to get the ifaceBand, but rather have it accept it as an argument
 which causes Coverity to see that it's the exit condition of 1 that won't
 have the possible NULL dereference.  Since we're passing that, I added the
 passing of iface-mac rather than passing iface as well. This just hopefully
 makes sure someone doesn't undo this in the future...
 
 Signed-off-by: John Ferlan jfer...@redhat.com
 ---
  src/network/bridge_driver.c | 11 ++-
  1 file changed, 6 insertions(+), 5 deletions(-)
 
 diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
 index a007388..d885aa9 100644
 --- a/src/network/bridge_driver.c
 +++ b/src/network/bridge_driver.c
 @@ -3820,7 +3820,7 @@ networkAllocateActualDevice(virDomainDefPtr dom,
  (netdef-forward.type == VIR_NETWORK_FORWARD_NAT) ||
  (netdef-forward.type == VIR_NETWORK_FORWARD_ROUTE)) {
  /* for these forward types, the actual net type really *is*
 - *NETWORK; we just keep the info from the portgroup in
 + * NETWORK; we just keep the info from the portgroup in
   * iface-data.network.actual
   */
  iface-data.network.actual-type = VIR_DOMAIN_NET_TYPE_NETWORK;
 @@ -4593,17 +4593,17 @@ networkGetNetworkAddress(const char *netname, char 
 **netaddr)
   */
  static int
  networkCheckBandwidth(virNetworkObjPtr net,
 -  virDomainNetDefPtr iface,
 +  virNetDevBandwidthPtr ifaceBand,
 +  virMacAddr ifaceMac,
unsigned long long *new_rate)

Unfortunately not to be seen in this little context, but there's a
comment just before these lines describing function arguments. You need
to update it too.

  {
  int ret = -1;
  virNetDevBandwidthPtr netBand = net-def-bandwidth;
 -virNetDevBandwidthPtr ifaceBand = virDomainNetGetActualBandwidth(iface);
  unsigned long long tmp_floor_sum = net-floor_sum;
  unsigned long long tmp_new_rate = 0;
  char ifmac[VIR_MAC_STRING_BUFLEN];
  
 -virMacAddrFormat(iface-mac, ifmac);
 +virMacAddrFormat(ifaceMac, ifmac);
  
  if (ifaceBand  ifaceBand-in  ifaceBand-in-floor 
  !(netBand  netBand-in)) {
 @@ -4689,7 +4689,8 @@ networkPlugBandwidth(virNetworkObjPtr net,
  char ifmac[VIR_MAC_STRING_BUFLEN];
  virNetDevBandwidthPtr ifaceBand = virDomainNetGetActualBandwidth(iface);
  
 -if ((plug_ret = networkCheckBandwidth(net, iface, new_rate))  0) {
 +if ((plug_ret = networkCheckBandwidth(net, ifaceBand,
 +  iface-mac, new_rate))  0) {
  /* helper reported error */
  goto cleanup;
  }
 

Sad we must do this just to silent Coverity. ACK if you update te
networkCheckBandwidth comment.

Michal

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


Re: [libvirt] [PATCH 4/5] cmdDomIfAddr: Free @ip_addr_str

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 05:52:56PM +0100, Michal Privoznik wrote:
 The variable holds formatted suffix to each line printed out
 (address type, address and prefix). However, the variable is
 never freed. At the same time, honour fact, that data held in
 the variable is not constant.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  tools/virsh-domain-monitor.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

ACK


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

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


Re: [libvirt] [PATCH v3] qemu: read backing chain names from qemu

2015-03-17 Thread Eric Blake
On 03/17/2015 03:29 AM, Peter Krempa wrote:
 On Mon, Mar 16, 2015 at 12:17:58 -0600, Eric Blake wrote:
 https://bugzilla.redhat.com/show_bug.cgi?id=1199182 documents that
 after a series of disk snapshots into existing destination images,
 followed by active commits of the top image, it is possible for
 qemu 2.2 and earlier to end up tracking a different name for the
 image than what it would have had when opening the chain afresh.
 That is, when starting with the chain 'a - b - c', the name
 associated with 'b' is how it was spelled in the metadata of 'c',
 but when starting with 'a', taking two snapshots into 'a - b - c',
 then committing 'c' back into 'b', the name associated with 'b' is
 now the name used when taking the first snapshot.



 v3: better sanity checks in qemu_monitor_json, rebase
 and retested atop Peter's fixes for interlocking block jobs

  src/qemu/qemu_driver.c   |  28 ++--
  src/qemu/qemu_monitor.c  |  20 -
  src/qemu/qemu_monitor.h  |   8 +++-
  src/qemu/qemu_monitor_json.c | 102 
 ++-
  src/qemu/qemu_monitor_json.h |   9 +++-
  5 files changed, 149 insertions(+), 18 deletions(-)
 
 ACK,

Thanks; pushed.

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



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

Re: [libvirt] [PATCH 3/5] qemuAgentGetInterfaces: Don't error out on missing HW address

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 05:52:55PM +0100, Michal Privoznik wrote:
 Now that we allow HW address to be not present on our RPC layer,
 don't error out if qemu-ga hasn't provided any.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/qemu/qemu_agent.c | 7 ---
  1 file changed, 7 deletions(-)
 
 diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
 index 5f90b15..a7b3279 100644
 --- a/src/qemu/qemu_agent.c
 +++ b/src/qemu/qemu_agent.c
 @@ -2054,13 +2054,6 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
  goto error;
  
  hwaddr = virJSONValueObjectGetString(tmp_iface, 
 hardware-address);
 -if (!hwaddr) {
 -virReportError(VIR_ERR_INTERNAL_ERROR, %s,
 -   _(qemu agent didn't provide
 -  'hardware-address' field));
 -goto error;
 -}
 -

ACK


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 v4 4/9] virstoragefile: Always use virStorageSourceSetBackingStore to set backing store

2015-03-17 Thread Matthias Gatto
Replace the parts of the code where a backing store is set manually
with virStorageSourceSetBackingStore

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/conf/domain_conf.c|  3 ++-
 src/conf/storage_conf.c   | 16 +---
 src/qemu/qemu_driver.c|  8 
 src/storage/storage_backend_fs.c  |  8 +---
 src/storage/storage_backend_gluster.c |  4 ++--
 src/storage/storage_backend_logical.c |  9 ++---
 src/storage/storage_driver.c  |  2 +-
 src/util/virstoragefile.c |  8 +---
 tests/virstoragetest.c|  4 ++--
 9 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3fd73d7..74f6efa 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5869,7 +5869,8 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
 virDomainDiskBackingStoreParse(ctxt, backingStore)  0)
 goto cleanup;
 
-src-backingStore = backingStore;
+if (!virStorageSourceSetBackingStore(src, backingStore, 0))
+goto cleanup;
 ret = 0;
 
  cleanup:
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 7ca678b..a6753e6 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1255,6 +1255,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
 char *capacity = NULL;
 char *unit = NULL;
 char *backingStore = NULL;
+virStorageSourcePtr backingStorePtr;
 xmlNodePtr node;
 xmlNodePtr *nodes = NULL;
 size_t i;
@@ -1291,20 +1292,21 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
 }
 
 if ((backingStore = virXPathString(string(./backingStore/path), ctxt))) {
-if (VIR_ALLOC(ret-target.backingStore)  0)
+if (VIR_ALLOC(backingStorePtr)  0)
 goto error;
 
-ret-target.backingStore-path = backingStore;
+virStorageSourceSetBackingStore(ret-target, backingStorePtr, 0);
+backingStorePtr-path = backingStore;
 backingStore = NULL;
 
 if (options-formatFromString) {
 char *format = 
virXPathString(string(./backingStore/format/@type), ctxt);
 if (format == NULL)
-ret-target.backingStore-format = options-defaultFormat;
+backingStorePtr-format = options-defaultFormat;
 else
-ret-target.backingStore-format = 
(options-formatFromString)(format);
+backingStorePtr-format = (options-formatFromString)(format);
 
-if (ret-target.backingStore-format  0) {
+if (backingStorePtr-format  0) {
 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_(unknown volume format type %s), format);
 VIR_FREE(format);
@@ -1313,9 +1315,9 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
 VIR_FREE(format);
 }
 
-if (VIR_ALLOC(ret-target.backingStore-perms)  0)
+if (VIR_ALLOC(backingStorePtr-perms)  0)
 goto error;
-if (virStorageDefParsePerms(ctxt, ret-target.backingStore-perms,
+if (virStorageDefParsePerms(ctxt, backingStorePtr-perms,
 ./backingStore/permissions,
 DEFAULT_VOL_PERM_MODE)  0)
 goto error;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e6fb2ae..8f33970 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -14123,12 +14123,12 @@ 
qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
 /* Update vm in place to match changes.  */
 need_unlink = false;
 
-newDiskSrc-backingStore = disk-src;
+virStorageSourceSetBackingStore(newDiskSrc, disk-src, 0);
 disk-src = newDiskSrc;
 newDiskSrc = NULL;
 
 if (persistDisk) {
-persistDiskSrc-backingStore = persistDisk-src;
+virStorageSourceSetBackingStore(persistDiskSrc, persistDisk-src, 0);
 persistDisk-src = persistDiskSrc;
 persistDiskSrc = NULL;
 }
@@ -14172,13 +14172,13 @@ 
qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver,
 /* Update vm in place to match changes. */
 tmp = disk-src;
 disk-src = virStorageSourceGetBackingStore(tmp, 0);
-tmp-backingStore = NULL;
+virStorageSourceSetBackingStore(tmp, NULL, 0);
 virStorageSourceFree(tmp);
 
 if (persistDisk) {
 tmp = persistDisk-src;
 persistDisk-src = virStorageSourceGetBackingStore(tmp, 0);
-tmp-backingStore = NULL;
+virStorageSourceSetBackingStore(tmp, NULL, 0);
 virStorageSourceFree(tmp);
 }
 }
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 8df2c0d..8c6d0b2 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -97,10 +97,12 @@ virStorageBackendProbeTarget(virStorageSourcePtr target,
 goto cleanup;
 
 if 

[libvirt] [PATCH v4 2/9] virstoragefile: Always use virStorageSourceGetBackingStore to get backing store

2015-03-17 Thread Matthias Gatto
Uniformize backing store usage by calling virStorageSourceGetBackingStore
instead of setting backing store manually.

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/conf/domain_conf.c|  7 ---
 src/conf/storage_conf.c   |  6 +++---
 src/qemu/qemu_cgroup.c|  4 ++--
 src/qemu/qemu_domain.c|  2 +-
 src/qemu/qemu_driver.c| 18 ++
 src/security/security_dac.c   |  2 +-
 src/security/security_selinux.c   |  4 ++--
 src/security/virt-aa-helper.c |  2 +-
 src/storage/storage_backend.c | 33 ++---
 src/storage/storage_backend_fs.c  | 33 ++---
 src/storage/storage_backend_gluster.c |  8 +---
 src/storage/storage_backend_logical.c | 10 ++
 src/util/virstoragefile.c | 20 ++--
 tests/virstoragetest.c| 14 +++---
 14 files changed, 88 insertions(+), 75 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c75b543..3fd73d7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -17252,7 +17252,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
 /* We currently don't output seclabels for backing chain element */
 if (virDomainDiskSourceFormatInternal(buf, backingStore, 0, 0, true)  0 ||
 virDomainDiskBackingStoreFormat(buf,
-backingStore-backingStore,
+
virStorageSourceGetBackingStore(backingStore, 0),
 backingStore-backingStoreRaw,
 idx + 1)  0)
 return -1;
@@ -17374,7 +17374,8 @@ virDomainDiskDefFormat(virBufferPtr buf,
 /* Don't format backingStore to inactive XMLs until the code for
  * persistent storage of backing chains is ready. */
 if (!(flags  VIR_DOMAIN_DEF_FORMAT_INACTIVE) 
-virDomainDiskBackingStoreFormat(buf, def-src-backingStore,
+virDomainDiskBackingStoreFormat(buf,
+
virStorageSourceGetBackingStore(def-src, 0),
 def-src-backingStoreRaw, 1)  0)
 return -1;
 
@@ -21456,7 +21457,7 @@ virDomainDiskDefForeachPath(virDomainDiskDefPtr disk,
 }
 }
 
-for (tmp = disk-src; tmp; tmp = tmp-backingStore) {
+for (tmp = disk-src; tmp; tmp = virStorageSourceGetBackingStore(tmp, 0)) {
 int actualType = virStorageSourceGetActualType(tmp);
 /* execute the callback only for local storage */
 if (actualType != VIR_STORAGE_TYPE_NETWORK 
diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index b070448..7ca678b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -1327,7 +1327,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool,
 if (virStorageSize(unit, capacity, ret-target.capacity)  0)
 goto error;
 } else if (!(flags  VIR_VOL_XML_PARSE_NO_CAPACITY) 
-   !((flags  VIR_VOL_XML_PARSE_OPT_CAPACITY)  
ret-target.backingStore)) {
+   !((flags  VIR_VOL_XML_PARSE_OPT_CAPACITY)  
virStorageSourceGetBackingStore(ret-target, 0))) {
 virReportError(VIR_ERR_XML_ERROR, %s, _(missing capacity element));
 goto error;
 }
@@ -1648,9 +1648,9 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
  def-target, target)  0)
 goto cleanup;
 
-if (def-target.backingStore 
+if (virStorageSourceGetBackingStore((def-target), 0) 
 virStorageVolTargetDefFormat(options, buf,
- def-target.backingStore,
+ 
virStorageSourceGetBackingStore((def-target), 0),
  backingStore)  0)
 goto cleanup;
 
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 3e30767..f04b0bf 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -121,7 +121,7 @@ qemuSetupDiskCgroup(virDomainObjPtr vm,
 virStorageSourcePtr next;
 bool forceReadonly = false;
 
-for (next = disk-src; next; next = next-backingStore) {
+for (next = disk-src; next; next = virStorageSourceGetBackingStore(next, 
0)) {
 if (qemuSetImageCgroupInternal(vm, next, false, forceReadonly)  0)
 return -1;
 
@@ -139,7 +139,7 @@ qemuTeardownDiskCgroup(virDomainObjPtr vm,
 {
 virStorageSourcePtr next;
 
-for (next = disk-src; next; next = next-backingStore) {
+for (next = disk-src; next; next = virStorageSourceGetBackingStore(next, 
0)) {
 if (qemuSetImageCgroup(vm, next, true)  0)
 return -1;
 }
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 2eacef2..9ac62e5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2736,7 +2736,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
 

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

2015-03-17 Thread Dimitri John Ledkov
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.
---
 examples/xml/nwfilter/Makefile.am |  2 +-
 src/conf/nwfilter_conf.h  |  1 +
 src/nwfilter/nwfilter_driver.c| 18 +++---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/examples/xml/nwfilter/Makefile.am 
b/examples/xml/nwfilter/Makefile.am
index ec1e7ee..61f328a 100644
--- a/examples/xml/nwfilter/Makefile.am
+++ b/examples/xml/nwfilter/Makefile.am
@@ -37,7 +37,7 @@ EXTRA_DIST=$(FILTERS)
 
 confdir = $(sysconfdir)/libvirt
 
-NWFILTER_DIR = $(DESTDIR)$(sysconfdir)/libvirt/nwfilter
+NWFILTER_DIR = $(DESTDIR)$(datadir)/libvirt/nwfilter
 
 if WITH_NWFILTER
 install-data-local:
diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h
index 6e68ecc..ee427b1 100644
--- a/src/conf/nwfilter_conf.h
+++ b/src/conf/nwfilter_conf.h
@@ -577,6 +577,7 @@ struct _virNWFilterDriverState {
 virNWFilterObjList nwfilters;
 
 char *configDir;
+char *defaultsDir;
 bool watchingFirewallD;
 };
 
diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 8e3db43..2e81dbf 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -173,7 +173,6 @@ nwfilterStateInitialize(bool privileged,
 virStateInhibitCallback callback ATTRIBUTE_UNUSED,
 void *opaque ATTRIBUTE_UNUSED)
 {
-char *base = NULL;
 DBusConnection *sysbus = NULL;
 
 if (!privileged)
@@ -228,17 +227,20 @@ nwfilterStateInitialize(bool privileged,
 goto error;
 }
 
-if (VIR_STRDUP(base, SYSCONFDIR /libvirt)  0)
+if (virAsprintf(driver-configDir,
+SYSCONFDIR /libvirt/nwfilter) == -1)
 goto error;
 
-if (virAsprintf(driver-configDir,
-%s/nwfilter, base) == -1)
+if (virNWFilterLoadAllConfigs(driver-nwfilters,
+  driver-configDir)  0)
 goto error;
 
-VIR_FREE(base);
+if (virAsprintf(driver-defaultsDir,
+PKGDATADIR /nwfilter) == -1)
+goto error;
 
 if (virNWFilterLoadAllConfigs(driver-nwfilters,
-  driver-configDir)  0)
+  driver-defaultsDir)  0)
 goto error;
 
 nwfilterDriverUnlock();
@@ -246,7 +248,6 @@ nwfilterStateInitialize(bool privileged,
 return 0;
 
  error:
-VIR_FREE(base);
 nwfilterDriverUnlock();
 nwfilterStateCleanup();
 
@@ -292,6 +293,8 @@ nwfilterStateReload(void)
 
 virNWFilterLoadAllConfigs(driver-nwfilters,
   driver-configDir);
+virNWFilterLoadAllConfigs(driver-nwfilters,
+  driver-defaultsDir);
 
 virNWFilterCallbackDriversUnlock();
 virNWFilterUnlockFilterUpdates();
@@ -345,6 +348,7 @@ nwfilterStateCleanup(void)
 virNWFilterObjListFree(driver-nwfilters);
 
 VIR_FREE(driver-configDir);
+VIR_FREE(driver-defaultsDir);
 nwfilterDriverUnlock();
 }
 
-- 
2.1.0

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


[libvirt] [PATCH v4 0/9] qemu: Add quorum support to libvirt

2015-03-17 Thread Matthias Gatto
The purpose of these patches is to introduce quorum for libvirt
I've try to follow this proposal:
http://www.redhat.com/archives/libvir-list/2014-May/msg00533.html

This feature ask for 6 task:

1) Allow a _virStorageSource to contain more than one backing store.

Because all the actual libvirt code use the backingStore field
as a pointer and we needs want to change that, I've decide to encapsulate
the backingStore field to simplifie the array manipulation.

2) Add the missing field a quorum need in _virStorageSource and
the VIR_STORAGE_TYPE_QUORUM and VIR_STORAGE_FILE_QUORUM in
their respectives enums.

3) Parse and format the xml
Because a quorum allows to have more than one backing store at the same level
we need to change virDomainDiskDefFormat and virDomainDiskDefParseXML
to call virDomainDiskBackingStoreFormat and virDomainDiskBackingStoreParse
in a loop.
virDomainDiskBackingStoreFormat and virDomainDiskBackingStoreParse can
call themself recursively in a loop because a quorum can contain another
quorum

4) Add nodename
We need to add nodename support in _virStorageSource because qemu
use them for their child.

5) Build qemu string
As for the xml, we have to call the function which create quorum recursively.
But this task have the problem explained here: 
http://www.redhat.com/archives/libvir-list/2014-October/msg00529.html
The _virStorageSource missing some informations that can be passed to
a child, and therefore this version of quorum is incomplet.

6) Allow to hotplug/change a disk in a quorum
This part is not present in these patches because for this task
we have to use blockdev-add, and currently libvirt use
device_add for hotpluging that doesn't allow to hotplug quorum childs.

There is 3 way to handle this problem:
  1) create a virDomainBlockDevAdd function in libvirt witch call
  blockdev-add.

  2) use blockdev-add instead of device_add in qemuMonitorJSONAddDevice

  3) write a hack which uses blockdev-add when only attaching quorum
  (but i'm pretty sure this solution is not the good one)

V2:
-Rebase on master
-Add Documentation

V3:
-Transforme the backingStore field in virStorageSource into
 an array of pointer instead of a pointer
-Modify virStorageSourceSetBackingStore to allow it to expand
 the backingStore size.

V4:
-Rebase on master

Matthias Gatto (9):
  virstoragefile: Add virStorageSourceGetBackingStore
  virstoragefile: Always use virStorageSourceGetBackingStore to get
backing store
  virstoragefile: Add virStorageSourceSetBackingStore
  virstoragefile: Always use virStorageSourceSetBackingStore to set
backing store
  virstoragefile: change backingStore to backingStores.
  virstoragefile: Add quorum in virstoragefile
  domain_conf: Read and Write quorum config
  qemu: Add quorum support in qemuBuildDriveDevStr
  virstoragefile: Add node-name

 docs/formatdomain.html.in |  27 -
 docs/schemas/domaincommon.rng |  95 +++--
 docs/schemas/storagecommon.rng|   1 +
 docs/schemas/storagevol.rng   |   1 +
 src/conf/domain_conf.c| 195 ++
 src/conf/storage_conf.c   |  22 ++--
 src/libvirt_private.syms  |   2 +
 src/qemu/qemu_cgroup.c|   4 +-
 src/qemu/qemu_command.c   | 114 
 src/qemu/qemu_domain.c|   2 +-
 src/qemu/qemu_driver.c|  30 +++---
 src/qemu/qemu_migration.c |   1 +
 src/security/security_dac.c   |   2 +-
 src/security/security_selinux.c   |   4 +-
 src/security/virt-aa-helper.c |   2 +-
 src/storage/storage_backend.c |  35 +++---
 src/storage/storage_backend_fs.c  |  37 ---
 src/storage/storage_backend_gluster.c |  10 +-
 src/storage/storage_backend_logical.c |  15 ++-
 src/storage/storage_driver.c  |   2 +-
 src/util/virstoragefile.c | 116 +---
 src/util/virstoragefile.h |  13 ++-
 tests/virstoragetest.c|  18 ++--
 23 files changed, 573 insertions(+), 175 deletions(-)

-- 
1.8.3.1

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


[libvirt] [PATCH v4 6/9] virstoragefile: Add quorum in virstoragefile

2015-03-17 Thread Matthias Gatto
Add VIR_STORAGE_TYPE_QUORUM in virStorageType.
Add VIR_STORAGE_FILE_QUORUM in virStorageFileFormat.

Add threshold value in _virStorageSource

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 docs/formatdomain.html.in  | 20 +-
 docs/schemas/domaincommon.rng  | 90 +++---
 docs/schemas/storagecommon.rng |  1 +
 docs/schemas/storagevol.rng|  1 +
 src/conf/domain_conf.c |  2 +
 src/qemu/qemu_command.c|  1 +
 src/qemu/qemu_driver.c |  4 ++
 src/qemu/qemu_migration.c  |  1 +
 src/util/virstoragefile.c  | 25 
 src/util/virstoragefile.h  |  3 ++
 10 files changed, 106 insertions(+), 42 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8d98915..6fb87fd 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1852,8 +1852,9 @@
 dd
 Valid values are file, block,
 dir (span class=sincesince 0.7.5/span),
-network (span class=sincesince 0.8.7/span), or
-volume (span class=sincesince 1.0.5/span)
+network (span class=sincesince 0.8.7/span),
+volume (span class=sincesince 1.0.5/span), or
+quorum (span class=sincesince 1.2.13/span)
 and refer to the underlying source for the disk.
 /dd
   dtcodedevice/code attribute
@@ -1914,6 +1915,14 @@
 codesnapshot='yes'/code with a transient disk generally
 does not make sense.
 /dd
+  dtcodethreshold/code attribute
+  span class=sincesince 1.2.13/span/dt
+dd
+Only use with a quorum disk.
+Indicate the minimum of positive vote a quorum must have to 
validate
+a data to be write. The minimum value is 2. The number of 
backingStores
+contain by the quorum must be superior to the threshold.
+/dd
 /dl
   /dd
   dtcodesource/code/dt
@@ -1984,6 +1993,11 @@
   
'file=/dev/disk/by-path/ip-example.com:3260-iscsi-iqn.2013-07.com.example:iscsi-pool-lun-1').
   /p
   /dd
+dtcodetype='quorum'/code
+span class=sincesince 1.2.13/span/dt
+  dd
+  A quorum contain no source element, but a serie of backingStores 
instead.
+  /dd
   /dl
 With file, block, and volume, one or more optional
 sub-elements codeseclabel/code, a href=#seclabeldescribed
@@ -2115,6 +2129,8 @@
 codebackingStore/code element means the sibling source is
 self-contained and is not based on any backing store. The following
 attributes and sub-elements are supported in
+span class=sinceSince 1.2.11/span. This elements is used to
+describe a quorum child.
 codebackingStore/code:
 dl
   dtcodetype/code attribute/dt
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ebd9299..5a76ae7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1290,6 +1290,40 @@
 /attribute
   /define
 
+  define name='diskDevice'
+choice
+  group
+optional
+  attribute name=device
+choice
+  valuefloppy/value
+  valuedisk/value
+  valuecdrom/value
+/choice
+  /attribute
+/optional
+  /group
+  group
+attribute name=device
+  choice
+valuelun/value
+  /choice
+/attribute
+optional
+  ref name=rawIO/
+/optional
+optional
+  attribute name=sgio
+choice
+  valuefiltered/value
+  valueunfiltered/value
+/choice
+  /attribute
+/optional
+  /group
+/choice
+  /define
+
   !--
   A disk description can be either of type file or block
   The name of the attribute on the source element depends on the type
@@ -1297,37 +1331,7 @@
 --
   define name=disk
 element name=disk
-  choice
-group
-  optional
-attribute name=device
-  choice
-valuefloppy/value
-valuedisk/value
-valuecdrom/value
-  /choice
-/attribute
-  /optional
-/group
-group
-  attribute name=device
-choice
-  valuelun/value
-/choice
-  /attribute
-  optional
-ref name=rawIO/
-  /optional
-  optional
-attribute name=sgio
-  choice
-valuefiltered/value
-valueunfiltered/value
-  /choice
-/attribute
-  /optional
-/group
-  /choice
+  ref name=diskDevice/
   optional
 ref name=snapshot/
   /optional
@@ -1339,9 +1343,15 @@
 

[libvirt] [PATCH v4 7/9] domain_conf: Read and Write quorum config

2015-03-17 Thread Matthias Gatto
Add the capabiltty to libvirt to parse and format the quorum syntax
as described here:
http://www.redhat.com/archives/libvir-list/2014-May/msg00533.html

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/conf/domain_conf.c | 164 +++--
 1 file changed, 119 insertions(+), 45 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 79dc29f..5ffa4ce 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5815,20 +5815,56 @@ virDomainDiskSourceParse(xmlNodePtr node,
 }
 
 
+static bool
+virDomainDiskThresholdParse(virStorageSourcePtr src,
+xmlNodePtr node)
+{
+char *threshold = virXMLPropString(node, threshold);
+int ret;
+
+if (!threshold) {
+virReportError(VIR_ERR_XML_ERROR,
+   %s, _(missing threshold in quorum));
+return false;
+}
+ret = virStrToLong_ul(threshold, NULL, 10, src-threshold);
+if (ret  0 || src-threshold  2) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(unexpected threshold %s),
+   threshold must be a decimal number superior to 2 
+ and inferior to the number of children);
+VIR_FREE(threshold);
+return false;
+}
+VIR_FREE(threshold);
+return true;
+}
+
+
 static int
 virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
-   virStorageSourcePtr src)
+   virStorageSourcePtr src,
+   xmlNodePtr node,
+   size_t pos)
 {
 virStorageSourcePtr backingStore = NULL;
 xmlNodePtr save_ctxt = ctxt-node;
-xmlNodePtr source;
+xmlNodePtr source = NULL;
 char *type = NULL;
 char *format = NULL;
 int ret = -1;
 
-if (!(ctxt-node = virXPathNode(./backingStore[*], ctxt))) {
-ret = 0;
-goto cleanup;
+if (src-type == VIR_STORAGE_TYPE_QUORUM) {
+if (!node) {
+ret = 0;
+goto cleanup;
+}
+ctxt-node = node;
+} else {
+if (!(ctxt-node = virXPathNode(./backingStore[*], ctxt))) {
+ret = 0;
+goto cleanup;
+}
 }
 
 if (VIR_ALLOC(backingStore)  0)
@@ -5860,6 +5896,25 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
 goto cleanup;
 }
 
+if (backingStore-type == VIR_STORAGE_TYPE_QUORUM) {
+xmlNodePtr cur = NULL;
+
+if (!virDomainDiskThresholdParse(backingStore, node))
+goto cleanup;
+
+for (cur = node-children; cur != NULL; cur = cur-next) {
+if (xmlStrEqual(cur-name, BAD_CAST backingStore)) {
+if ((virDomainDiskBackingStoreParse(ctxt,
+backingStore,
+cur,
+
backingStore-nBackingStores)  0)) {
+goto cleanup;
+}
+}
+}
+goto exit;
+}
+
 if (!(source = virXPathNode(./source, ctxt))) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_(missing disk backing store source));
@@ -5867,10 +5922,11 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
 }
 
 if (virDomainDiskSourceParse(source, ctxt, backingStore)  0 ||
-virDomainDiskBackingStoreParse(ctxt, backingStore)  0)
+virDomainDiskBackingStoreParse(ctxt, backingStore, NULL, 0)  0)
 goto cleanup;
 
-if (!virStorageSourceSetBackingStore(src, backingStore, 0))
+ exit:
+if (!virStorageSourceSetBackingStore(src, backingStore, pos))
 goto cleanup;
 ret = 0;
 
@@ -5883,7 +5939,6 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
 return ret;
 }
 
-
 #define VENDOR_LEN  8
 #define PRODUCT_LEN 16
 
@@ -6381,6 +6436,10 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 }
 } else if (xmlStrEqual(cur-name, BAD_CAST boot)) {
 /* boot is parsed as part of virDomainDeviceInfoParseXML */
+} else if (xmlStrEqual(cur-name, BAD_CAST backingStore)) {
+if (virDomainDiskBackingStoreParse(ctxt, def-src, cur,
+   def-src-nBackingStores)  
0)
+goto error;
 }
 }
 cur = cur-next;
@@ -6404,12 +6463,19 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
 def-device = VIR_DOMAIN_DISK_DEVICE_DISK;
 }
 
+if (def-src-type == VIR_STORAGE_TYPE_QUORUM 
+!virDomainDiskThresholdParse(def-src, node))
+goto error;
+
+snapshot = virXMLPropString(node, snapshot);
+
 /* Only CDROM and Floppy devices are allowed missing source path
  * to indicate no media present. LUN is for raw access CD-ROMs
  * that are not attached to a physical device 

[libvirt] [PATCH v4 9/9] virstoragefile: Add node-name

2015-03-17 Thread Matthias Gatto
Add nodename inside virstoragefile
During xml backingStore parsing, look for a nodename attribute in the disk
declaration if this one is a quorum, if a nodename is found, add it to
the virStorageSource otherwise create a new one with a random name.
Take inspiration from this patch to create the nodename:
http://lists.gnu.org/archive/html/qemu-devel/2014-05/msg03209.html

Durring xml backingStore formating, look for a nodename attribute inside the
virStorageSource struct, and add it to the disk element.

Use the nodename to create the quorum in qemuBuildQuorumStr.

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 docs/formatdomain.html.in |  7 +++
 docs/schemas/domaincommon.rng |  5 +
 src/conf/domain_conf.c| 27 +++
 src/qemu/qemu_command.c   |  3 +++
 src/util/virstoragefile.c |  4 
 src/util/virstoragefile.h |  1 +
 6 files changed, 47 insertions(+)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6fb87fd..80167e4 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2148,6 +2148,13 @@
 codevda[2]/code refers to the backing store with
 codeindex='2'/code of the disk with codevda/code target.
   /dd
+  dtcodenodename/code attribute
+  span class=sincesince 1.2.13/span/dt
+  dd
+When the backing store is a quorum child, we can use this attribute
+to define the node-name of a child. If this atribute is undefine,
+a random nodename is generate.
+  /dd
   dtcodeformat/code sub-element/dt
   dd
 The codeformat/code element contains codetype/code
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 5a76ae7..6e7c87f 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1363,6 +1363,11 @@
   /attribute
   interleave
 optional
+  attribute name=nodename
+text/
+  /attribute
+/optional
+optional
   ref name=diskDevice/
 /optional
 ref name=diskSource/
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 5ffa4ce..66e14d4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -56,6 +56,7 @@
 #include network_conf.h
 #include virtpm.h
 #include virstring.h
+#include virrandom.h
 
 #define VIR_FROM_THIS VIR_FROM_DOMAIN
 
@@ -5841,6 +5842,8 @@ virDomainDiskThresholdParse(virStorageSourcePtr src,
 }
 
 
+#define GEN_NODE_NAME_PREFIXlibvirt
+#define GEN_NODE_NAME_MAX_LEN   (sizeof(GEN_NODE_NAME_PREFIX) + 8 + 8)
 static int
 virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
virStorageSourcePtr src,
@@ -5883,6 +5886,26 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
 goto cleanup;
 }
 
+if (src-type == VIR_STORAGE_TYPE_QUORUM) {
+char *nodeName = NULL;
+
+if ((nodeName = virXMLPropString(ctxt-node, nodename))) {
+backingStore-nodeName = nodeName;
+} else {
+size_t len;
+
+if (VIR_ALLOC_N(nodeName, GEN_NODE_NAME_MAX_LEN)  0)
+goto cleanup;
+if (snprintf(nodeName, GEN_NODE_NAME_MAX_LEN,
+ %s%08x, GEN_NODE_NAME_PREFIX, (int)pos)  0)
+goto cleanup;
+for (len = strlen(nodeName); len  GEN_NODE_NAME_MAX_LEN - 1; 
++len)
+nodeName[len] = virRandomInt('Z' - 'A') + 'A';
+nodeName[GEN_NODE_NAME_MAX_LEN - 1] = '\0';
+backingStore-nodeName = nodeName;
+}
+}
+
 if (!(format = virXPathString(string(./format/@type), ctxt))) {
 virReportError(VIR_ERR_XML_ERROR, %s,
_(missing disk backing store format));
@@ -5938,6 +5961,8 @@ virDomainDiskBackingStoreParse(xmlXPathContextPtr ctxt,
 ctxt-node = save_ctxt;
 return ret;
 }
+#undef GEN_NODE_NAME_PREFIX
+#undef GEN_NODE_NAME_MAX_LEN
 
 #define VENDOR_LEN  8
 #define PRODUCT_LEN 16
@@ -17318,6 +17343,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf,
   type, idx);
 if (backingStore-threshold)
 virBufferAsprintf(buf,  threshold='%lu', 
backingStore-threshold);
+if (backingStore-nodeName)
+virBufferAsprintf(buf,  nodename='%s', backingStore-nodeName);
 virBufferAddLit(buf, \n);
 virBufferAdjustIndent(buf, 2);
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 5fc7956..26ddd89 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3495,6 +3495,9 @@ qemuBuildQuorumStr(virConnectPtr conn,
   toAppend, i,
   
virStorageFileFormatTypeToString(backingStore-format));
 
+virBufferAsprintf(opt, ,%schildren.%lu.node-name=%s,
+  toAppend, i, backingStore-nodeName);
+
 if 

Re: [libvirt] [PATCH 5/5] qemuGetDHCPInterfaces: Don't leak @network

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 05:52:57PM +0100, Michal Privoznik wrote:
 The function needs a pointer to the network to get list of DHCP
 leases. The pointer is obtained via virNetworkLookupByName() which
 requires callers to free the returned network once no longer needed.
 Otherwise it's leaked.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  src/qemu/qemu_driver.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

ACK


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] util: clean up #includes of virnetdevopenvswitch.h

2015-03-17 Thread Laine Stump
virnetdevopenvswitch.h declares a few functions that can be called to
add ports to and remove them from OVS bridges, and retrieve the
migration data for a port. It does not contain any data definitions
that are used by domain_conf.h. But for some reason, domain_conf.h
virnetdevopenvswitch.h should be directly #including it. This adds a
few lines to the project, but saves all the files that don't need it
from the extra computing, and makes the dependencies more clear cut.
---
 src/conf/domain_conf.h| 1 -
 src/lxc/lxc_driver.c  | 1 +
 src/lxc/lxc_process.c | 1 +
 src/qemu/qemu_hotplug.c   | 1 +
 src/qemu/qemu_migration.c | 3 ++-
 src/qemu/qemu_process.c   | 1 +
 6 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 4eb7742..9d314fa 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -42,7 +42,6 @@
 # include virnetdevmacvlan.h
 # include virsysinfo.h
 # include virnetdevvportprofile.h
-# include virnetdevopenvswitch.h
 # include virnetdevbandwidth.h
 # include virnetdevvlan.h
 # include virobject.h
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 98fbea8..245000d 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -49,6 +49,7 @@
 #include viralloc.h
 #include virnetdevbridge.h
 #include virnetdevveth.h
+#include virnetdevopenvswitch.h
 #include nodeinfo.h
 #include viruuid.h
 #include virstats.h
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 1e90c16..6c23a0b 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -37,6 +37,7 @@
 #include virnetdev.h
 #include virnetdevveth.h
 #include virnetdevbridge.h
+#include virnetdevopenvswitch.h
 #include virtime.h
 #include domain_nwfilter.h
 #include network/bridge_driver.h
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 32596a7..9e51f31 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -47,6 +47,7 @@
 #include virnetdev.h
 #include virnetdevbridge.h
 #include virnetdevtap.h
+#include virnetdevopenvswitch.h
 #include virnetdevmidonet.h
 #include device_conf.h
 #include virstoragefile.h
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 83be435..992e192 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1,7 +1,7 @@
 /*
  * qemu_migration.c: QEMU migration handling
  *
- * Copyright (C) 2006-2014 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -45,6 +45,7 @@
 #include virerror.h
 #include viralloc.h
 #include virfile.h
+#include virnetdevopenvswitch.h
 #include datatypes.h
 #include fdstream.h
 #include viruuid.h
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index c395b5b..afa2f1d 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -62,6 +62,7 @@
 #include virprocess.h
 #include virtime.h
 #include virnetdevtap.h
+#include virnetdevopenvswitch.h
 #include virnetdevmidonet.h
 #include virbitmap.h
 #include viratomic.h
-- 
2.1.0

--
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-17 Thread Daniel P. Berrange
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.

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


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

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


Re: [libvirt] [PATCH 2/5] virsh: Adapt to new HW address scenario

2015-03-17 Thread Daniel P. Berrange
On Tue, Mar 17, 2015 at 05:52:54PM +0100, Michal Privoznik wrote:
 Make sure we don't print (null) (which in fact is printf()'s
 cleverness anyway, not ours). If no HW address is present, print
 N/A string just like we do for other fields.
 
 Signed-off-by: Michal Privoznik mpriv...@redhat.com
 ---
  tools/virsh-domain-monitor.c | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
 index c9bf156..0717076 100644
 --- a/tools/virsh-domain-monitor.c
 +++ b/tools/virsh-domain-monitor.c
 @@ -2278,7 +2278,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
  /* When the interface has no IP address */
  if (!iface-naddrs) {
  vshPrintExtra(ctl,  %-10s %-17s%-12s %s\n,
 -  iface-name, iface-hwaddr, N/A, N/A);
 +  iface-name,
 +  iface-hwaddr ? iface-hwaddr : N/A, N/A, 
 N/A);
  continue;
  }
  
 @@ -2312,7 +2313,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
  /* Don't repeat interface name */
  if (full || !j)
  vshPrintExtra(ctl,  %-10s %-17s%s\n,
 -  iface-name, iface-hwaddr, ip_addr_str);
 +  iface-name,
 +  iface-hwaddr ? iface-hwaddr : , 
 ip_addr_str);
  else
  vshPrintExtra(ctl,  %-10s %-17s%s\n,
-, -, ip_addr_str);

ACK

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

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


Re: [libvirt] [PATCH] util: clean up #includes of virnetdevopenvswitch.h

2015-03-17 Thread Laine Stump
On 03/17/2015 01:54 PM, Eric Blake wrote:
 On 03/17/2015 11:50 AM, Laine Stump wrote:
 virnetdevopenvswitch.h declares a few functions that can be called to
 add ports to and remove them from OVS bridges, and retrieve the
 migration data for a port. It does not contain any data definitions
 that are used by domain_conf.h. But for some reason, domain_conf.h
 virnetdevopenvswitch.h should be directly #including it. This adds a
 That sentence didn't read well.  Maybe

 But for some reason, domain_conf.h was directly #including
 virnetdevopenvswitch.h.

Urgh. Yes. Either I accidentally hit an arrow key while typing, or it's
another case of artifacts on the screen messing me up (although I've
only noticed that with Thunderbird, not with emacs).

Thanks!

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


Re: [libvirt] [PATCH] util: clean up #includes of virnetdevopenvswitch.h

2015-03-17 Thread Eric Blake
On 03/17/2015 12:59 PM, Laine Stump wrote:
 On 03/17/2015 01:54 PM, Eric Blake wrote:
 On 03/17/2015 11:50 AM, Laine Stump wrote:
 virnetdevopenvswitch.h declares a few functions that can be called to
 add ports to and remove them from OVS bridges, and retrieve the
 migration data for a port. It does not contain any data definitions
 that are used by domain_conf.h. But for some reason, domain_conf.h
 virnetdevopenvswitch.h should be directly #including it. This adds a
 That sentence didn't read well.  Maybe

 But for some reason, domain_conf.h was directly #including
 virnetdevopenvswitch.h.
 
 Urgh. Yes. Either I accidentally hit an arrow key while typing, or it's
 another case of artifacts on the screen messing me up (although I've
 only noticed that with Thunderbird, not with emacs).

Ah, I know what happened.  You typed 'domain_conf.h #includes ...', but
since '#includes' was at the start of a new line, git commit treated it
as a comment line and nuked that section of your sentence.  (I hate when
that happens - I've been bit when trying to paste terminal sequences run
as root where my prompt was #)

-- 
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 v4 3/9] virstoragefile: Add virStorageSourceSetBackingStore

2015-03-17 Thread Matthias Gatto
As explained for virStorageSourceGetBackingStore, quorum allows
multiple backing store, this make the operation to set bs complex
because we have to check if the backingStore is used as an array
or a pointer, and set it differently in both case.

In order to help the manipulation of backing store, I've added a
function virStorageSourceSetBackingStore.

For now virStorageSourceSetBackingStore don't handle the case where
we have more than one backing store in virStorageSource.

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/libvirt_private.syms  |  1 +
 src/util/virstoragefile.c | 10 ++
 src/util/virstoragefile.h |  3 +++
 3 files changed, 14 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 7b8038b..f7f8923 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2089,6 +2089,7 @@ virStorageSourceParseRBDColonString;
 virStorageSourcePoolDefFree;
 virStorageSourcePoolModeTypeFromString;
 virStorageSourcePoolModeTypeToString;
+virStorageSourceSetBackingStore;
 virStorageTypeFromString;
 virStorageTypeToString;
 
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index ef8053d..9ee5aff 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1806,6 +1806,16 @@ virStorageSourceGetBackingStore(const virStorageSource 
*src,
 }
 
 
+bool
+virStorageSourceSetBackingStore(virStorageSourcePtr src,
+virStorageSourcePtr backingStore,
+size_t pos ATTRIBUTE_UNUSED)
+{
+src-backingStore = backingStore;
+return src-backingStore;
+}
+
+
 /**
  * virStorageSourcePtr:
  *
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index c37ddcf..85b8d6e 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -289,6 +289,9 @@ struct _virStorageSource {
 #  define DEV_BSIZE 512
 # endif
 
+bool virStorageSourceSetBackingStore(virStorageSourcePtr src,
+virStorageSourcePtr 
backingStore,
+size_t pos);
 virStorageSourcePtr virStorageSourceGetBackingStore(const virStorageSource 
*src,
 size_t pos);
 
-- 
1.8.3.1

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


[libvirt] [PATCH v4 8/9] qemu: Add quorum support in qemuBuildDriveDevStr

2015-03-17 Thread Matthias Gatto
Allow to libvirt to build the quorum string used by quemu.

Add 2 static functions: qemuBuildQuorumStr and
qemuBuildAndAppendDriveStrToVirBuffer.
qemuBuildQuorumStr is made because a quorum can have another quorum
as a child, so we may need to call qemuBuildQuorumStr recursively.

qemuBuildQuorumFileSourceStr was basically made to share
the code use to build the source between qemuBuildQuorumStr and
qemuBuildDriveStr, but there is some difference betwin the syntax
use by libvirt to declare a disk and the one qemu need to build a quorum:
a quorum need a syntaxe like:
domaine_name.children.X.file.filename=filename
where libvirt don't use file.filename= but directly file=.
Therfore I use this function only for quorum.

But as explained in the cover letter and here:
http://www.redhat.com/archives/libvir-list/2014-October/msg00529.html
We miss some informations in _virStorageSource to have a complet
quorum support in libvirt.
Ideally I'd like to refactore virDomainDiskDefFormat to allow
qemuBuildQuorumStr to call this function in a loop.

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/qemu/qemu_command.c | 110 
 1 file changed, 110 insertions(+)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index cf2c95e..5fc7956 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3407,6 +3407,111 @@ qemuCheckDiskConfig(virDomainDiskDefPtr disk)
 return -1;
 }
 
+static bool
+qemuBuildQuorumFileSourceStr(virConnectPtr conn,
+  virStorageSourcePtr src,
+  virBuffer *opt,
+  const char *toAppend)
+{
+char *source = NULL;
+int actualType = virStorageSourceGetActualType(src);
+
+if (qemuGetDriveSourceString(src, conn, source)  0)
+goto error;
+
+if (source) {
+
+virBufferAsprintf(opt, ,%sfilename=, toAppend);
+
+switch (actualType) {
+case VIR_STORAGE_TYPE_DIR:
+/* QEMU only supports magic FAT format for now */
+if (src-format  0 
+src-format != VIR_STORAGE_FILE_FAT) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(unsupported disk driver type for '%s'),
+   virStorageFileFormatTypeToString(src-format));
+goto error;
+}
+
+if (!src-readonly) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(cannot create virtual FAT disks in 
read-write mode));
+goto error;
+}
+
+virBufferAddLit(opt, fat:);
+
+break;
+
+default:
+break;
+}
+virBufferAsprintf(opt, %s, source);
+}
+
+return true;
+ error:
+return false;
+}
+
+
+static bool
+qemuBuildQuorumStr(virConnectPtr conn,
+   virDomainDiskDefPtr disk,
+   virStorageSourcePtr src,
+   virBuffer *opt,
+   const char *toAppend)
+{
+char *tmp = NULL;
+int ret;
+virStorageSourcePtr backingStore;
+size_t i;
+
+if (!src-threshold) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(threshold missing in the quorum configuration));
+return false;
+}
+if (src-nBackingStores  2) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(a quorum must have at last 2 children));
+return false;
+}
+if (src-threshold  src-nBackingStores) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(threshold must not exceed the number of childrens));
+return false;
+}
+virBufferAsprintf(opt, ,%svote-threshold=%lu,
+  toAppend, src-threshold);
+for (i = 0;  i  src-nBackingStores; ++i) {
+backingStore = virStorageSourceGetBackingStore(src, i);
+ret = virAsprintf(tmp, %schildren.%lu.file., toAppend, i);
+if (ret  0)
+return false;
+
+virBufferAsprintf(opt, ,%schildren.%lu.driver=%s,
+  toAppend, i,
+  
virStorageFileFormatTypeToString(backingStore-format));
+
+if (qemuBuildQuorumFileSourceStr(conn, backingStore, opt, tmp) == 
false)
+goto error;
+
+/* This operation avoid me to made another copy */
+tmp[ret - sizeof(file)] = '\0';
+if (backingStore-type == VIR_STORAGE_TYPE_QUORUM) {
+if (!qemuBuildQuorumStr(conn, disk, backingStore, opt, tmp))
+goto error;
+}
+VIR_FREE(tmp);
+}
+return true;
+ error:
+VIR_FREE(tmp);
+return false;
+}
+
 
 /* Qemu 1.2 and later have a binary flag -enable-fips that must be
  * used for VNC auth to obey FIPS settings; but the flag only
@@ -3880,6 +3985,11 @@ qemuBuildDriveStr(virConnectPtr conn,
   

[libvirt] [PATCH v4 1/9] virstoragefile: Add virStorageSourceGetBackingStore

2015-03-17 Thread Matthias Gatto
Create virStorageSourceGetBackingStore function in
preparation for quorum:
Actually, if we want to get a backing store inside a virStorageSource
we have to do it manually(src-backingStore = backingStore).
The problem is that with a quorum, a virStorageSource
can contain multiple backing stores, and src-backingStore can
be treated as a virStorageSourcePtr or a virStorageSourcePtrPtr.

Due to these reason, we need to simplify the manipulation of
virStorageSource, and create a function to get the asked
backingStore in a virStorageSource

For now, this function only return the backingStore field

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/libvirt_private.syms  | 1 +
 src/util/virstoragefile.c | 8 
 src/util/virstoragefile.h | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1fb42ac..7b8038b 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2079,6 +2079,7 @@ virStorageSourceClear;
 virStorageSourceCopy;
 virStorageSourceFree;
 virStorageSourceGetActualType;
+virStorageSourceGetBackingStore;
 virStorageSourceGetSecurityLabelDef;
 virStorageSourceInitChainElement;
 virStorageSourceIsEmpty;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 78a7a9f..9a3e39b 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1798,6 +1798,14 @@ virStorageSourcePoolDefCopy(const 
virStorageSourcePoolDef *src)
 }
 
 
+virStorageSourcePtr
+virStorageSourceGetBackingStore(const virStorageSource *src,
+size_t pos ATTRIBUTE_UNUSED)
+{
+return src-backingStore;
+}
+
+
 /**
  * virStorageSourcePtr:
  *
diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h
index b4c3808..c37ddcf 100644
--- a/src/util/virstoragefile.h
+++ b/src/util/virstoragefile.h
@@ -289,6 +289,9 @@ struct _virStorageSource {
 #  define DEV_BSIZE 512
 # endif
 
+virStorageSourcePtr virStorageSourceGetBackingStore(const virStorageSource 
*src,
+size_t pos);
+
 int virStorageFileProbeFormat(const char *path, uid_t uid, gid_t gid);
 int virStorageFileProbeFormatFromBuf(const char *path,
  char *buf,
-- 
1.8.3.1

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


[libvirt] [PATCH v4 5/9] virstoragefile: change backingStore to backingStores.

2015-03-17 Thread Matthias Gatto
The backingStore field was a virStorageSourcePtr.
because a quorum can contain more that one backingStore at the same level
it's now a 'virStorageSourcePtr *'.

This patch rename  src-backingStore to src-backingStores,
add a static function virStorageSourceExpandBackingStore
(virStorageSourcePushBackingStore in the V2) and made the necessary 
modification to
virStorageSourceSetBackingStore and virStorageSourceGetBackingStore.
virStorageSourceSetBackingStore can now expand size of src-backingStores
by calling virStorageSourceExpandBackingStore if necessary.

Signed-off-by: Matthias Gatto matthias.ga...@outscale.com
---
 src/storage/storage_backend.c|  2 +-
 src/storage/storage_backend_fs.c |  2 +-
 src/util/virstoragefile.c| 69 +++-
 src/util/virstoragefile.h|  3 +-
 4 files changed, 65 insertions(+), 11 deletions(-)

diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c
index 884c7cd..bee56a1 100644
--- a/src/storage/storage_backend.c
+++ b/src/storage/storage_backend.c
@@ -487,7 +487,7 @@ virStorageBackendCreateRaw(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 goto cleanup;
 }
 
-if (vol-target.backingStore) {
+if (vol-target.backingStores) {
 virReportError(VIR_ERR_NO_SUPPORT, %s,
_(backing storage not supported for raw volumes));
 goto cleanup;
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index 8c6d0b2..b9a7588 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -1042,7 +1042,7 @@ static int createFileDir(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 return -1;
 }
 
-if (vol-target.backingStore) {
+if (vol-target.backingStores) {
 virReportError(VIR_ERR_NO_SUPPORT, %s,
_(backing storage not supported for directories 
volumes));
 return -1;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 9da4bdf..b3d84b9 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -1798,21 +1798,66 @@ virStorageSourcePoolDefCopy(const 
virStorageSourcePoolDef *src)
 }
 
 
+/**
+ * virStorageSourceGetBackingStore:
+ * @src: virStorageSourcePtr containing the backing stores
+ * @pos: position of the backing store to get
+ *
+ * return the backingStore at the position of @pos
+ */
 virStorageSourcePtr
-virStorageSourceGetBackingStore(const virStorageSource *src,
-size_t pos ATTRIBUTE_UNUSED)
+virStorageSourceGetBackingStore(const virStorageSource *src, size_t pos)
+{
+if (!src || !src-backingStores || pos = src-nBackingStores)
+return NULL;
+return src-backingStores[pos];
+}
+
+
+/**
+ * virStorageSourcePushBackingStore:
+ *
+ * Expand src-backingStores and update src-nBackingStores
+ */
+static bool
+virStorageSourceExpandBackingStore(virStorageSourcePtr src, size_t nbr)
 {
-return src-backingStore;
+if (!src)
+return false;
+if (src-nBackingStores  0) {
+if (VIR_EXPAND_N(src-backingStores, src-nBackingStores, nbr)  0)
+return false;
+} else {
+if (VIR_ALLOC_N(src-backingStores, nbr)  0)
+return false;
+src-nBackingStores += nbr;
+}
+return true;
 }
 
 
+/**
+ * virStorageSourceSetBackingStore:
+ * @src: virStorageSourcePtr to hold @backingStore
+ * @backingStore: backingStore to store
+ * @pos: position of the backing store to store
+ *
+ * Set @backingStore at @pos in src-backingStores.
+ * If src-backingStores don't have the space to contain
+ * @backingStore, we expand src-backingStores
+ */
 bool
 virStorageSourceSetBackingStore(virStorageSourcePtr src,
 virStorageSourcePtr backingStore,
-size_t pos ATTRIBUTE_UNUSED)
+size_t pos)
 {
-src-backingStore = backingStore;
-return src-backingStore;
+if (!src)
+return false;
+if (pos = src-nBackingStores 
+!virStorageSourceExpandBackingStore(src, pos - src-nBackingStores + 
1))
+return false;
+src-backingStores[pos] = backingStore;
+return true;
 }
 
 
@@ -2023,6 +2068,8 @@ virStorageSourceIsEmpty(virStorageSourcePtr src)
 void
 virStorageSourceBackingStoreClear(virStorageSourcePtr def)
 {
+size_t i;
+
 if (!def)
 return;
 
@@ -2030,8 +2077,14 @@ virStorageSourceBackingStoreClear(virStorageSourcePtr 
def)
 VIR_FREE(def-backingStoreRaw);
 
 /* recursively free backing chain */
-virStorageSourceFree(virStorageSourceGetBackingStore(def, 0));
-virStorageSourceSetBackingStore(def, NULL, 0);
+for (i = 0; i  def-nBackingStores; ++i)
+virStorageSourceFree(virStorageSourceGetBackingStore(def, i));
+if (def-nBackingStores  0) {
+/* in this case def-backingStores is treat as an array so we have to 
free it*/
+VIR_FREE(def-backingStores);
+}
+def-nBackingStores 

Re: [libvirt] [PATCH python v10] Expose virDomainInterfacesAddresses to python binding

2015-03-17 Thread Nehal J Wani
On Wed, Mar 18, 2015 at 2:50 AM, Nehal J Wani nehaljw.k...@gmail.com wrote:
 On Mon, Mar 16, 2015 at 8:25 PM, Daniel P. Berrange berra...@redhat.com 
 wrote:
 From: Nehal J Wani nehaljw.k...@gmail.com

 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
 lo 00:00:00:00:00:00ipv4 127.0.0.1/8
 lo 00:00:00:00:00:00ipv6 ::1/128
 eth3   52:54:00:20:70:3dipv4 192.168.105.240/16
 eth3   52:54:00:20:70:3dipv6 fe80::5054:ff:fe20:703d/64
 eth2   52:54:00:36:2a:e5N/A  N/A
 eth1   52:54:00:b1:70:19ipv4 192.168.105.201/16
 eth1   52:54:00:b1:70:19ipv4 192.168.201.195/16
 eth1   52:54:00:b1:70:19ipv6 fe80::5054:ff:feb1:7019/64
 eth0   52:54:00:2e:45:ceipv4 10.1.33.188/24
 eth0   52:54:00:2e:45:ceipv6 2001:db8:0:f101::2/64
 eth0   52:54:00:2e:45:ceipv6 fe80::5054:ff:fe2e:45ce/64

 This example uses VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LEASE, so the
 commit message should be showing vnetX instead of ethX.

In addition to above,
(i) 'lo' won't be available with lease store.
(ii) fd00::/8 are private ipv6 ranges. Hence should not be visible
through --source lease
(iii) 'N/A' is not possible in case of lease option. The underlying
API guarantees that.

Similar problem is present in the commit log for
2f36e6944e6eb56a00e19fcd85ec8513461597c9, but I guess no body wants to
mess with git history.



 --
 Nehal J Wani



-- 
Nehal J Wani

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


Re: [libvirt] Enhancing block/disk migration in libvirt

2015-03-17 Thread Tony Breeds
On Thu, Mar 12, 2015 at 01:05:21PM +0100, Kashyap Chamarthy wrote:
 On Tue, Feb 17, 2015 at 07:05:13PM +1100, Tony Breeds wrote:
  On Tue, Feb 17, 2015 at 09:02:57AM +0100, Michal Privoznik wrote:
  
   Oh, I forgot to paste the API name: virDomainMigrate3
  
  That'll narrow the search!  Thanks!
 
 Is there an upstream libvirt bug for this work? If not, can it be filed
 with the context from this thread for tracking purpose? I'm asking
 because, a few upstream OpenStack Nova folks expressed interest on IRC
 to track this work.
 
 URL to file:
 
 
 https://bugzilla.redhat.com/bugzilla/enter_bug.cgi?product=Virtualization%20Toolscomponent=libvirt

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

I called it out as a feature rather than bug but there is a place to track it.

This work is still important to me (and openstack) timing is such that I got
pulled into something that has delayed my start date on this work.

I've been contacted by a couple of people saying they'd benefit form the work
even though they do not use openstack.

Yours Tony.


pgpo0Pgx0pID9.pgp
Description: PGP signature
--
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-17 Thread Maxim Nestratov

17.03.2015 17:14, Michal Privoznik пишет:

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).

ACK though.

Michal
Michal, I got your message and absolutely agree with you. We suffer from 
this a lot and we'll rework this approach shortly.

Thank you for pointing this out.

Maxim

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

Re: [libvirt] [PATCH] util: clean up #includes of virnetdevopenvswitch.h

2015-03-17 Thread Eric Blake
On 03/17/2015 11:50 AM, Laine Stump wrote:
 virnetdevopenvswitch.h declares a few functions that can be called to
 add ports to and remove them from OVS bridges, and retrieve the
 migration data for a port. It does not contain any data definitions
 that are used by domain_conf.h. But for some reason, domain_conf.h
 virnetdevopenvswitch.h should be directly #including it. This adds a

That sentence didn't read well.  Maybe

But for some reason, domain_conf.h was directly #including
virnetdevopenvswitch.h.

 few lines to the project, but saves all the files that don't need it
 from the extra computing, and makes the dependencies more clear cut.
 ---
  src/conf/domain_conf.h| 1 -
  src/lxc/lxc_driver.c  | 1 +
  src/lxc/lxc_process.c | 1 +
  src/qemu/qemu_hotplug.c   | 1 +
  src/qemu/qemu_migration.c | 3 ++-
  src/qemu/qemu_process.c   | 1 +
  6 files changed, 6 insertions(+), 2 deletions(-)

ACK.

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



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

[libvirt] [PATCHv2 3/5] Allocate virtio-serial addresses when starting a domain

2015-03-17 Thread Ján Tomko
Instead of always using controller 0 and incrementing port number,
respect the maximum port numbers of controllers and use all of them.

Ports for virtio consoles are quietly reserved, but not formatted
(neither in XML nor on QEMU command line).

Also rejects duplicate virtio-serial addresses.
https://bugzilla.redhat.com/show_bug.cgi?id=890606
https://bugzilla.redhat.com/show_bug.cgi?id=1076708
---
 src/conf/domain_conf.c | 29 --
 src/qemu/qemu_command.c| 63 ++
 src/qemu/qemu_domain.c |  1 +
 src/qemu/qemu_domain.h |  1 +
 src/qemu/qemu_process.c|  2 +
 .../qemuxml2argv-channel-virtio-auto.args  |  8 +--
 .../qemuxml2argv-channel-virtio-autoassign.args| 10 ++--
 .../qemuxml2xmlout-channel-virtio-auto.xml | 10 ++--
 8 files changed, 81 insertions(+), 43 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c75b543..89357d2 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3402,21 +3402,6 @@ 
virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
 
 chr-target.port = maxport + 1;
 }
-
-if (chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
-chr-info.addr.vioserial.port == 0) {
-int maxport = 0;
-
-for (i = 0; i  cnt; i++) {
-const virDomainChrDef *thischr = arrPtr[i];
-if (thischr-info.type == 
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
-thischr-info.addr.vioserial.controller == 
chr-info.addr.vioserial.controller 
-thischr-info.addr.vioserial.bus == 
chr-info.addr.vioserial.bus 
-(int)thischr-info.addr.vioserial.port  maxport)
-maxport = thischr-info.addr.vioserial.port;
-}
-chr-info.addr.vioserial.port = maxport + 1;
-}
 }
 
 /* set default path for virtio-rng random backend to /dev/random */
@@ -14526,20 +14511,6 @@ virDomainDefParseXML(xmlDocPtr xml,
 chr-targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO 
 chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
 chr-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL;
-
-if (chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
-chr-info.addr.vioserial.port == 0) {
-int maxport = 0;
-for (j = 0; j  i; j++) {
-virDomainChrDefPtr thischr = def-channels[j];
-if (thischr-info.type == 
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
-thischr-info.addr.vioserial.controller == 
chr-info.addr.vioserial.controller 
-thischr-info.addr.vioserial.bus == 
chr-info.addr.vioserial.bus 
-(int)thischr-info.addr.vioserial.port  maxport)
-maxport = thischr-info.addr.vioserial.port;
-}
-chr-info.addr.vioserial.port = maxport + 1;
-}
 }
 VIR_FREE(nodes);
 
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 02105c3..e7f86e1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1399,6 +1399,65 @@ qemuAssignSpaprVIOAddress(virDomainDefPtr def, 
virDomainDeviceInfoPtr info,
 return 0;
 }
 
+
+static int
+qemuDomainAssignVirtioSerialAddresses(virDomainDefPtr def,
+  virDomainObjPtr obj)
+{
+int ret = -1;
+size_t i;
+virDomainVirtioSerialAddrSetPtr addrs = NULL;
+qemuDomainObjPrivatePtr priv = NULL;
+
+if (!(addrs = virDomainVirtioSerialAddrSetCreate()))
+goto cleanup;
+
+if (virDomainVirtioSerialAddrSetAddControllers(addrs, def)  0)
+goto cleanup;
+
+if (virDomainDeviceInfoIterate(def, virDomainVirtioSerialAddrReserve,
+   addrs)  0)
+goto cleanup;
+
+VIR_DEBUG(Finished reserving existing ports);
+
+for (i = 0; i  def-nconsoles; i++) {
+virDomainChrDefPtr chr = def-consoles[i];
+if (chr-deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE 
+chr-targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
+if (virDomainVirtioSerialAddrAssign(addrs, chr-info, true)  0)
+goto cleanup;
+}
+}
+
+for (i = 0; i  def-nchannels; i++) {
+virDomainChrDefPtr chr = def-channels[i];
+if (chr-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL 
+chr-info.addr.vioserial.port == 0 
+virDomainVirtioSerialAddrAssign(addrs, chr-info, false)  0)
+goto cleanup;
+}
+
+if (obj  obj-privateData) {
+priv = obj-privateData;
+if (addrs) {
+/* if this is the live domain object, we persist the addresses */
+virDomainVirtioSerialAddrSetFree(priv-vioserialaddrs);
+   

[libvirt] [PATCHv2 0/5] Allocate virtio-serial addresses

2015-03-17 Thread Ján Tomko
https://bugzilla.redhat.com/show_bug.cgi?id=890606
https://bugzilla.redhat.com/show_bug.cgi?id=1076708

Ján Tomko (5):
  Add test for virtio serial port assignment
  Add functions to track virtio-serial addresses
  Allocate virtio-serial addresses when starting a domain
  Expand the address set when attaching a virtio-serial controller
  Assign an address when hotplugging a virtio-serial device

 src/conf/domain_addr.c | 348 +
 src/conf/domain_addr.h |  56 
 src/conf/domain_conf.c |  29 --
 src/libvirt_private.syms   |   9 +
 src/qemu/qemu_command.c|  63 
 src/qemu/qemu_domain.c |   1 +
 src/qemu/qemu_domain.h |   1 +
 src/qemu/qemu_hotplug.c|  31 +-
 src/qemu/qemu_process.c|   2 +
 tests/qemuhotplugtest.c|   2 +-
 .../qemuxml2argv-channel-virtio-auto.args  |   8 +-
 .../qemuxml2argv-channel-virtio-autoassign.args|  20 ++
 .../qemuxml2argv-channel-virtio-autoassign.xml |  50 +++
 tests/qemuxml2argvtest.c   |   2 +
 .../qemuxml2xmlout-channel-virtio-auto.xml |  10 +-
 15 files changed, 591 insertions(+), 41 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.xml

-- 
2.0.5

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

[libvirt] [PATCHv2 2/5] Add functions to track virtio-serial addresses

2015-03-17 Thread Ján Tomko
Create a sorted array of virtio-serial controllers.
Each of the elements contains the controller index
and a bitmap of available ports.

Buses are not tracked, because they aren't supported by QEMU.
---
 src/conf/domain_addr.c   | 348 +++
 src/conf/domain_addr.h   |  56 
 src/libvirt_private.syms |   9 ++
 3 files changed, 413 insertions(+)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index fb4a76f..d9d01fc 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -718,3 +718,351 @@ virDomainCCWAddressSetCreate(void)
 virDomainCCWAddressSetFree(addrs);
 return NULL;
 }
+
+
+#define VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS 31
+
+
+/* virDomainVirtioSerialAddrSetCreate
+ *
+ * Allocates an address set for virtio serial addresses
+ */
+virDomainVirtioSerialAddrSetPtr
+virDomainVirtioSerialAddrSetCreate(void)
+{
+virDomainVirtioSerialAddrSetPtr ret = NULL;
+
+if (VIR_ALLOC(ret)  0)
+return NULL;
+
+return ret;
+}
+
+static void
+virDomainVirtioSerialControllerFree(virDomainVirtioSerialControllerPtr cont)
+{
+if (cont) {
+virBitmapFree(cont-ports);
+VIR_FREE(cont);
+}
+}
+
+static ssize_t
+virDomainVirtioSerialAddrPlaceController(virDomainVirtioSerialAddrSetPtr addrs,
+ virDomainVirtioSerialControllerPtr 
cont)
+{
+size_t i;
+
+for (i = 0; i  addrs-ncontrollers; i++) {
+if (addrs-controllers[i]-idx = cont-idx)
+return i;
+}
+return -1;
+}
+
+static ssize_t
+virDomainVirtioSerialAddrFindController(virDomainVirtioSerialAddrSetPtr addrs,
+unsigned int idx)
+{
+size_t i;
+
+for (i = 0; i  addrs-ncontrollers; i++) {
+if (addrs-controllers[i]-idx == idx)
+return i;
+}
+return -1;
+}
+
+/* virDomainVirtioSerialAddrSetAddController
+ *
+ * Adds virtio serial ports of the existing controller
+ * to the address set.
+ */
+int
+virDomainVirtioSerialAddrSetAddController(virDomainVirtioSerialAddrSetPtr 
addrs,
+  virDomainControllerDefPtr cont)
+{
+int ret = -1;
+int ports;
+virDomainVirtioSerialControllerPtr cnt = NULL;
+ssize_t insertAt;
+
+if (cont-type != VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+return 0;
+
+ports = cont-opts.vioserial.ports;
+if (ports == -1)
+ports = VIR_DOMAIN_DEFAULT_VIRTIO_SERIAL_PORTS;
+
+VIR_DEBUG(Adding virtio serial controller index %u with %d
+   ports to the address set, cont-idx, ports);
+
+if (VIR_ALLOC(cnt)  0)
+goto cleanup;
+
+if (!(cnt-ports = virBitmapNew(ports)))
+goto cleanup;
+cnt-idx = cont-idx;
+
+insertAt = virDomainVirtioSerialAddrPlaceController(addrs, cnt);
+if (VIR_INSERT_ELEMENT(addrs-controllers, insertAt,
+   addrs-ncontrollers, cnt)  0)
+goto cleanup;
+
+ret = 0;
+
+ cleanup:
+virDomainVirtioSerialControllerFree(cnt);
+return ret;
+}
+
+/* virDomainVirtioSerialAddrSetAddControllers
+ *
+ * Adds virtio serial ports of controllers present in the domain definition
+ * to the address set.
+ */
+int
+virDomainVirtioSerialAddrSetAddControllers(virDomainVirtioSerialAddrSetPtr 
addrs,
+   virDomainDefPtr def)
+{
+size_t i;
+
+for (i = 0; i  def-ncontrollers; i++) {
+if (virDomainVirtioSerialAddrSetAddController(addrs,
+  def-controllers[i])  0)
+return -1;
+}
+
+return 0;
+}
+
+/* virDomainVirtioSerialAddrSetRemoveController
+ *
+ * Removes a virtio serial controller from the address set.
+ */
+int
+virDomainVirtioSerialAddrSetRemoveController(virDomainVirtioSerialAddrSetPtr 
addrs,
+ virDomainControllerDefPtr cont)
+{
+int ret = -1;
+ssize_t pos;
+
+if (cont-type != VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL)
+return 0;
+
+VIR_DEBUG(Removing virtio serial controller index %u 
+  from the address set, cont-idx);
+
+pos = virDomainVirtioSerialAddrFindController(addrs, cont-idx);
+
+if (pos = 0 
+VIR_DELETE_ELEMENT(addrs-controllers, pos, addrs-ncontrollers)  0)
+goto cleanup;
+
+ret = 0;
+
+ cleanup:
+return ret;
+}
+
+void
+virDomainVirtioSerialAddrSetFree(virDomainVirtioSerialAddrSetPtr addrs)
+{
+size_t i;
+if (addrs) {
+for (i = 0; i  addrs-ncontrollers; i++)
+virDomainVirtioSerialControllerFree(addrs-controllers[i]);
+VIR_FREE(addrs);
+}
+}
+
+static int
+virDomainVirtioSerialAddrNext(virDomainVirtioSerialAddrSetPtr addrs,
+  virDomainDeviceVirtioSerialAddress *addr,
+  bool allowZero)
+{
+int ret = -1;
+ssize_t port, start = 0;
+ssize_t i;
+unsigned int controller;
+
+/* 

[libvirt] [PATCHv2 1/5] Add test for virtio serial port assignment

2015-03-17 Thread Ján Tomko
Add a test to demonstrate the effect of this series.
---
 .../qemuxml2argv-channel-virtio-autoassign.args| 20 +
 .../qemuxml2argv-channel-virtio-autoassign.xml | 50 ++
 tests/qemuxml2argvtest.c   |  2 +
 3 files changed, 72 insertions(+)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.args
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.args 
b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.args
new file mode 100644
index 000..d64a228
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.args
@@ -0,0 +1,20 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c \
+-device virtio-serial-pci,id=virtio-serial0,max_ports=4,vectors=4,bus=pci.0\
+,addr=0x3 -device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
+-usb -hda /dev/HostVG/QEMUGuest1 \
+-chardev pty,id=charchannel0 -device virtserialport,bus=virtio-serial0.0,nr=1,\
+chardev=charchannel0,id=channel0,name=org.linux-kvm.port.0 \
+-chardev pty,id=charchannel1 -device virtserialport,bus=virtio-serial0.0,nr=2,\
+chardev=charchannel1,id=channel1,name=org.linux-kvm.port.foo \
+-chardev pty,id=charchannel2 -device virtserialport,bus=virtio-serial0.0,nr=1,\
+chardev=charchannel2,id=channel2,name=org.linux-kvm.port.bar \
+-chardev pty,id=charchannel3 -device virtserialport,bus=virtio-serial0.2,nr=1,\
+chardev=charchannel3,id=channel3,name=org.linux-kvm.port.wizz \
+-chardev pty,id=charchannel4 -device virtserialport,bus=virtio-serial0.0,nr=3,\
+chardev=charchannel4,id=channel4,name=org.linux-kvm.port.ooh \
+-chardev pty,id=charchannel5 -device virtserialport,bus=virtio-serial0.0,nr=4,\
+chardev=charchannel5,id=channel5,name=org.linux-kvm.port.lla \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.xml
new file mode 100644
index 000..ac0744e
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-autoassign.xml
@@ -0,0 +1,50 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory unit='KiB'219100/memory
+  currentMemory unit='KiB'219100/currentMemory
+  vcpu placement='static' cpuset='1-4,8-20,525'1/vcpu
+  os
+type arch='i686' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/qemu/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='hda' bus='ide'/
+  address type='drive' controller='0' bus='0' target='0' unit='0'/
+/disk
+controller type='usb' index='0'/
+controller type='ide' index='0'/
+controller type='virtio-serial' index='0' ports='4' vectors='4'/
+controller type='virtio-serial' index='1'
+  address type='pci' domain='0x' bus='0x00' slot='0x0a' 
function='0x0'/
+/controller
+channel type='pty'
+  target type='virtio' name='org.linux-kvm.port.0'/
+/channel
+channel type='pty'
+  target type='virtio' name='org.linux-kvm.port.foo'/
+/channel
+channel type='pty'
+  target type='virtio' name='org.linux-kvm.port.bar'/
+  address type='virtio-serial' controller='0' port='1'/
+/channel
+channel type='pty'
+  target type='virtio' name='org.linux-kvm.port.wizz'/
+  address type='virtio-serial' controller='0' bus='2'/
+/channel
+channel type='pty'
+  target type='virtio' name='org.linux-kvm.port.ooh'/
+/channel
+channel type='pty'
+  target type='virtio' name='org.linux-kvm.port.lla'/
+/channel
+memballoon model='virtio'/
+  /devices
+/domain
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index fcf5218..0ec68f4 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1070,6 +1070,8 @@ mymain(void)
 QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
 DO_TEST(channel-virtio-auto,
 QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
+DO_TEST(channel-virtio-autoassign,
+QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
 DO_TEST(console-virtio,
 QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
 DO_TEST(console-virtio-many,
-- 
2.0.5

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


[libvirt] [PATCH 4/6] parallels: report, that cdroms are readonly

2015-03-17 Thread Dmitry Guryanov
When retriving list of domains from PCS, set
readonly flag for cdrom devices.

Signed-off-by: Dmitry Guryanov dgurya...@parallels.com
---
 src/parallels/parallels_sdk.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 6b3321b..ea090b7 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -478,10 +478,12 @@ prlsdkGetDiskInfo(PRL_HANDLE prldisk,
 virDomainDiskSetFormat(disk, VIR_STORAGE_FILE_RAW);
 }
 
-if (isCdrom)
+if (isCdrom) {
 disk-device = VIR_DOMAIN_DISK_DEVICE_CDROM;
-else
+disk-src-readonly = true;
+} else {
 disk-device = VIR_DOMAIN_DISK_DEVICE_DISK;
+}
 
 pret = PrlVmDev_GetFriendlyName(prldisk, NULL, buflen);
 prlsdkCheckRetGoto(pret, cleanup);
-- 
2.1.0

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


[libvirt] [PATCHv2 4/5] Expand the address set when attaching a virtio-serial controller

2015-03-17 Thread Ján Tomko
---
 src/qemu/qemu_hotplug.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 7845fd1..b2f70d1 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -435,6 +435,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr 
driver,
 char *devstr = NULL;
 qemuDomainObjPrivatePtr priv = vm-privateData;
 bool releaseaddr = false;
+bool addedToAddrSet = false;
 
 if (virDomainControllerFind(vm-def, controller-type, controller-idx) = 
0) {
 virReportError(VIR_ERR_OPERATION_FAILED,
@@ -473,6 +474,12 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr 
driver,
 goto cleanup;
 }
 
+if (controller-type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL 
+virDomainVirtioSerialAddrSetAddController(priv-vioserialaddrs,
+  controller)  0)
+goto cleanup;
+addedToAddrSet = true;
+
 if (!(devstr = qemuBuildControllerDevStr(vm-def, controller, 
priv-qemuCaps, NULL)))
 goto cleanup;
 }
@@ -501,6 +508,9 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr 
driver,
 }
 
  cleanup:
+if (ret != 0  addedToAddrSet)
+virDomainVirtioSerialAddrSetRemoveController(priv-vioserialaddrs,
+ controller);
 if (ret != 0  releaseaddr)
 qemuDomainReleaseDeviceAddress(vm, controller-info, NULL);
 
-- 
2.0.5

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


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

2015-03-17 Thread Jiri Denemark
Signed-off-by: Jiri Denemark jdene...@redhat.com
---
 src/libvirt_private.syms  |   1 +
 src/util/vircgroup.c  |  19 ++--
 src/util/vircgrouppriv.h  |   4 +
 tests/vircgroupdata/all-in-one.mounts |   7 ++
 tests/vircgroupdata/all-in-one.parsed |  10 +++
 tests/vircgroupdata/cgroups1.mounts   |  30 +++
 tests/vircgroupdata/cgroups1.parsed   |  10 +++
 tests/vircgroupdata/cgroups2.mounts   |  22 +
 tests/vircgroupdata/cgroups2.parsed   |  10 +++
 tests/vircgroupdata/cgroups3.mounts   |  28 ++
 tests/vircgroupdata/cgroups3.parsed   |  10 +++
 tests/vircgroupdata/fedora-18.mounts  |  30 +++
 tests/vircgroupdata/fedora-18.parsed  |  10 +++
 tests/vircgroupdata/fedora-21.mounts  |  33 +++
 tests/vircgroupdata/fedora-21.parsed  |  10 +++
 tests/vircgroupdata/no-cgroups.mounts |  10 +++
 tests/vircgroupdata/no-cgroups.parsed |  10 +++
 tests/vircgroupdata/ovirt-node-6.6.mounts | 144 ++
 tests/vircgroupdata/ovirt-node-6.6.parsed |  10 +++
 tests/vircgroupdata/ovirt-node-7.1.mounts | 142 +
 tests/vircgroupdata/ovirt-node-7.1.parsed |  10 +++
 tests/vircgroupdata/rhel-7.1.mounts   |  31 +++
 tests/vircgroupdata/rhel-7.1.parsed   |  10 +++
 tests/vircgrouptest.c |  71 +++
 24 files changed, 666 insertions(+), 6 deletions(-)
 create mode 100644 tests/vircgroupdata/all-in-one.mounts
 create mode 100644 tests/vircgroupdata/all-in-one.parsed
 create mode 100644 tests/vircgroupdata/cgroups1.mounts
 create mode 100644 tests/vircgroupdata/cgroups1.parsed
 create mode 100644 tests/vircgroupdata/cgroups2.mounts
 create mode 100644 tests/vircgroupdata/cgroups2.parsed
 create mode 100644 tests/vircgroupdata/cgroups3.mounts
 create mode 100644 tests/vircgroupdata/cgroups3.parsed
 create mode 100644 tests/vircgroupdata/fedora-18.mounts
 create mode 100644 tests/vircgroupdata/fedora-18.parsed
 create mode 100644 tests/vircgroupdata/fedora-21.mounts
 create mode 100644 tests/vircgroupdata/fedora-21.parsed
 create mode 100644 tests/vircgroupdata/no-cgroups.mounts
 create mode 100644 tests/vircgroupdata/no-cgroups.parsed
 create mode 100644 tests/vircgroupdata/ovirt-node-6.6.mounts
 create mode 100644 tests/vircgroupdata/ovirt-node-6.6.parsed
 create mode 100644 tests/vircgroupdata/ovirt-node-7.1.mounts
 create mode 100644 tests/vircgroupdata/ovirt-node-7.1.parsed
 create mode 100644 tests/vircgroupdata/rhel-7.1.mounts
 create mode 100644 tests/vircgroupdata/rhel-7.1.parsed

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1fb42ac..ca27af4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1126,6 +1126,7 @@ virCgroupDenyAllDevices;
 virCgroupDenyDevice;
 virCgroupDenyDeviceMajor;
 virCgroupDenyDevicePath;
+virCgroupDetectMountsFromFile;
 virCgroupFree;
 virCgroupGetBlkioIoDeviceServiced;
 virCgroupGetBlkioIoServiced;
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index e54a079..5c392ac 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -338,18 +338,19 @@ virCgroupCopyMounts(virCgroupPtr group,
  * Process /proc/mounts figuring out what controllers are
  * mounted and where
  */
-static int
-virCgroupDetectMounts(virCgroupPtr group)
+int
+virCgroupDetectMountsFromFile(virCgroupPtr group,
+  const char *path,
+  bool checkLinks)
 {
 size_t i;
 FILE *mounts = NULL;
 struct mntent entry;
 char buf[CGROUP_MAX_VAL];
 
-mounts = fopen(/proc/mounts, r);
+mounts = fopen(path, r);
 if (mounts == NULL) {
-virReportSystemError(errno, %s,
- _(Unable to open /proc/mounts));
+virReportSystemError(errno, _(Unable to open %s), path);
 return -1;
 }
 
@@ -394,7 +395,7 @@ virCgroupDetectMounts(virCgroupPtr group)
 
 /* If it is a co-mount it has a filename like cpu,cpuacct
  * and we must identify the symlink path */
-if (strchr(tmp2 + 1, ',')) {
+if (checkLinks  strchr(tmp2 + 1, ',')) {
 *tmp2 = '\0';
 if (virAsprintf(linksrc, %s/%s,
 entry.mnt_dir, typestr)  0)
@@ -436,6 +437,12 @@ virCgroupDetectMounts(virCgroupPtr group)
 return -1;
 }
 
+static int
+virCgroupDetectMounts(virCgroupPtr group)
+{
+return virCgroupDetectMountsFromFile(group, /proc/mounts, true);
+}
+
 
 static int
 virCgroupCopyPlacement(virCgroupPtr group,
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
index 582be79..722863e 100644
--- a/src/util/vircgrouppriv.h
+++ b/src/util/vircgrouppriv.h
@@ -48,4 +48,8 @@ struct virCgroup {
 struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST];
 };
 
+int virCgroupDetectMountsFromFile(virCgroupPtr group,
+  

[libvirt] [PATCHv2 5/5] Assign an address when hotplugging a virtio-serial device

2015-03-17 Thread Ján Tomko
---
 src/qemu/qemu_hotplug.c | 21 +++--
 tests/qemuhotplugtest.c |  2 +-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index b2f70d1..3e8d398 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1533,6 +1533,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
 virDomainDefPtr vmdef = vm-def;
 char *devstr = NULL;
 char *charAlias = NULL;
+bool need_release = false;
+bool allowZero = false;
 
 if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE)) {
 virReportError(VIR_ERR_OPERATION_INVALID, %s,
@@ -1543,6 +1545,16 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
 if (qemuAssignDeviceChrAlias(vmdef, chr, -1)  0)
 goto cleanup;
 
+if (chr-deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE 
+chr-targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO)
+allowZero = true;
+
+if (virDomainVirtioSerialAddrAutoAssign(priv-vioserialaddrs,
+chr-info,
+allowZero)  0)
+goto cleanup;
+need_release = true;
+
 if (qemuBuildChrDeviceStr(devstr, vm-def, chr, priv-qemuCaps)  0)
 goto cleanup;
 
@@ -1574,6 +1586,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
  cleanup:
 if (ret  0  virDomainObjIsActive(vm))
 qemuDomainChrInsertPreAllocCleanup(vm-def, chr);
+if (ret  0  need_release)
+virDomainVirtioSerialAddrRelease(priv-vioserialaddrs, chr-info);
 VIR_FREE(charAlias);
 VIR_FREE(devstr);
 return ret;
@@ -3970,10 +3984,13 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
 goto cleanup;
 
 rc = qemuDomainWaitForDeviceRemoval(vm);
-if (rc == 0 || rc == 1)
+if (rc == 0 || rc == 1) {
+virDomainVirtioSerialAddrRelease(priv-vioserialaddrs, tmpChr-info);
 ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr);
-else
+} else {
 ret = 0;
+}
+
 
  cleanup:
 qemuDomainResetDeviceRemoval(vm);
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 12a7f71..ea2cf77 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -86,7 +86,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
 if (event)
 virQEMUCapsSet(priv-qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
 
-if (qemuDomainAssignPCIAddresses((*vm)-def, priv-qemuCaps, *vm)  0)
+if (qemuDomainAssignAddresses((*vm)-def, priv-qemuCaps, *vm)  0)
 goto cleanup;
 
 if (qemuAssignDeviceAliases((*vm)-def, priv-qemuCaps)  0)
-- 
2.0.5

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


[libvirt] [PATCH 1/6] parallels: fix headers in parallels_sdk.h

2015-03-17 Thread Dmitry Guryanov
Return value of functions prlsdkStart/Kill/Stop e.t.c.
is PRL_RESULT in parallels_sdk.c and int in parallels_sdk.h.
PRL_RESULT is int, so compiler didn't report errors.
Let's fix the difference.

Signed-off-by: Dmitry Guryanov dgurya...@parallels.com
---
 src/parallels/parallels_sdk.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index 694c19b..cb8d3fb 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -35,11 +35,11 @@ prlsdkAddDomain(parallelsConnPtr privconn, const unsigned 
char *uuid);
 int prlsdkUpdateDomain(parallelsConnPtr privconn, virDomainObjPtr dom);
 int prlsdkSubscribeToPCSEvents(parallelsConnPtr privconn);
 void prlsdkUnsubscribeFromPCSEvents(parallelsConnPtr privconn);
-int prlsdkStart(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-int prlsdkKill(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-int prlsdkStop(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-int prlsdkPause(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-int prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkStart(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkKill(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkStop(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkPause(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
 
 typedef PRL_RESULT (*prlsdkChangeStateFunc)(parallelsConnPtr privconn, 
PRL_HANDLE sdkdom);
 int
-- 
2.1.0

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


[libvirt] [PATCH 6/6] parallels: fix virDomainDefineXML for domain in saved state

2015-03-17 Thread Dmitry Guryanov
PCS doesn't store domain config in managed save state file.
It's forbidden to change config for VMs in this state.
It's possible to change config for containers, but after
restoring domain will have that new config, not a config,
which domain had at the moment of virDomainManagedSave.

So we need to handle this case differently from other states.
Let's forbid this operation, if config is changed and if it's
not changed - just do nothing.

Openstack/nova calls virDomainDefineXML on resume with
current domain config, so we can't forbid this operation
in managed save state.

Signed-off-by: Dmitry Guryanov dgurya...@parallels.com
---
 src/parallels/parallels_driver.c | 32 
 1 file changed, 28 insertions(+), 4 deletions(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 9be2c6b..80facb3 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -713,11 +713,35 @@ parallelsDomainDefineXMLFlags(virConnectPtr conn, const 
char *xml, unsigned int
 if (!olddom)
 goto cleanup;
 } else {
-if (prlsdkApplyConfig(conn, olddom, def))
-goto cleanup;
+int state, reason;
+
+state = virDomainObjGetState(olddom, reason);
+
+if (state == VIR_DOMAIN_SHUTOFF 
+reason == VIR_DOMAIN_SHUTOFF_SAVED) {
+
+/* PCS doesn't store domain config in managed save state file.
+ * It's forbidden to change config for VMs in this state.
+ * It's possible to change config for containers, but after
+ * restoring domain will have that new config, not a config,
+ * which domain had at the moment of virDomainManagedSave.
+ *
+ * So forbid this operation, if config is changed. If it's
+ * not changed - just do nothing. */
+
+if (!virDomainDefCheckABIStability(olddom-def, def)) {
+virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, %s,
+   _(Can't change domain configuration 
+ in managed save state));
+goto cleanup;
+}
+} else {
+if (prlsdkApplyConfig(conn, olddom, def))
+goto cleanup;
 
-if (prlsdkUpdateDomain(privconn, olddom))
-goto cleanup;
+if (prlsdkUpdateDomain(privconn, olddom))
+goto cleanup;
+}
 }
 
 retdom = virGetDomain(conn, def-name, def-uuid);
-- 
2.1.0

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


[libvirt] [PATCH 5/6] parallels: add controllers in prlsdkLoadDomain

2015-03-17 Thread Dmitry Guryanov
Call virDomainDefAddImplicitControllers to add disk
controllers, so virDomainDef, filled by this function
will look exactly like the one returned by virDomainDefParseString.

Signed-off-by: Dmitry Guryanov dgurya...@parallels.com
---
 src/parallels/parallels_sdk.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index ea090b7..4441524 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -1247,6 +1247,9 @@ prlsdkLoadDomain(parallelsConnPtr privconn,
 pret = PrlVmCfg_GetHomePath(sdkdom, pdom-home, buflen);
 prlsdkCheckRetGoto(pret, error);
 
+if (virDomainDefAddImplicitControllers(def)  0)
+goto error;
+
 if (olddom) {
 /* assign new virDomainDef without any checks */
 /* we can't use virDomainObjAssignDef, because it checks
-- 
2.1.0

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


[libvirt] [PATCH 2/6] parallels: split prlsdkDomainChangeState function

2015-03-17 Thread Dmitry Guryanov
Split function prlsdkDomainChangeState into
prlsdkDomainChangeStateLocked and prlsdkDomainChangeState.
So it can be used from places, where virDomainObj already
found and locked.

Signed-off-by: Dmitry Guryanov dgurya...@parallels.com
---
 src/parallels/parallels_sdk.c | 35 +--
 src/parallels/parallels_sdk.h |  4 
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index 0b2478e..e677d36 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -1704,22 +1704,14 @@ PRL_RESULT prlsdkResume(parallelsConnPtr privconn, 
PRL_HANDLE sdkdom)
 }
 
 int
-prlsdkDomainChangeState(virDomainPtr domain,
-prlsdkChangeStateFunc chstate)
+prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
+  virDomainObjPtr dom,
+  prlsdkChangeStateFunc chstate)
 {
-parallelsConnPtr privconn = domain-conn-privateData;
-virDomainObjPtr dom;
 parallelsDomObjPtr pdom;
 PRL_RESULT pret;
-int ret = -1;
 virErrorNumber virerr;
 
-dom = virDomainObjListFindByUUID(privconn-domains, domain-uuid);
-if (dom == NULL) {
-parallelsDomNotFoundError(domain);
-return -1;
-}
-
 pdom = dom-privateData;
 pret = chstate(privconn, pdom-sdkdom);
 virReportError(VIR_ERR_OPERATION_FAILED,
@@ -1737,12 +1729,27 @@ prlsdkDomainChangeState(virDomainPtr domain,
 }
 
 virReportError(virerr, %s, _(Can't change domain state.));
-goto cleanup;
+return -1;
 }
 
-ret = prlsdkUpdateDomain(privconn, dom);
+return prlsdkUpdateDomain(privconn, dom);
+}
 
- cleanup:
+int
+prlsdkDomainChangeState(virDomainPtr domain,
+prlsdkChangeStateFunc chstate)
+{
+parallelsConnPtr privconn = domain-conn-privateData;
+virDomainObjPtr dom;
+int ret = -1;
+
+dom = virDomainObjListFindByUUID(privconn-domains, domain-uuid);
+if (dom == NULL) {
+parallelsDomNotFoundError(domain);
+return -1;
+}
+
+ret = prlsdkDomainChangeStateLocked(privconn, dom, chstate);
 virObjectUnlock(dom);
 return ret;
 }
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index cb8d3fb..780a226 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -46,6 +46,10 @@ int
 prlsdkDomainChangeState(virDomainPtr domain,
 prlsdkChangeStateFunc chstate);
 int
+prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
+  virDomainObjPtr dom,
+  prlsdkChangeStateFunc chstate);
+int
 prlsdkApplyConfig(virConnectPtr conn,
   virDomainObjPtr dom,
   virDomainDefPtr new);
-- 
2.1.0

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


[libvirt] [PATCH 3/6] parallels: implement virDomainManagedSave

2015-03-17 Thread Dmitry Guryanov
Implement virDomainManagedSave api function. In PCS
this feature called suspend. You can suspend VM or
CT while it is in running or paused state. And after
resuming (or starting) it will have the same state, as
before suspend.

Signed-off-by: Dmitry Guryanov dgurya...@parallels.com
---
 src/parallels/parallels_driver.c | 69 +++-
 src/parallels/parallels_sdk.c| 21 
 src/parallels/parallels_sdk.h|  3 ++
 3 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index bf29a96..9be2c6b 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -971,6 +971,8 @@ parallelsDomainHasManagedSaveImage(virDomainPtr domain, 
unsigned int flags)
 {
 parallelsConnPtr privconn = domain-conn-privateData;
 virDomainObjPtr dom = NULL;
+int state, reason;
+int ret = 0;
 
 virCheckFlags(0, -1);
 
@@ -980,9 +982,72 @@ parallelsDomainHasManagedSaveImage(virDomainPtr domain, 
unsigned int flags)
 return -1;
 }
 
+state = virDomainObjGetState(dom, reason);
+if (state == VIR_DOMAIN_SHUTOFF  reason == VIR_DOMAIN_SHUTOFF_SAVED)
+ret = 1;
 virObjectUnlock(dom);
 
-return 0;
+return ret;
+}
+
+static int
+parallelsDomainManagedSave(virDomainPtr domain, unsigned int flags)
+{
+parallelsConnPtr privconn = domain-conn-privateData;
+virDomainObjPtr dom = NULL;
+int state, reason;
+int ret = -1;
+
+virCheckFlags(VIR_DOMAIN_SAVE_RUNNING |
+  VIR_DOMAIN_SAVE_PAUSED, -1);
+
+dom = virDomainObjListFindByUUID(privconn-domains, domain-uuid);
+if (dom == NULL) {
+parallelsDomNotFoundError(domain);
+return -1;
+}
+
+state = virDomainObjGetState(dom, reason);
+
+if (state == VIR_DOMAIN_RUNNING  (flags  VIR_DOMAIN_SAVE_PAUSED)) {
+ret = prlsdkDomainChangeStateLocked(privconn, dom, prlsdkPause);
+if (ret)
+goto cleanup;
+}
+
+ret = prlsdkDomainChangeStateLocked(privconn, dom, prlsdkSuspend);
+
+ cleanup:
+virObjectUnlock(dom);
+return ret;
+}
+
+static int
+parallelsDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
+{
+parallelsConnPtr privconn = domain-conn-privateData;
+virDomainObjPtr dom = NULL;
+int state, reason;
+int ret = -1;
+
+virCheckFlags(0, -1);
+
+dom = virDomainObjListFindByUUID(privconn-domains, domain-uuid);
+if (dom == NULL) {
+parallelsDomNotFoundError(domain);
+return -1;
+}
+
+state = virDomainObjGetState(dom, reason);
+
+if (!(state == VIR_DOMAIN_SHUTOFF  reason == VIR_DOMAIN_SHUTOFF_SAVED))
+goto cleanup;
+
+ret = prlsdkDomainManagedSaveRemove(privconn, dom);
+
+ cleanup:
+virObjectUnlock(dom);
+return ret;
 }
 
 static virHypervisorDriver parallelsDriver = {
@@ -1027,6 +1092,8 @@ static virHypervisorDriver parallelsDriver = {
 .connectIsSecure = parallelsConnectIsSecure, /* 1.2.5 */
 .connectIsAlive = parallelsConnectIsAlive, /* 1.2.5 */
 .domainHasManagedSaveImage = parallelsDomainHasManagedSaveImage, /* 1.2.13 
*/
+.domainManagedSave = parallelsDomainManagedSave, /* 1.2.14 */
+.domainManagedSaveRemove = parallelsDomainManagedSaveRemove, /* 1.2.14 */
 };
 
 static virConnectDriver parallelsConnectDriver = {
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index e677d36..6b3321b 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -1703,6 +1703,14 @@ PRL_RESULT prlsdkResume(parallelsConnPtr privconn, 
PRL_HANDLE sdkdom)
 return waitJob(job, privconn-jobTimeout);
 }
 
+PRL_RESULT prlsdkSuspend(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+{
+PRL_HANDLE job = PRL_INVALID_HANDLE;
+
+job = PrlVm_Suspend(sdkdom);
+return waitJob(job, privconn-jobTimeout);
+}
+
 int
 prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
   virDomainObjPtr dom,
@@ -3089,3 +3097,16 @@ prlsdkUnregisterDomain(parallelsConnPtr privconn, 
virDomainObjPtr dom)
 virDomainObjListRemove(privconn-domains, dom);
 return 0;
 }
+
+int
+prlsdkDomainManagedSaveRemove(parallelsConnPtr privconn, virDomainObjPtr dom)
+{
+parallelsDomObjPtr privdom = dom-privateData;
+PRL_HANDLE job;
+
+job = PrlVm_DropSuspendedState(privdom-sdkdom);
+if (PRL_FAILED(waitJob(job, privconn-jobTimeout)))
+return -1;
+
+return 0;
+}
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index 780a226..b084678 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -40,6 +40,7 @@ PRL_RESULT prlsdkKill(parallelsConnPtr privconn, PRL_HANDLE 
sdkdom);
 PRL_RESULT prlsdkStop(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
 PRL_RESULT prlsdkPause(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
 PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT 

[libvirt] [PATCH 0/6] parallels: implement managed save

2015-03-17 Thread Dmitry Guryanov
This patch is intended to implement all needed code, so
that suspend/resume in openstack nova will work.

It implements .domainHasManagedSaveImage, .domainManagedSave
and .domainManagedSaveRemove functions. Also it adds
workaround to parallelsDomainDefineXMLFlags to skip
applying configuration, if VM is in managed save state and
config hasn't been changed, because it's not possible
to change VM config in suspended state in PCS.


Dmitry Guryanov (6):
  parallels: fix headers in parallels_sdk.h
  parallels: split prlsdkDomainChangeState function
  parallels: implement virDomainManagedSave
  parallels: report, that cdroms are readonly
  parallels: add controllers in prlsdkLoadDomain
  parallels: fix virDomainDefineXML for domain in saved state

 src/parallels/parallels_driver.c | 101 +--
 src/parallels/parallels_sdk.c|  65 ++---
 src/parallels/parallels_sdk.h|  17 +--
 3 files changed, 157 insertions(+), 26 deletions(-)

-- 
2.1.0

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


Re: [libvirt] [PATCH 4/7] parallels: set network adapter device status to connected

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:52, Maxim Nestratov wrote:
 when a new network adapter device is added
 
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
 index f581fbb..9588163 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -2653,7 +2653,7 @@ 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, 1);
  prlsdkCheckRetGoto(pret, cleanup);
  
  if (net-ifname) {
 

Why? net-linkstate contains the link state requested by user in XML. I
think we should honour user's configuration.

Michal

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


[libvirt] [PATCHv3 06/12] conf: Add interface to parse and format memory device information

2015-03-17 Thread Peter Krempa
This patch adds code that parses and formats configuration for memory
devices.

A simple configuration would be:
memory model='dimm'
  target
size unit='KiB'524287/size
node0/node
  /target
/memory

A complete configuration of a memory device:
memory model='dimm'
  source
pagesize unit='KiB'4096/pagesize
nodemask1-3/nodemask
  /source
  target
size unit='KiB'524287/size
node1/node
  /target
/memory

This patch preemptively forbids use of the memory device in individual
drivers so the users are warned right away that the device is not
supported.
---

Notes:
Version 3:
- target node is stored now as unsigned and all uses are tweaked
- fixed documentation wording as suggested
- added documentation for behavior of memory element once memory devices 
are used

Version 2:
- dropped the ACPI prefix
- fixed memory leak in the free function
- tweaked docs

Version 3:
- target node is stored now as unsigned and all uses are tweaked
- fixed documentation wording as suggested

Version 2:
- dropped the ACPI prefix
- fixed memory leak in the free function
- tweaked docs

Version 3:
- target node is stored now as unsigned and all uses are tweaked
- fixed documentation wording as suggested

Version 2:
- dropped the ACPI prefix
- fixed memory leak in the free function
- tweaked docs

Version 2:
- dropped the ACPI prefix
- fixed memory leak in the free function
- tweaked docs

 docs/formatdomain.html.in  |  92 +-
 docs/schemas/domaincommon.rng  |  50 +++
 src/bhyve/bhyve_domain.c   |   5 +-
 src/conf/domain_conf.c | 336 -
 src/conf/domain_conf.h |  33 ++
 src/libvirt_private.syms   |   2 +
 src/libxl/libxl_domain.c   |   3 +
 src/lxc/lxc_domain.c   |   4 +
 src/openvz/openvz_driver.c |   3 +
 src/qemu/qemu_domain.c |   3 +
 src/qemu/qemu_driver.c |  13 +
 src/qemu/qemu_hotplug.c|   3 +
 src/uml/uml_driver.c   |   3 +
 src/xen/xen_driver.c   |   3 +
 src/xenapi/xenapi_driver.c |   3 +
 .../qemuxml2argv-memory-hotplug-dimm.xml   |  50 +++
 16 files changed, 601 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index c167e1c..e1aa79c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -684,7 +684,9 @@

 dl
   dtcodememory/code/dt
-  ddThe maximum allocation of memory for the guest at boot time.
+  ddThe maximum allocation of memory for the guest at boot time. The
+memory allocation includes possible additional memory devices specified
+at start or hotplugged later.
 The units for this value are determined by the optional
 attribute codeunit/code, which defaults to KiB
 (kibibytes, 2sup10/sup or blocks of 1024 bytes).  Valid
@@ -702,6 +704,9 @@
 supported by the hypervisor.  Some hypervisors also enforce a
 minimum, such as 4000KiB.

+In case a href=#elementsCPUNUMA/a is configured for the guest the
+codememory/code element can be omitted.
+
 In the case of crash, optional attribute codedumpCore/code
 can be used to control whether the guest memory should be
 included in the generated coredump or not (values on, off).
@@ -5909,6 +5914,91 @@ qemu-kvm -net nic,model=? /dev/null
 /dd
   /dl

+h4a name=elementsMemoryMemory devices/a/h4
+
+p
+In addition to the initial memory assigned to the guest, memory devices
+allow additional memory to be assigned to the guest in the form of
+memory modules.
+
+A memory device can be hot-plugged or hot-unplugged depending on the
+guests' memory resource needs.
+
+Some hypervisors may require NUMA configured for the guest.
+  span class=sinceSince 1.2.14/span
+/p
+
+p
+  Example: usage of the memory devices
+/p
+pre
+  ...
+  lt;devicesgt;
+lt;memory model='dimm'gt;
+  lt;targetgt;
+lt;size unit='KiB'gt;524287lt;/sizegt;
+lt;nodegt;0lt;/nodegt;
+  lt;/targetgt;
+lt;/memorygt;
+lt;memory model='dimm'gt;
+  lt;sourcegt;
+lt;pagesize unit='KiB'gt;4096lt;/pagesizegt;
+lt;nodemaskgt;1-3lt;/nodemaskgt;
+  lt;/sourcegt;
+  lt;targetgt;
+lt;size unit='KiB'gt;524287lt;/sizegt;
+lt;nodegt;1lt;/nodegt;
+  lt;/targetgt;
+lt;/memorygt;
+  lt;/devicesgt;
+  ...
+/pre
+dl
+  dtcodemodel/code/dt
+  dd
+p
+   

[libvirt] [PATCHv3 08/12] qemu: migration: Forbid migration with memory modules lacking info

2015-03-17 Thread Peter Krempa
Make sure that libvirt has all vital information needed to reliably
represent configuration of guest's memory devices in case of a
migration.

This patch forbids migration in case the required slot number and module
base address are not present (failed to be loaded from qemu via
monitor).
---

Notes:
Version 2:
- rebased to the drop of ACPI

 src/qemu/qemu_migration.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 83be435..f36a36c 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2016,6 +2016,20 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, 
virDomainObjPtr vm,
 }
 }

+/* Verify that memory device config can be transferred reliably */
+for (i = 0; i  def-nmems; i++) {
+virDomainMemoryDefPtr mem = def-mems[i];
+
+if (mem-model == VIR_DOMAIN_MEMORY_MODEL_DIMM 
+mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(domain's dimm info lacks slot ID 
+ or base address));
+
+return false;
+}
+}
+
 return true;
 }

-- 
2.2.2

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


[libvirt] [PATCHv3 10/12] qemu: conf: Add support for memory device cold(un)plug

2015-03-17 Thread Peter Krempa
Add a few helpers that allow to operate with memory device definitions
on the domain config and use them to implement memory device coldplug in
the qemu driver.
---

Notes:
Version 2:
- no changes

 src/conf/domain_conf.c   | 100 +++
 src/conf/domain_conf.h   |  10 +
 src/libvirt_private.syms |   4 ++
 src/qemu/qemu_driver.c   |  15 ++-
 4 files changed, 127 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 8c2234f..1a02e46 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -12811,6 +12811,106 @@ virDomainRNGRemove(virDomainDefPtr def,
 }


+static int
+virDomainMemoryFindByDefInternal(virDomainDefPtr def,
+ virDomainMemoryDefPtr mem,
+ bool allowAddressFallback)
+{
+size_t i;
+
+for (i = 0; i  def-nmems; i++) {
+virDomainMemoryDefPtr tmp = def-mems[i];
+
+/* address, if present */
+if (allowAddressFallback) {
+if (tmp-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
+continue;
+} else {
+if (mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
+!virDomainDeviceInfoAddressIsEqual(tmp-info, mem-info))
+continue;
+}
+
+/* alias, if present */
+if (mem-info.alias 
+STRNEQ_NULLABLE(tmp-info.alias, mem-info.alias))
+continue;
+
+/* target info - always present */
+if (tmp-model != mem-model ||
+tmp-targetNode != mem-targetNode ||
+tmp-size != mem-size)
+continue;
+
+/* source stuff - match with device */
+if (tmp-pagesize != mem-pagesize)
+continue;
+
+if (!virBitmapEqual(tmp-sourceNodes, mem-sourceNodes))
+continue;
+
+break;
+}
+
+if (i == def-nmems)
+return -1;
+
+return i;
+}
+
+
+int
+virDomainMemoryFindByDef(virDomainDefPtr def,
+ virDomainMemoryDefPtr mem)
+{
+return virDomainMemoryFindByDefInternal(def, mem, false);
+}
+
+
+int
+virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
+ virDomainMemoryDefPtr mem)
+{
+int ret;
+
+if ((ret = virDomainMemoryFindByDefInternal(def, mem, false))  0)
+ret = virDomainMemoryFindByDefInternal(def, mem, true);
+
+return ret;
+}
+
+
+int
+virDomainMemoryInsert(virDomainDefPtr def,
+  virDomainMemoryDefPtr mem)
+{
+int id = def-nmems;
+
+if (mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE 
+virDomainDefHasDeviceAddress(def, mem-info)) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(Domain already contains a device with the same 
+ address));
+return -1;
+}
+
+if (VIR_APPEND_ELEMENT(def-mems, def-nmems, mem)  0)
+return -1;
+
+return id;
+}
+
+
+virDomainMemoryDefPtr
+virDomainMemoryRemove(virDomainDefPtr def,
+  int idx)
+{
+virDomainMemoryDefPtr ret = def-mems[idx];
+VIR_DELETE_ELEMENT(def-mems, idx, def-nmems);
+return ret;
+}
+
+
 char *
 virDomainDefGetDefaultEmulator(virDomainDefPtr def,
virCapsPtr caps)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 475a174..eb61aff 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2860,6 +2860,16 @@ virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr 
def, const char *model);
 typedef const char* (*virEventActionToStringFunc)(int type);
 typedef int (*virEventActionFromStringFunc)(const char *type);

+int virDomainMemoryInsert(virDomainDefPtr def, virDomainMemoryDefPtr mem)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+virDomainMemoryDefPtr virDomainMemoryRemove(virDomainDefPtr def, int idx)
+ATTRIBUTE_NONNULL(1);
+int virDomainMemoryFindByDef(virDomainDefPtr def, virDomainMemoryDefPtr mem)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+int virDomainMemoryFindInactiveByDef(virDomainDefPtr def,
+ virDomainMemoryDefPtr mem)
+ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
+
 VIR_ENUM_DECL(virDomainTaint)
 VIR_ENUM_DECL(virDomainVirt)
 VIR_ENUM_DECL(virDomainBoot)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f24b449..239bef4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -335,6 +335,10 @@ virDomainLockFailureTypeToString;
 virDomainMemballoonModelTypeFromString;
 virDomainMemballoonModelTypeToString;
 virDomainMemoryDefFree;
+virDomainMemoryFindByDef;
+virDomainMemoryFindInactiveByDef;
+virDomainMemoryInsert;
+virDomainMemoryRemove;
 virDomainNetAppendIpAddress;
 virDomainNetDefFormat;
 virDomainNetDefFree;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 300bce4..e948cca 

[libvirt] [PATCHv3 00/12] Add support for memory hotplug

2015-03-17 Thread Peter Krempa
This version includes review feedback changes from John and also fixes the
memory element documentation and code that calculates it to support possible 
non-NUMA configs with memory hotplug if any hypervisor would support that in the
future.

Peter Krempa (12):
  qemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject
  libxl: Refactor logic in domain post parse callback
  conf: Add support for parsing and formatting max memory and slot count
  qemu: Implement setup of memory hotplug parameters
  conf: Add device address type for dimm devices
  conf: Add interface to parse and format memory device information
  qemu: memdev: Add infrastructure to load memory device information
  qemu: migration: Forbid migration with memory modules lacking info
  qemu: add support for memory devices
  qemu: conf: Add support for memory device cold(un)plug
  qemu: Implement memory device hotplug
  qemu: Implement memory device hotunplug

 docs/formatdomain.html.in  | 112 +++-
 docs/schemas/domaincommon.rng  |  76 +++
 src/bhyve/bhyve_domain.c   |   9 +-
 src/conf/domain_conf.c | 576 -
 src/conf/domain_conf.h |  59 +++
 src/libvirt_private.syms   |   7 +
 src/libxl/libxl_domain.c   |  15 +-
 src/lxc/lxc_domain.c   |   8 +
 src/openvz/openvz_driver.c |  14 +-
 src/parallels/parallels_driver.c   |   6 +-
 src/phyp/phyp_driver.c |   6 +-
 src/qemu/qemu_command.c| 166 +-
 src/qemu/qemu_command.h|  15 +
 src/qemu/qemu_domain.c |  80 +++
 src/qemu/qemu_domain.h |   5 +
 src/qemu/qemu_driver.c |  29 ++
 src/qemu/qemu_hotplug.c| 187 +++
 src/qemu/qemu_hotplug.h|   6 +
 src/qemu/qemu_migration.c  |  14 +
 src/qemu/qemu_monitor.c|  48 +-
 src/qemu/qemu_monitor.h|  14 +
 src/qemu/qemu_monitor_json.c   | 122 +
 src/qemu/qemu_monitor_json.h   |   5 +
 src/qemu/qemu_process.c|   4 +
 src/uml/uml_driver.c   |   9 +-
 src/vbox/vbox_common.c |   6 +-
 src/vmware/vmware_driver.c |   6 +-
 src/vmx/vmx.c  |   6 +-
 src/xen/xen_driver.c   |   7 +
 src/xenapi/xenapi_driver.c |   9 +-
 tests/domainschemadata/maxMemory.xml   |  19 +
 .../qemuxml2argv-memory-hotplug-dimm.args  |  11 +
 .../qemuxml2argv-memory-hotplug-dimm.xml   |  50 ++
 .../qemuxml2argv-memory-hotplug-nonuma.xml |  22 +
 .../qemuxml2argv-memory-hotplug.args   |   6 +
 .../qemuxml2argv-memory-hotplug.xml|  34 ++
 tests/qemuxml2argvtest.c   |   6 +
 tests/qemuxml2xmltest.c|   4 +
 38 files changed, 1747 insertions(+), 31 deletions(-)
 create mode 100644 tests/domainschemadata/maxMemory.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.xml
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.xml

-- 
2.2.2

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


Re: [libvirt] [PATCH 4/4] parallels: minor cleanup

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:40, Maxim Nestratov wrote:
 indentation is fixed, unnecessary error message removed,
 unnecessary job freeing removed
 
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |5 +
  1 files changed, 1 insertions(+), 4 deletions(-)
 
 diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
 index 1025da5..f6350df 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -698,7 +698,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, 
 virDomainNetDefPtr net, bool isCt)
  goto cleanup;
  
  pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net-ifname, 
 buflen);
 -prlsdkCheckRetGoto(pret, cleanup);
 +prlsdkCheckRetGoto(pret, cleanup);
  
  pret = PrlVmDev_GetIndex(netAdapter, netAdapterIndex);
  prlsdkCheckRetGoto(pret, cleanup);
 @@ -1360,7 +1360,6 @@ prlsdkLoadDomains(parallelsConnPtr privconn)
  
   error:
  PrlHandle_Free(result);
 -PrlHandle_Free(job);
  return -1;
  }
  
 @@ -1740,8 +1739,6 @@ prlsdkDomainChangeState(virDomainPtr domain,
  
  pdom = dom-privateData;
  pret = chstate(privconn, pdom-sdkdom);
 -virReportError(VIR_ERR_OPERATION_FAILED,
 -   _(Can't change domain state: %d), pret);
  if (PRL_FAILED(pret)) {
  virResetLastError();
  
 

I'm having some difficulties applying this patch. Can you rebase to the
current master and resend? The problem is in the first chunk, I guess.

Michal

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


Re: [libvirt] [PATCH 3/4] parallels: fix home directory for VMs

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:40, Maxim Nestratov wrote:
 Failures of parallelsStorageOpen occured because we incorrectly treated
 path to VM' configuration file as a directory. Now initialization of
 parallels VM domains home directory is fixed.
 
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |8 
  1 files changed, 8 insertions(+), 0 deletions(-)
 
 diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
 index b6026fd..1025da5 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -1255,6 +1255,14 @@ prlsdkLoadDomain(parallelsConnPtr privconn,
  pret = PrlVmCfg_GetHomePath(sdkdom, pdom-home, buflen);
  prlsdkCheckRetGoto(pret, error);
  
 +/* For VMs pdom-home is actually /directory/config.pvs */
 +if (!IS_CT(def)) {
 +/* Get rid of /config.pvs in path string */
 +char *s = strrchr(pdom-home, '/');
 +if (s)
 +*s = '\0';
 +}
 +
  if (olddom) {
  /* assign new virDomainDef without any checks */
  /* we can't use virDomainObjAssignDef, because it checks
 

ACK

Michal

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


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

2015-03-17 Thread Michal Privoznik
On 17.03.2015 15:25, Maxim Nestratov wrote:
 17.03.2015 17:15, Michal Privoznik пишет:
 On 13.03.2015 16:52, Maxim Nestratov wrote:
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
   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;
   
 How about introducing 'int parallelsNetworkTypeFromString(const char *)'
 using our ENUM_DECL and ENUM_IMPL macros? This code could then be turned
 into:

  if ((def-forward.type = parallelNetworkTypeFromString(tmp))  0) {
  parallelsParseError();
  goto cleanup;
  }

  switch((virNetworkForwardType) def-forward.type) {
  case VIR_NETWORK_FORWARD_BRIDGE:
  if (parallelsGetBridgedNetInfo(def, jobj)  0)
  goto cleanup;
  break;
  case VIR_NETWORK_FORWARD_NONE:
  if (parallelsGetHostOnlyNetInfo(def, def-name)  0)
  goto cleanup;
  ...
  }

 I find it more future proof then STREQ() spaghetti.

 Michal
 Ok. Makes sence. I'll do this in the next series version.
 

D'oh. Now that I'm going through the code again, this patch actually
makes sense and my suggestion doesn't. The problem is, initially I
thought that @tmp holds network type in string, while in fact it holds a
network's name. And it doesn't make much sense to create an enum for
that. Although, other patches in the series need some discussion before
I can push them.

Michal

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

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

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:52, 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 mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |   99 +++-
  1 files changed, 86 insertions(+), 13 deletions(-)

ACK

Michal

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


[libvirt] [PATCHv3 11/12] qemu: Implement memory device hotplug

2015-03-17 Thread Peter Krempa
Add code to hot-add memory devices to running qemu instances.
---

Notes:
Version 3:
- added comment to clarify that @mem is always consumed by 
qemuDomainAttachMemory
Version 2:
- no change

Version 2:
- no change

 src/qemu/qemu_command.c |  4 +--
 src/qemu/qemu_command.h | 15 
 src/qemu/qemu_driver.c  |  5 ++-
 src/qemu/qemu_hotplug.c | 95 +
 src/qemu/qemu_hotplug.h |  3 ++
 5 files changed, 119 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2d85567..1f72437 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4599,7 +4599,7 @@ qemuBuildControllerDevStr(virDomainDefPtr domainDef,
  * other configuration was used (to detect legacy configurations). Returns
  * -1 in case of an error.
  */
-static int
+int
 qemuBuildMemoryBackendStr(unsigned long long size,
   unsigned long long pagesize,
   int guestNode,
@@ -4872,7 +4872,7 @@ qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem,
 }


-static char *
+char *
 qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
  virQEMUCapsPtr qemuCaps)
 {
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index ee81f92..a29db41 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -162,6 +162,21 @@ char *qemuBuildSoundDevStr(virDomainDefPtr domainDef,
virDomainSoundDefPtr sound,
virQEMUCapsPtr qemuCaps);

+int qemuBuildMemoryBackendStr(unsigned long long size,
+  unsigned long long pagesize,
+  int guestNode,
+  virBitmapPtr userNodeset,
+  virBitmapPtr autoNodeset,
+  virDomainDefPtr def,
+  virQEMUCapsPtr qemuCaps,
+  virQEMUDriverConfigPtr cfg,
+  const char **backendType,
+  virJSONValuePtr *backendProps,
+  bool force);
+
+char *qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
+   virQEMUCapsPtr qemuCaps);
+
 /* Legacy, pre device support */
 char *qemuBuildPCIHostdevPCIDevStr(virDomainHostdevDefPtr dev,
virQEMUCapsPtr qemuCaps);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e948cca..cbdf279 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7649,8 +7649,11 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
 dev-data.rng = NULL;
 break;

-/*TODO: implement later */
 case VIR_DOMAIN_DEVICE_MEMORY:
+ret = qemuDomainAttachMemory(driver, vm,
+ dev-data.memory);
+dev-data.memory = NULL;
+break;

 case VIR_DOMAIN_DEVICE_NONE:
 case VIR_DOMAIN_DEVICE_FS:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 5c5ad0e..88c5e3c 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -1672,6 +1672,101 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
 }


+/**
+ * qemuDomainAttachMemory:
+ * @driver: qemu driver data
+ * @vm: VM object
+ * @mem: Definition of the memory device to be attached. @mem is always 
consumed
+ *
+ * Attaches memory device described by @mem to domain @vm.
+ *
+ * Returns 0 on success -1 on error.
+ */
+int
+qemuDomainAttachMemory(virQEMUDriverPtr driver,
+   virDomainObjPtr vm,
+   virDomainMemoryDefPtr mem)
+{
+qemuDomainObjPrivatePtr priv = vm-privateData;
+virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+char *devstr = NULL;
+char *objalias = NULL;
+const char *backendType;
+virJSONValuePtr props = NULL;
+int id;
+int ret = -1;
+
+if (virAsprintf(mem-info.alias, dimm%zu, vm-def-nmems)  0)
+goto cleanup;
+
+if (virAsprintf(objalias, mem%s, mem-info.alias)  0)
+goto cleanup;
+
+if (!(devstr = qemuBuildMemoryDeviceStr(mem, priv-qemuCaps)))
+goto cleanup;
+
+qemuDomainMemoryDeviceAlignSize(mem);
+
+if (qemuBuildMemoryBackendStr(mem-size, mem-pagesize,
+  mem-targetNode, mem-sourceNodes, NULL,
+  vm-def, priv-qemuCaps, cfg,
+  backendType, props, true)  0)
+goto cleanup;
+
+if (virDomainMemoryInsert(vm-def, mem)  0) {
+virJSONValueFree(props);
+goto cleanup;
+}
+
+qemuDomainObjEnterMonitor(driver, vm);
+if (qemuMonitorAddObject(priv-mon, backendType, objalias, props)  0)
+goto removedef;
+
+if (qemuMonitorAddDevice(priv-mon, devstr)  0) {
+virErrorPtr err = virSaveLastError();
+ignore_value(qemuMonitorDelObject(priv-mon, objalias));
+

[libvirt] [PATCHv3 05/12] conf: Add device address type for dimm devices

2015-03-17 Thread Peter Krempa
Dimm devices are described by the slot and base address. Add a new
address type to be able to describe such address.
---

Notes:
Version 2:
- drop 'ACPI' from everything

 docs/schemas/domaincommon.rng | 18 +++
 src/conf/domain_conf.c| 74 ++-
 src/conf/domain_conf.h|  9 ++
 3 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index a0dee17..1f4df8e 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4030,6 +4030,18 @@
   /attribute
 /optional
   /define
+  define name=dimmaddress
+optional
+  attribute name=slot
+ref name=unsignedInt/
+  /attribute
+/optional
+optional
+  attribute name=base
+ref name=hexuint/
+  /attribute
+/optional
+  /define
   define name=devices
 element name=devices
   interleave
@@ -4449,6 +4461,12 @@
 valuevirtio-mmio/value
   /attribute
 /group
+group
+  attribute name=type
+valuedimm/value
+  /attribute
+  ref name=dimmaddress/
+/group
   /choice
 /element
   /define
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index dc15d95..2d765ba 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -249,7 +249,8 @@ VIR_ENUM_IMPL(virDomainDeviceAddress, 
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
   virtio-s390,
   ccw,
   virtio-mmio,
-  isa)
+  isa,
+  dimm)

 VIR_ENUM_IMPL(virDomainDiskDevice, VIR_DOMAIN_DISK_DEVICE_LAST,
   disk,
@@ -2832,6 +2833,11 @@ virDomainDeviceInfoAddressIsEqual(const 
virDomainDeviceInfo *a,
 if (memcmp(a-addr.isa, b-addr.isa, sizeof(a-addr.isa)))
 return false;
 break;
+
+case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
+if (memcmp(a-addr.dimm, b-addr.dimm, sizeof(a-addr.dimm)))
+return false;
+break;
 }

 return true;
@@ -3701,6 +3707,12 @@ virDomainDeviceInfoFormat(virBufferPtr buf,
 virBufferAsprintf(buf,  irq='0x%x', info-addr.isa.irq);
 break;

+case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
+virBufferAsprintf(buf,  slot='%u', info-addr.dimm.slot);
+virBufferAsprintf(buf,  base='0x%llx', info-addr.dimm.base);
+
+break;
+
 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390:
 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST:
@@ -4070,6 +4082,41 @@ virDomainDeviceISAAddressParseXML(xmlNodePtr node,
 return ret;
 }

+
+static int
+virDomainDeviceDimmAddressParseXML(xmlNodePtr node,
+   virDomainDeviceDimmAddressPtr addr)
+{
+int ret = -1;
+char *tmp = NULL;
+
+if (!(tmp = virXMLPropString(node, slot)) ||
+virStrToLong_uip(tmp, NULL, 10, addr-slot)  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(invalid or missing dimm slot id '%s'),
+   NULLSTR(tmp));
+goto cleanup;
+}
+VIR_FREE(tmp);
+
+if (!(tmp = virXMLPropString(node, base)) ||
+virStrToLong_ullp(tmp, NULL, 16, addr-base)  0) {
+virReportError(VIR_ERR_XML_ERROR,
+   _(invalid or missing dimm base address '%s'),
+   NULLSTR(tmp));
+goto cleanup;
+}
+VIR_FREE(tmp);
+
+ret = 0;
+
+ cleanup:
+VIR_FREE(tmp);
+
+return ret;
+}
+
+
 /* Parse the XML definition for a device address
  * @param node XML nodeset to parse for device address definition
  */
@@ -4211,6 +4258,11 @@ virDomainDeviceInfoParseXML(xmlNodePtr node,
_(virtio-s390 bus doesn't have an address));
 goto cleanup;

+case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
+if (virDomainDeviceDimmAddressParseXML(address, info-addr.dimm)  0)
+goto cleanup;
+break;
+
 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE:
 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST:
 break;
@@ -15408,6 +15460,26 @@ 
virDomainDeviceInfoCheckABIStability(virDomainDeviceInfoPtr src,
 }
 break;

+case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM:
+if (src-addr.dimm.slot != dst-addr.dimm.slot) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(Target device dimm slot %u does not match 
+ source %u),
+   dst-addr.dimm.slot,
+   src-addr.dimm.slot);
+return false;
+}
+
+if (src-addr.dimm.base != dst-addr.dimm.base) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(Target device dimm base addres '%llx' does 
+ not match source '%llx'),
+   dst-addr.dimm.base,
+   

Re: [libvirt] [PATCH 0/7] Fix ejecting of network backed cdroms via virsh

2015-03-17 Thread Peter Krempa
On Thu, Mar 12, 2015 at 18:09:52 +0100, Peter Krempa wrote:
 It turned out that not only virsh was broken ...
 
 Peter Krempa (7):
   virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach
 disk
   virsh: domain: Add --print-xml flag for command change-media
   virsh: domain: Fix the change-media command
   qemu: hotplug: Use checker function to check if disk is empty
   qemu: driver: Fix cold-update of removable storage devices
   util: storage: Fix check for empty storage device
   conf: disk: Simplify checking if source definition was parsed

Ping? anyone willing to review?

Peter


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

[libvirt] [PATCHv3 01/12] qemu: monitor: Don't leak @props with non-JSON in qemuMonitorAddObject

2015-03-17 Thread Peter Krempa
The function comment states that @props is always consumed, even on
failure. This was not true with the failure if the monitor is not using
QMP.
---

This patch is new in the series.

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

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 18f866f..9b86695 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3245,11 +3245,13 @@ qemuMonitorAddObject(qemuMonitorPtr mon,
   mon, type, objalias, props);
 int ret = -1;

-if (mon-json)
+if (mon-json) {
 ret = qemuMonitorJSONAddObject(mon, type, objalias, props);
-else
+} else {
+virJSONValueFree(props);
 virReportError(VIR_ERR_OPERATION_UNSUPPORTED, %s,
_(object adding requires JSON monitor));
+}

 return ret;
 }
-- 
2.2.2

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


[libvirt] [PATCHv3 07/12] qemu: memdev: Add infrastructure to load memory device information

2015-03-17 Thread Peter Krempa
When using 'dimm' memory devices with qemu, some of the information
like the slot number and base address need to be reloaded from qemu
after process start so that it reflects the actual state. The state then
allows to use memory devices across migrations.
---

Notes:
Version 3:
- Don't try to extract data if the qemu command was not successful

Version 2:
- rebase to the drop of ACPI prefix

Version 2:
- rebase to the drop of ACPI prefix

 src/qemu/qemu_domain.c   |  49 +
 src/qemu/qemu_domain.h   |   4 ++
 src/qemu/qemu_monitor.c  |  42 +++
 src/qemu/qemu_monitor.h  |  14 +
 src/qemu/qemu_monitor_json.c | 122 +++
 src/qemu/qemu_monitor_json.h |   5 ++
 src/qemu/qemu_process.c  |   4 ++
 7 files changed, 240 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6f328e4..825c02e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -2807,6 +2807,55 @@ qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
 return 0;
 }

+
+int
+qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ int asyncJob)
+{
+qemuDomainObjPrivatePtr priv = vm-privateData;
+virHashTablePtr meminfo = NULL;
+int rc;
+size_t i;
+
+if (vm-def-nmems == 0)
+return 0;
+
+if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob)  0)
+return -1;
+
+rc = qemuMonitorGetMemoryDeviceInfo(priv-mon, meminfo);
+
+if (qemuDomainObjExitMonitor(driver, vm)  0)
+return -1;
+
+/* if qemu doesn't support the info request, just carry on */
+if (rc == -2)
+return 0;
+
+if (rc  0)
+return -1;
+
+for (i = 0; i  vm-def-nmems; i++) {
+virDomainMemoryDefPtr mem = vm-def-mems[i];
+qemuMonitorMemoryDeviceInfoPtr dimm;
+
+if (!mem-info.alias)
+continue;
+
+if (!(dimm = virHashLookup(meminfo, mem-info.alias)))
+continue;
+
+mem-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM;
+mem-info.addr.dimm.slot = dimm-slot;
+mem-info.addr.dimm.base = dimm-address;
+}
+
+virHashFree(meminfo);
+return 0;
+}
+
+
 bool
 qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
virDomainDefPtr src,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index ba8d398..75e82f3 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -393,6 +393,10 @@ extern virDomainDefParserConfig 
virQEMUDriverDomainDefParserConfig;
 int qemuDomainUpdateDeviceList(virQEMUDriverPtr driver,
virDomainObjPtr vm, int asyncJob);

+int qemuDomainUpdateMemoryDeviceInfo(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ int asyncJob);
+
 bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver,
 virDomainDefPtr src,
 virDomainDefPtr dst);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 9b86695..bd4d137 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4344,3 +4344,45 @@ void 
qemuMonitorIOThreadsInfoFree(qemuMonitorIOThreadsInfoPtr iothread)
 VIR_FREE(iothread-name);
 VIR_FREE(iothread);
 }
+
+
+/**
+ * qemuMonitorGetMemoryDeviceInfo:
+ * @mon: pointer to the monitor
+ * @info: Location to return the hash of qemuMonitorMemoryDeviceInfo
+ *
+ * Retrieve state and addresses of frontend memory devices present in
+ * the guest.
+ *
+ * Returns 0 on success and fills @info with a newly allocated struct; if the
+ * data can't be retrieved due to lack of support in qemu, returns -2. On
+ * other errors returns -1.
+ */
+int
+qemuMonitorGetMemoryDeviceInfo(qemuMonitorPtr mon,
+   virHashTablePtr *info)
+{
+VIR_DEBUG(mon=%p info=%p, mon, info);
+int ret;
+
+*info = NULL;
+
+if (!mon) {
+virReportError(VIR_ERR_INVALID_ARG, %s,
+   _(monitor must not be NULL));
+return -1;
+}
+
+if (!mon-json)
+return -2;
+
+if (!(*info = virHashCreate(10, virHashValueFree)))
+return -1;
+
+if ((ret = qemuMonitorJSONGetMemoryDeviceInfo(mon, *info))  0) {
+virHashFree(*info);
+*info = NULL;
+}
+
+return ret;
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b30da34..8dc4a1c 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -877,6 +877,20 @@ int qemuMonitorGetIOThreads(qemuMonitorPtr mon,

 void qemuMonitorIOThreadsInfoFree(qemuMonitorIOThreadsInfoPtr iothread);

+typedef struct _qemuMonitorMemoryDeviceInfo qemuMonitorMemoryDeviceInfo;
+typedef qemuMonitorMemoryDeviceInfo *qemuMonitorMemoryDeviceInfoPtr;
+
+struct _qemuMonitorMemoryDeviceInfo {
+unsigned long 

[libvirt] [PATCHv3 09/12] qemu: add support for memory devices

2015-03-17 Thread Peter Krempa
Add support to start qemu instance with 'pc-dimm' device. Thanks to the
refactors we are able to reuse the existing function to determine the
parameters.
---

Notes:
Version 2:
- dropped the ACPI naming

 src/qemu/qemu_command.c| 130 -
 src/qemu/qemu_domain.c |  26 -
 src/qemu/qemu_domain.h |   1 +
 .../qemuxml2argv-memory-hotplug-dimm.args  |  11 ++
 tests/qemuxml2argvtest.c   |   2 +
 tests/qemuxml2xmltest.c|   1 +
 6 files changed, 167 insertions(+), 4 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-dimm.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ef8feeb..2d85567 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1222,6 +1222,10 @@ qemuAssignDeviceAliases(virDomainDefPtr def, 
virQEMUCapsPtr qemuCaps)
 if (virAsprintf(def-tpm-info.alias, tpm%d, 0)  0)
 return -1;
 }
+for (i = 0; i  def-nmems; i++) {
+if (virAsprintf(def-mems[i]-info.alias, dimm%zu, i)  0)
+return -1;
+}

 return 0;
 }
@@ -4612,8 +4616,7 @@ qemuBuildMemoryBackendStr(unsigned long long size,
 virDomainHugePagePtr hugepage = NULL;
 virDomainNumatuneMemMode mode;
 const long system_page_size = virGetSystemPageSizeKB();
-virNumaMemAccess memAccess = 
virDomainNumaGetNodeMemoryAccessMode(def-numa, guestNode);
-
+virNumaMemAccess memAccess = VIR_NUMA_MEM_ACCESS_DEFAULT;
 size_t i;
 char *mem_path = NULL;
 virBitmapPtr nodemask = NULL;
@@ -4626,6 +4629,16 @@ qemuBuildMemoryBackendStr(unsigned long long size,
 if (!(props = virJSONValueNewObject()))
 return -1;

+/* memory devices could provide a invalid guest node */
+if (guestNode = virDomainNumaGetNodeCount(def-numa)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+   _(can't add memory backend for guest node '%d' as 
+ the guest has only '%zu' NUMA nodes configured),
+   guestNode, virDomainNumaGetNodeCount(def-numa));
+return -1;
+}
+
+memAccess = virDomainNumaGetNodeMemoryAccessMode(def-numa, guestNode);
 mode = virDomainNumatuneGetMode(def-numa, guestNode);

 if (pagesize == 0 || pagesize != system_page_size) {
@@ -4823,6 +4836,95 @@ qemuBuildMemoryCellBackendStr(virDomainDefPtr def,
 }


+static char *
+qemuBuildMemoryDimmBackendStr(virDomainMemoryDefPtr mem,
+  virDomainDefPtr def,
+  virQEMUCapsPtr qemuCaps,
+  virQEMUDriverConfigPtr cfg)
+{
+virJSONValuePtr props = NULL;
+char *alias = NULL;
+const char *backendType;
+char *ret = NULL;
+
+if (!mem-info.alias) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(memory device alias is not assigned));
+return NULL;
+}
+
+if (virAsprintf(alias, mem%s, mem-info.alias)  0)
+goto cleanup;
+
+if (qemuBuildMemoryBackendStr(mem-size, mem-pagesize,
+  mem-targetNode, mem-sourceNodes, NULL,
+  def, qemuCaps, cfg,
+  backendType, props, true)  0)
+goto cleanup;
+
+ret = qemuBuildObjectCommandlineFromJSON(backendType, alias, props);
+
+ cleanup:
+VIR_FREE(alias);
+virJSONValueFree(props);
+
+return ret;
+}
+
+
+static char *
+qemuBuildMemoryDeviceStr(virDomainMemoryDefPtr mem,
+ virQEMUCapsPtr qemuCaps)
+{
+virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+if (!mem-info.alias) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(missing alias for memory device));
+return NULL;
+}
+
+switch ((virDomainMemoryModel) mem-model) {
+case VIR_DOMAIN_MEMORY_MODEL_DIMM:
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(this qemu doesn't support the pc-dimm device));
+return NULL;
+}
+
+if (mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM 
+mem-info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(only 'dimm' addresses are supported for the 
+ pc-dimm device));
+return NULL;
+}
+
+virBufferAsprintf(buf, pc-dimm,node=%d,memdev=mem%s,id=%s,
+  mem-targetNode, mem-info.alias, mem-info.alias);
+
+if (mem-info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM) {
+virBufferAsprintf(buf, ,slot=%d, mem-info.addr.dimm.slot);
+virBufferAsprintf(buf, ,base=%llu, mem-info.addr.dimm.base);
+}
+
+break;
+
+

[libvirt] [PATCHv3 02/12] libxl: Refactor logic in domain post parse callback

2015-03-17 Thread Peter Krempa
With the current control flow the post parse callback returned success
right away for fully virtualized VMs. To allow adding additional checks
into the post parse callback tweak the conditions so that the function
doesn't return early except for error cases.

To clarify the original piece of code borrow the wording from the commit
message for the patch that introduced the code.
---

This patch is new in the series.

 src/libxl/libxl_domain.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 407a9bd..611ccf4 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -546,10 +546,9 @@ libxlDomainDefPostParse(virDomainDefPtr def,
 virCapsPtr caps ATTRIBUTE_UNUSED,
 void *opaque ATTRIBUTE_UNUSED)
 {
-if (STREQ(def-os.type, hvm))
-return 0;
-
-if (def-nconsoles == 0) {
+/* Xen PV domains always have a PV console, so add one to the domain config
+ * via post-parse callback if not explicitly specified in the XML. */
+if (STRNEQ(def-os.type, hvm)  def-nconsoles == 0) {
 virDomainChrDefPtr chrdef;

 if (!(chrdef = virDomainChrDefNew()))
-- 
2.2.2

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


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

2015-03-17 Thread Maxim Nestratov

17.03.2015 17:15, Michal Privoznik пишет:

On 13.03.2015 16:52, Maxim Nestratov wrote:

Signed-off-by: Maxim Nestratov mnestra...@parallels.com
---
  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;
  

How about introducing 'int parallelsNetworkTypeFromString(const char *)'
using our ENUM_DECL and ENUM_IMPL macros? This code could then be turned
into:

 if ((def-forward.type = parallelNetworkTypeFromString(tmp))  0) {
 parallelsParseError();
 goto cleanup;
 }

 switch((virNetworkForwardType) def-forward.type) {
 case VIR_NETWORK_FORWARD_BRIDGE:
 if (parallelsGetBridgedNetInfo(def, jobj)  0)
 goto cleanup;
 break;
 case VIR_NETWORK_FORWARD_NONE:
 if (parallelsGetHostOnlyNetInfo(def, def-name)  0)
 goto cleanup;
 ...
 }

I find it more future proof then STREQ() spaghetti.

Michal

Ok. Makes sence. I'll do this in the next series version.

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

Re: [libvirt] [PATCH v2 0/4] parallels: fixes and cleanups

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:40, Maxim Nestratov wrote:
 From: Maxim Nestratov mnestra...@parallels.com
 
 v2 change:
  - rebased
 
 Maxim Nestratov (3):
   parallels: don't forget to unlock domain if unregister fails
   parallels: fix home directory for VMs
   parallels: minor cleanup
 
 Mikhail Feoktistov (1):
   parallels: set cpu mode when applying xml configuration
 
 --
 libvir-list mailing list
 libvir-list@redhat.com
 https://www.redhat.com/mailman/listinfo/libvir-list
 

I've ACKed and pushed the first three patches.

Michal

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


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

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:52, Maxim Nestratov wrote:
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  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;
  

How about introducing 'int parallelsNetworkTypeFromString(const char *)'
using our ENUM_DECL and ENUM_IMPL macros? This code could then be turned
into:

if ((def-forward.type = parallelNetworkTypeFromString(tmp))  0) {
parallelsParseError();
goto cleanup;
}

switch((virNetworkForwardType) def-forward.type) {
case VIR_NETWORK_FORWARD_BRIDGE:
if (parallelsGetBridgedNetInfo(def, jobj)  0)
goto cleanup;
break;
case VIR_NETWORK_FORWARD_NONE:
if (parallelsGetHostOnlyNetInfo(def, def-name)  0)
goto cleanup;
...
}

I find it more future proof then STREQ() spaghetti.

Michal

--
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-17 Thread Michal Privoznik
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).

ACK though.

Michal

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


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

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:52, 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.
 
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  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..4dc7115 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 required to be configured completely 
 */

s/networks required/networks are required/

 +if (!STREQ(def-name, PARALLELS_REQUIRED_BRIDGED_NETWORK))

s/!STREQ/STRNEQ/

 +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 required to be configured completely 
 */
 +if (!STREQ(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;
 +return ret;

This doesn't make much sense. drop return, let it fall through cleanup,
and move virNetworkObjEndAPI() under the label. Of course, @def should
be set to NULL as soon as virNetworkAssignDef() succeeds.

  
   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;
  }
  
 

ACK with nits fixed.

Michal

--
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 type default

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:52, Maxim Nestratov wrote:
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
 index 9588163..748a308 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -2665,6 +2665,10 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom, 
 parallelsConnPtr privconn, virDomainN
  pret = PrlVmDevNet_SetMacAddress(sdknet, macstr);
  prlsdkCheckRetGoto(pret, cleanup);
  
 +/* Other alternatives: PNT_VIRTIO, PNT_RTL */
 +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);
 

I'd appreciate if this would go through XML. There's option for
hypervisor drivers to register a callback to fill in defaults after XML
is parsed. That's perfect place to set e1000 as default vNIC model (if
not already provided by user in XML). And here just set model requested
in XML (or throw an error if unsupported).

Michal

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


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

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:52, Maxim Nestratov wrote:
 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 mnestra...@parallels.com
 ---
  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 748a308..a0a2ba0 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -3062,6 +3062,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;
 

ACK, libvirt has it's own subsystem for managing firewall.

Michal

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


[libvirt] [PATCHv3 03/12] conf: Add support for parsing and formatting max memory and slot count

2015-03-17 Thread Peter Krempa
Add a XML element that will allow to specify maximum supportable memory
and the count of memory slots to use with memory hotplug.

To avoid possible confusion and misuse of the new element this patch
also explicitly forbids the use of the maxMemory setting in individual
drivers's post parse callbacks. This limitation will be lifted when the
support is implemented.
---

Notes:
Version 3:
- tweaked docs according to suggestions

Version 2:
- changed version in docs to 1.2.14
- fixed typo in code and in commit message
- simplified condition when formatting the maxMemory element
- rebased on top of the changes to the refactor series

Version 2:
- changed version in docs to 1.2.14
- fixed typo in code and in commit message
- simplified condition when formatting the maxMemory element
- rebased on top of the changes to the refactor series

 docs/formatdomain.html.in| 20 +++
 docs/schemas/domaincommon.rng|  8 +
 src/bhyve/bhyve_domain.c |  4 +++
 src/conf/domain_conf.c   | 66 
 src/conf/domain_conf.h   |  7 
 src/libvirt_private.syms |  1 +
 src/libxl/libxl_domain.c |  5 +++
 src/lxc/lxc_domain.c |  4 +++
 src/openvz/openvz_driver.c   | 11 --
 src/parallels/parallels_driver.c |  6 +++-
 src/phyp/phyp_driver.c   |  6 +++-
 src/qemu/qemu_domain.c   |  4 +++
 src/uml/uml_driver.c |  6 +++-
 src/vbox/vbox_common.c   |  6 +++-
 src/vmware/vmware_driver.c   |  6 +++-
 src/vmx/vmx.c|  6 +++-
 src/xen/xen_driver.c |  4 +++
 src/xenapi/xenapi_driver.c   |  6 +++-
 tests/domainschemadata/maxMemory.xml | 19 +++
 19 files changed, 186 insertions(+), 9 deletions(-)
 create mode 100644 tests/domainschemadata/maxMemory.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8d98915..57caef0 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -675,6 +675,7 @@
 pre
 lt;domaingt;
   ...
+  lt;maxMemory slots='16' unit='KiB'gt;1524288lt;/maxMemorygt;
   lt;memory unit='KiB'gt;524288lt;/memorygt;
   lt;currentMemory unit='KiB'gt;524288lt;/currentMemorygt;
   ...
@@ -708,6 +709,25 @@
 span class='since'codeunit/code since 0.9.11/span,
 span class='since'codedumpCore/code since 0.10.2
 (QEMU only)/span/dd
+  dtcodemaxMemory/code/dt
+  ddThe run time maximum memory allocation of the guest. The initial
+memory specified by either the codelt;memorygt;/code element or
+the NUMA cell size configuration can be increased by hot-plugging of
+memory to the limit specified by this element.
+
+The codeunit/code attribute behaves the same as for
+codelt;memorygt;/code.
+
+The codeslots/code attribute specifies the number of slots
+available for adding memory to the guest. The bounds are hypervisor
+specific.
+
+Note that due to alignment of the memory chunks added via memory
+hotplug the full size allocation specified by this element may be
+impossible to achieve.
+span class='since'Since 1.2.14/span
+  /dd
+
   dtcodecurrentMemory/code/dt
   ddThe actual allocation of memory for the guest. This value can
 be less than the maximum allocation, to allow for ballooning
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index ebd9299..a0dee17 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -593,6 +593,14 @@
 /element
   /optional
   optional
+element name=maxMemory
+  ref name=scaledInteger/
+  attribute name=slots
+ref name=unsignedInt/
+  /attribute
+/element
+  /optional
+  optional
 element name=currentMemory
   ref name='scaledInteger'/
 /element
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index ecb1758..25ef852 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -67,6 +67,10 @@ bhyveDomainDefPostParse(virDomainDefPtr def,
VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)  
0)
 return -1;

+/* memory hotplug tunables are not supported by this driver */
+if (virDomainDefCheckUnsupportedMemoryHotplug(def)  0)
+return -1;
+
 return 0;
 }

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c75b543..dc15d95 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -980,6 +980,27 @@ virDomainBlkioDeviceParseXML(xmlNodePtr root,
 }


+/**
+ * virDomainDefCheckUnsupportedMemoryHotplug:
+ * @def: domain definition
+ *
+ * Returns -1 if the domain definition would enable memory hotplug via the
+ * maxMemory tunable and reports an error. Otherwise returns 0.
+ */

[libvirt] [PATCHv3 12/12] qemu: Implement memory device hotunplug

2015-03-17 Thread Peter Krempa
Add code to hot-remove memory devices from qemu. Unfortunately QEMU
doesn't support this right now, so this is just for completenes.
---

Notes:
Version 3:
- moved check for the -device capability before any other code
Version 2:
- no change

 src/qemu/qemu_driver.c  |  4 ++-
 src/qemu/qemu_hotplug.c | 91 -
 src/qemu/qemu_hotplug.h |  3 ++
 3 files changed, 96 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cbdf279..9731b5f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7733,7 +7733,9 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
 ret = qemuDomainDetachRNGDevice(driver, vm, dev-data.rng);
 break;
 case VIR_DOMAIN_DEVICE_MEMORY:
-/* TODO: Implement later */
+ret = qemuDomainDetachMemoryDevice(driver, vm, dev-data.memory);
+break;
+
 case VIR_DOMAIN_DEVICE_FS:
 case VIR_DOMAIN_DEVICE_INPUT:
 case VIR_DOMAIN_DEVICE_SOUND:
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 88c5e3c..3365982 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2828,6 +2828,44 @@ qemuDomainRemoveControllerDevice(virQEMUDriverPtr driver,
 }


+static int
+qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainMemoryDefPtr mem)
+{
+qemuDomainObjPrivatePtr priv = vm-privateData;
+virObjectEventPtr event;
+char *backendAlias = NULL;
+int rc;
+int idx;
+
+VIR_DEBUG(Removing memory device %s from domain %p %s,
+  mem-info.alias, vm, vm-def-name);
+
+if ((event = virDomainEventDeviceRemovedNewFromObj(vm, mem-info.alias)))
+qemuDomainEventQueue(driver, event);
+
+if (virAsprintf(backendAlias, mem%s, mem-info.alias)  0)
+goto error;
+
+qemuDomainObjEnterMonitor(driver, vm);
+rc = qemuMonitorDelObject(priv-mon, backendAlias);
+if (qemuDomainObjExitMonitor(driver, vm)  0 || rc  0)
+goto error;
+
+if ((idx = virDomainMemoryFindByDef(vm-def, mem)) = 0)
+virDomainMemoryRemove(vm-def, idx);
+
+virDomainMemoryDefFree(mem);
+VIR_FREE(backendAlias);
+return 0;
+
+ error:
+VIR_FREE(backendAlias);
+return -1;
+}
+
+
 static void
 qemuDomainRemovePCIHostDevice(virQEMUDriverPtr driver,
   virDomainObjPtr vm,
@@ -3165,8 +3203,9 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
 qemuDomainRemoveRNGDevice(driver, vm, dev-data.rng);
 break;

-/* TODO: implement later */
 case VIR_DOMAIN_DEVICE_MEMORY:
+ret = qemuDomainRemoveMemoryDevice(driver, vm, dev-data.memory);
+break;

 case VIR_DOMAIN_DEVICE_NONE:
 case VIR_DOMAIN_DEVICE_LEASE:
@@ -4118,3 +4157,53 @@ qemuDomainDetachRNGDevice(virQEMUDriverPtr driver,
 qemuDomainResetDeviceRemoval(vm);
 return ret;
 }
+
+
+int
+qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainMemoryDefPtr memdef)
+{
+qemuDomainObjPrivatePtr priv = vm-privateData;
+virDomainMemoryDefPtr mem;
+int idx;
+int rc;
+int ret = -1;
+
+if (!virQEMUCapsGet(priv-qemuCaps, QEMU_CAPS_DEVICE)) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(qemu does not support -device));
+return -1;
+}
+
+if ((idx = virDomainMemoryFindByDef(vm-def, memdef))  0) {
+virReportError(VIR_ERR_OPERATION_INVALID, %s,
+   _(device not present in domain configuration));
+return -1;
+}
+
+mem = vm-def-mems[idx];
+
+if (!mem-info.alias) {
+virReportError(VIR_ERR_INTERNAL_ERROR, %s,
+   _(alias for the memory device was not found));
+return -1;
+}
+
+qemuDomainMarkDeviceForRemoval(vm, mem-info);
+
+qemuDomainObjEnterMonitor(driver, vm);
+rc = qemuMonitorDelDevice(priv-mon, mem-info.alias);
+if (qemuDomainObjExitMonitor(driver, vm)  0 || rc  0)
+goto cleanup;
+
+rc = qemuDomainWaitForDeviceRemoval(vm);
+if (rc == 0 || rc == 1)
+ret = qemuDomainRemoveMemoryDevice(driver, vm, mem);
+else
+ret = 0;
+
+ cleanup:
+qemuDomainResetDeviceRemoval(vm);
+return ret;
+}
diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h
index ad4ff38..4140da3 100644
--- a/src/qemu/qemu_hotplug.h
+++ b/src/qemu/qemu_hotplug.h
@@ -60,6 +60,9 @@ int qemuDomainFindGraphicsIndex(virDomainDefPtr def,
 int qemuDomainAttachMemory(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainMemoryDefPtr mem);
+int qemuDomainDetachMemoryDevice(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainMemoryDefPtr memdef);
 int qemuDomainChangeGraphics(virQEMUDriverPtr 

[libvirt] [PATCHv3 04/12] qemu: Implement setup of memory hotplug parameters

2015-03-17 Thread Peter Krempa
To enable memory hotplug the maximum memory size and slot count need to
be specified. As qemu supports now other units than mebibytes when
specifying memory, use the new interface in this case.
---

Notes:
Version 2:
- simplified condition for enabling the max_memory formatting
- tweaked test code to use the NONE macro instead of 0

 docs/formatdomain.html.in  |  2 +-
 src/qemu/qemu_command.c| 34 ++
 src/qemu/qemu_domain.c |  8 ++---
 .../qemuxml2argv-memory-hotplug-nonuma.xml | 22 ++
 .../qemuxml2argv-memory-hotplug.args   |  6 
 .../qemuxml2argv-memory-hotplug.xml| 34 ++
 tests/qemuxml2argvtest.c   |  4 +++
 tests/qemuxml2xmltest.c|  3 ++
 8 files changed, 102 insertions(+), 11 deletions(-)
 create mode 100644 
tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug.xml

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 57caef0..c167e1c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -725,7 +725,7 @@
 Note that due to alignment of the memory chunks added via memory
 hotplug the full size allocation specified by this element may be
 impossible to achieve.
-span class='since'Since 1.2.14/span
+span class='since'Since 1.2.14 supported by the QEMU driver./span
   /dd

   dtcodecurrentMemory/code/dt
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 02105c3..ef8feeb 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8489,13 +8489,35 @@ qemuBuildCommandLine(virConnectPtr conn,
 if (qemuDomainAlignMemorySizes(def)  0)
 goto error;

-/* Set '-m MB' based on maxmem, because the lower 'memory' limit
- * is set post-startup using the balloon driver. If balloon driver
- * is not supported, then they're out of luck anyway.  Update the
- * XML to reflect our rounding.
- */
 virCommandAddArg(cmd, -m);
-virCommandAddArgFormat(cmd, %llu, virDomainDefGetMemoryInitial(def)  / 
1024);
+
+if (def-mem.max_memory) {
+if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PC_DIMM)) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(memory hotplug isn't supported by this QEMU 
binary));
+goto error;
+}
+
+/* due to guest support, qemu would silently enable NUMA with one node
+ * once the memory hotplug backend is enabled. To avoid possible
+ * confusion we will enforce user originated numa configuration along
+ * with memory hotplug. */
+if (virDomainNumaGetNodeCount(def-numa) == 0) {
+virReportError(VIR_ERR_CONFIG_UNSUPPORTED, %s,
+   _(At least one numa node has to be configured when 

+ enabling memory hotplug));
+goto error;
+}
+
+/* Use the 'k' suffix to let qemu handle the units */
+virCommandAddArgFormat(cmd, size=%lluk,slots=%u,maxmem=%lluk,
+   virDomainDefGetMemoryInitial(def),
+   def-mem.memory_slots,
+   def-mem.max_memory);
+
+} else {
+   virCommandAddArgFormat(cmd, %llu, virDomainDefGetMemoryInitial(def) / 
1024);
+}

 if (def-mem.nhugepages  !virDomainNumaGetNodeCount(def-numa)) {
 const long system_page_size = virGetSystemPageSizeKB();
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 6484bb5..3223752 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1052,10 +1052,6 @@ qemuDomainDefPostParse(virDomainDefPtr def,
   VIR_DOMAIN_INPUT_BUS_USB)  0)
 return -1;

-/* memory hotplug tunables are not supported by this driver */
-if (virDomainDefCheckUnsupportedMemoryHotplug(def)  0)
-return -1;
-
 return 0;
 }

@@ -2898,5 +2894,9 @@ qemuDomainAlignMemorySizes(virDomainDefPtr def)
 mem = virDomainDefGetMemoryInitial(def);
 virDomainDefSetMemoryInitial(def, VIR_ROUND_UP(mem, 1024));

+/* Align maximum memory size. QEMU requires rounding to next 4KiB block.
+ * We'll take the traditional path and round it to 1MiB*/
+def-mem.max_memory = VIR_ROUND_UP(def-mem.max_memory, 1024);
+
 return 0;
 }
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
new file mode 100644
index 000..5c807ed
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-memory-hotplug-nonuma.xml
@@ -0,0 +1,22 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  

Re: [libvirt] [PATCH 1/4] parallels: set cpu mode when applying xml configuration

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:40, Maxim Nestratov wrote:
 From: Mikhail Feoktistov mfeoktis...@parallels.com
 
 Otherwise exporting existing domain config and defining a new one like this:
 virsh -c parallels:///system dumpxml instance01  my.xml
 virsh -c parallels:///system define my.xml
 leads to an error because PCS default x64 mode turns to x32.
 Thus, we need to set correct cpuMode in prlsdkDoApplyConfig() explicitly.
 
 Signed-off-by: Mikhail Feoktistov mfeoktis...@parallels.com
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |   13 +
  1 files changed, 13 insertions(+), 0 deletions(-)
 
 diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
 index 4c90a18..b6026fd 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -2957,6 +2957,19 @@ prlsdkDoApplyConfig(virConnectPtr conn,
  prlsdkCheckRetGoto(pret, error);
  VIR_FREE(mask);
  
 +switch (def-os.arch) {
 +case VIR_ARCH_X86_64:
 +pret = PrlVmCfg_SetCpuMode(sdkdom, PCM_CPU_MODE_64);
 +break;
 +case VIR_ARCH_I686:
 +pret = PrlVmCfg_SetCpuMode(sdkdom, PCM_CPU_MODE_32);
 +break;
 +default:
 +virReportError(VIR_ERR_INTERNAL_ERROR, _(Unknown CPU mode: 
 %X), def-os.arch);

We can use virArchToString() to report human readable cpu arch.

 +goto error;
 +}
 +prlsdkCheckRetGoto(pret, error);
 +
  if (prlsdkClearDevices(sdkdom)  0)
  goto error;
  
 

ACK with this squashed in:

diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index ec3372f..3a7efe3 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -2894,7 +2894,9 @@ prlsdkDoApplyConfig(PRL_HANDLE sdkdom,
 pret = PrlVmCfg_SetCpuMode(sdkdom, PCM_CPU_MODE_32);
 break;
 default:
-virReportError(VIR_ERR_INTERNAL_ERROR, _(Unknown CPU mode: %X), 
def-os.arch);
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _(Unknown CPU mode: %s),
+   virArchToString(def-os.arch));
 goto error;
 }
 prlsdkCheckRetGoto(pret, error);


Michal

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


Re: [libvirt] [PATCH 2/4] parallels: don't forget to unlock domain if unregister fails

2015-03-17 Thread Michal Privoznik
On 13.03.2015 16:40, Maxim Nestratov wrote:
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_driver.c |7 ++-
  1 files changed, 6 insertions(+), 1 deletions(-)
 
 diff --git a/src/parallels/parallels_driver.c 
 b/src/parallels/parallels_driver.c
 index d2907cf..aeb43ad 100644
 --- a/src/parallels/parallels_driver.c
 +++ b/src/parallels/parallels_driver.c
 @@ -948,6 +948,7 @@ parallelsDomainUndefineFlags(virDomainPtr domain,
  {
  parallelsConnPtr privconn = domain-conn-privateData;
  virDomainObjPtr dom = NULL;
 +int ret;
  
  virCheckFlags(0, -1);
  
 @@ -957,7 +958,11 @@ parallelsDomainUndefineFlags(virDomainPtr domain,
  return -1;
  }
  
 -return prlsdkUnregisterDomain(privconn, dom);
 +ret = prlsdkUnregisterDomain(privconn, dom);
 +if (ret)
 + virObjectUnlock(dom);
 +
 +return ret;
  }
  
  static int
 

Nice catch. ACK.

Michal

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


Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-03-17 Thread Antoni Segura Puimedon
On Tue, Mar 17, 2015 at 4:26 PM, Laine Stump la...@laine.org wrote:

  On 02/24/2015 04:17 AM, Antoni Segura Puimedon wrote:



 On Tue, Feb 24, 2015 at 3:30 AM, Laine Stump la...@redhat.com wrote:

  On 02/23/2015 08:48 PM, YAMAMOTO Takashi wrote:
  On Tue, Feb 24, 2015 at 2:20 AM, YAMAMOTO Takashi 
 yamam...@valinux.co.jp
  wrote:
 
  Adds the port type definitions and methods that will be used to bind
  interfaces to the Midonet virtual ports.
 
  virtnetdevmidonet.c adds the way to bind and unbind the ports by
  calling into the Midonet Host Agent control command line (installed
  with the midolman package).
 
  Signed-off-by: Antoni Segura Puimedon toni+libv...@midokura.com
 
  have you considered a script-based solution which would be able
  to cover openvswitch case as well?
 
 
  Can you elaborate? For script I can only think about having an xml node
  that can be specified for the port type that says what should be run
 for
  attachment (like with the ethernet mode). But I'm not sure how it
 would fit
  right now.
 
  i meant to have a run a script port type.
  the script runs ovs-vsctl, mm-ctl, or whatever internally.

  We actively avoid calling free-form scripts as much as possible. It is
 too difficult to support, and opens the possibility of security problems.

 For that matter, we even prefer to not call external binaries if we can
 avoid it, and eliminate existing executions of external binaries
 whenever we get the change. The only reason we agreed to executing
 ovs-vsctl is because there is no defined public API for Open vSwitch
 that uses a library, netlink message, ioctl, etc. (at least there wasn't
 at the time that code was added).


 I was wondering for some time if it would make it better for ovs and
  midonet, in terms of interoperability with the rest of the linux stack
 (in this case libvirt) if they exposed their methods to dbus. What do
  you think about that? (obviously that would take a few releases of
 both.


 Just now saw this message. It would be really nice if they exposed their
 methods *somehow* (I'm curious why you suggest dbus; what about netlink? I
 have no love for netlink (or dbus), but other network things (aside from
 NetworkManager) seem to use netlink.


I'll check it out for a future binding. We'll still have the cli, but maybe
we can update this to use some netlink/protobuf/dbus api call.



 The really important thing, though, is that whatever API is provided, that
 it be *set in stone* and never change in a way that isn't backward
 compatible. libvirt's API is an example of doing this successfully - years
 have gone by and we haven't had to increment the .so major version.


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

Re: [libvirt] [PATCH 0/7] Fix ejecting of network backed cdroms via virsh

2015-03-17 Thread Peter Krempa
On Tue, Mar 17, 2015 at 16:45:43 +0100, Michal Privoznik wrote:
 On 12.03.2015 18:09, Peter Krempa wrote:
  It turned out that not only virsh was broken ...
  
  Peter Krempa (7):
virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach
  disk
virsh: domain: Add --print-xml flag for command change-media
virsh: domain: Fix the change-media command
qemu: hotplug: Use checker function to check if disk is empty
qemu: driver: Fix cold-update of removable storage devices
util: storage: Fix check for empty storage device
conf: disk: Simplify checking if source definition was parsed
  
   src/conf/domain_conf.c|  12 ++--
   src/qemu/qemu_driver.c|  16 ++---
   src/qemu/qemu_hotplug.c   |   2 +-
   src/util/virstoragefile.c |   4 ++
   tools/virsh-domain.c  | 171 
  --
   tools/virsh.pod   |   7 +-
   6 files changed, 112 insertions(+), 100 deletions(-)
  
 
 ACK series.

Thanks, I've fixed the missing comma and pushed the series.

Peter


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

Re: [libvirt] [PATCH 2/3 v3] Schema and docs for the midonet virtualport type

2015-03-17 Thread Laine Stump
On 02/23/2015 03:54 PM, Antoni Segura Puimedon wrote:
 Midonet is an opensource virtual networking that over lays the IP
 network between hypervisors. Currently, such networks can be made
 with the openvswitch virtualport type.

 This patch, defines the schema and documentation that will serve
 as basis for the follow up patches that will add support to libvirt
 for using Midonet virtual ports for its interfaces. The schema
 definition requires that the port profile expresses its interfaceid
 as part of the port profile. For that reason, this is part of the
 patch too.

As we discussed on IRC just now, libvirt's parsers don't enforce the
schemas in the RNG files by default, so a small extra bit is necessary
to make sure that an interfaceid is always present. I've squashed the
following small bit into virNetDevVPortProfileCheckComplete() before
pushing:


diff --git a/src/util/virnetdevvportprofile.c
b/src/util/virnetdevvportprofile.c
index 09acb52..547894c 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -189,6 +189,11 @@
virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
 }
 }
 break;
+
+case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
+   if (!virtport-interfaceID_specified)
+  missing = interfaceid;
+   break;
 }
 
 if (missing) {

ACK with that change along with the couple small grammar fixes I point
out below. I've squashed these all in and will be pushing as soon as I
look through 3/3.


 Signed-off-by: Antoni Segura Puimedon toni+libv...@midokura.com
 ---
  docs/formatdomain.html.in  | 34 +
  docs/schemas/networkcommon.rng | 12 
  src/conf/netdev_vport_profile_conf.c   |  3 +-
  .../qemuxml2argvdata/qemuxml2argv-net-midonet.xml  | 35 
 ++
  tests/qemuxml2xmltest.c|  1 +
  5 files changed, 84 insertions(+), 1 deletion(-)
  create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-midonet.xml

 diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
 index f6477c2..1c2bb45 100644
 --- a/docs/formatdomain.html.in
 +++ b/docs/formatdomain.html.in
 @@ -3652,6 +3652,40 @@
lt;/devicesgt;
.../pre
  
 +p
 +  On hosts that support Open vSwitch on the kernel side and that have the

s/that have/have/

 +  Midonet Host Agent configured, it is also possible to connect to the
 +  'midonet' bridge device by adding a
 +  codelt;virtualport type='midonet'/gt;/code to the
 +  interface definition.  (span class=sinceSince
 +  1.2.13/span). The Midonet virtualport type requires an
 +  codeinterfaceid/code attribute to its
 +  codelt;parametersgt;/code element.

s/to its/in its/

  This interface id is the UUID
 +  that specifies which port in the virtual network topology will be bound
 +  to the interface.
 +/p
 +pre
 +  ...
 +  lt;devicesgt;
 +...
 +lt;interface type='bridge'gt;
 +  lt;source bridge='br0'/gt;
 +lt;/interfacegt;
 +lt;interface type='bridge'gt;
 +  lt;source bridge='br1'/gt;
 +  lt;target dev='vnet7'/gt;
 +  lt;mac address=00:11:22:33:44:55/gt;
 +lt;/interfacegt;
 +lt;interface type='bridge'gt;
 +  lt;source bridge='midonet'/gt;
 +  lt;virtualport type='midonet'gt;
 +lt;parameters 
 interfaceid='0b2d64da-3d0e-431e-afdd-804415d6ebbb'/gt;
 +  lt;/virtualportgt;
 +lt;/interfacegt;
 +...
 +  lt;/devicesgt;
 +  .../pre
 +
  h5a name=elementsNICSSlirpUserspace SLIRP stack/a/h5
  
  p
 diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
 index 162ea3d..cc8b1dc 100644
 --- a/docs/schemas/networkcommon.rng
 +++ b/docs/schemas/networkcommon.rng
 @@ -79,6 +79,18 @@
  /element
/group
group
 +element name=virtualport
 +  attribute name=type
 +valuemidonet/value
 +  /attribute
 +  element name=parameters
 +attribute name=interfaceid
 +  ref name=UUID/
 +/attribute
 +  /element
 +/element
 +  /group
 +  group
  !-- use this when no type attribute is present --
  element name=virtualport
optional
 diff --git a/src/conf/netdev_vport_profile_conf.c 
 b/src/conf/netdev_vport_profile_conf.c
 index 8da0838..1641a3e 100644
 --- a/src/conf/netdev_vport_profile_conf.c
 +++ b/src/conf/netdev_vport_profile_conf.c
 @@ -260,7 +260,8 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr 
 virtPort,
  virBufferAsprintf(buf,  instanceid='%s', uuidstr);
  }
  if (virtPort-interfaceID_specified 
 -(type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH ||
 +(type == VIR_NETDEV_VPORT_PROFILE_MIDONET ||
 + type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH ||
   type == VIR_NETDEV_VPORT_PROFILE_NONE)) {
  char uuidstr[VIR_UUID_STRING_BUFLEN];

Re: [libvirt] [PATCH 1/3 v3] utilities for supporting midonet virtualports

2015-03-17 Thread Laine Stump
On 02/23/2015 03:54 PM, Antoni Segura Puimedon wrote:
 Adds the port type definitions and methods that will be used to bind
 interfaces to the Midonet virtual ports.

 virtnetdevmidonet.c adds the way to bind and unbind the ports by
 calling into the Midonet Host Agent control command line (installed
 with the midolman package).

 Signed-off-by: Antoni Segura Puimedon toni+libv...@midokura.com
 ---
  configure.ac |  4 ++
  po/POTFILES.in   |  1 +
  src/Makefile.am  |  1 +
  src/libvirt_private.syms |  5 +++
  src/util/virnetdevmidonet.c  | 97 
 
  src/util/virnetdevmidonet.h  | 37 +++
  src/util/virnetdevvportprofile.c |  3 +-
  src/util/virnetdevvportprofile.h |  3 +-
  8 files changed, 149 insertions(+), 2 deletions(-)
  create mode 100644 src/util/virnetdevmidonet.c
  create mode 100644 src/util/virnetdevmidonet.h

ACK with a couple very minor formatting changes.


 diff --git a/configure.ac b/configure.ac
 index b3e99e7..ddffbb2 100644
 --- a/configure.ac
 +++ b/configure.ac
 @@ -425,6 +425,8 @@ AC_PATH_PROG([MODPROBE], [modprobe], [modprobe],
   [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
  AC_PATH_PROG([RMMOD], [rmmod], [rmmod],
   [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
 +AC_PATH_PROG([MMCTL], [mm-ctl], [mm-ctl],
 + [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
  AC_PATH_PROG([OVSVSCTL], [ovs-vsctl], [ovs-vsctl],
   [/sbin:/usr/sbin:/usr/local/sbin:$PATH])
  AC_PATH_PROG([SCRUB], [scrub], [scrub],
 @@ -440,6 +442,8 @@ AC_DEFINE_UNQUOTED([RADVD],[$RADVD],
  [Location or name of the radvd program])
  AC_DEFINE_UNQUOTED([TC],[$TC],
  [Location or name of the tc program (see iproute2)])
 +AC_DEFINE_UNQUOTED([MMCTL],[$MMCTL],
 +[Location or name of the mm-ctl program])
  AC_DEFINE_UNQUOTED([OVSVSCTL],[$OVSVSCTL],
  [Location or name of the ovs-vsctl program])
  
 diff --git a/po/POTFILES.in b/po/POTFILES.in
 index 3064037..cdfc839 100644
 --- a/po/POTFILES.in
 +++ b/po/POTFILES.in
 @@ -195,6 +195,7 @@ src/util/virnetdev.c
  src/util/virnetdevbandwidth.c
  src/util/virnetdevbridge.c
  src/util/virnetdevmacvlan.c
 +src/util/virnetdevmidonet.c
  src/util/virnetdevopenvswitch.c
  src/util/virnetdevtap.c
  src/util/virnetdevveth.c
 diff --git a/src/Makefile.am b/src/Makefile.am
 index b41c6d4..23d3f93 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -129,6 +129,7 @@ UTIL_SOURCES =
 \
   util/virnetdevbandwidth.h util/virnetdevbandwidth.c \
   util/virnetdevbridge.h util/virnetdevbridge.c   \
   util/virnetdevmacvlan.c util/virnetdevmacvlan.h \
 + util/virnetdevmidonet.h util/virnetdevmidonet.c \
   util/virnetdevopenvswitch.h util/virnetdevopenvswitch.c \
   util/virnetdevtap.h util/virnetdevtap.c \
   util/virnetdevveth.h util/virnetdevveth.c   \
 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
 index 46a1613..0938cdc 100644
 --- a/src/libvirt_private.syms
 +++ b/src/libvirt_private.syms
 @@ -1738,6 +1738,11 @@ virNetDevMacVLanRestartWithVPortProfile;
  virNetDevMacVLanVPortProfileRegisterCallback;
  
  
 +# util/virnetdevmidonet.h
 +virNetDevMidonetBindPort;
 +virNetDevMidonetUnbindPort;
 +
 +
  # util/virnetdevopenvswitch.h
  virNetDevOpenvswitchAddPort;
  virNetDevOpenvswitchGetMigrateData;
 diff --git a/src/util/virnetdevmidonet.c b/src/util/virnetdevmidonet.c
 new file mode 100644
 index 000..57fb636
 --- /dev/null
 +++ b/src/util/virnetdevmidonet.c
 @@ -0,0 +1,97 @@
 +/*
 + * Copyright (C) 2015 Midokura, Sarl.
 + *
 + * This library is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU Lesser General Public
 + * License as published by the Free Software Foundation; either
 + * version 2.1 of the License, or (at your option) any later version.
 + *
 + * This library is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * Lesser General Public License for more details.
 + *
 + * You should have received a copy of the GNU Lesser General Public
 + * License along with this library.  If not, see
 + * http://www.gnu.org/licenses/.
 + *
 + * Authors:
 + * Antoni Segura Puimedon t...@midokura.com
 + */
 +
 +#include config.h
 +
 +#include virnetdevmidonet.h
 +#include vircommand.h
 +#include viralloc.h
 +#include virerror.h
 +#include viruuid.h
 +
 +#define VIR_FROM_THIS VIR_FROM_NONE
 +
 +/**
 + * virNetDevMidonetBindPort:
 + * @ifname: the network interface name
 + * @virtualport: the midonet specific fields
 + *
 + * Bind an interface to a Midonet virtual port
 + *
 + * Returns 0 in case of success or -1 in case of failure.
 + */
 +int virNetDevMidonetBindPort(const char *ifname,
 + 

Re: [libvirt] [PATCH v2] parallels: minor cleanup

2015-03-17 Thread Maxim Nestratov

17.03.2015 18:56, Michal Privoznik пишет:

I've updated the commit message, ACKed and pushed.

Michal
Thank you Michal. Next time I'll use your commit message as an example 
for such cleanups. I really thought mine was enough.


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

Re: [libvirt] [PATCH 0/7] Fix ejecting of network backed cdroms via virsh

2015-03-17 Thread Michal Privoznik
On 12.03.2015 18:09, Peter Krempa wrote:
 It turned out that not only virsh was broken ...
 
 Peter Krempa (7):
   virsh: domain: Don't use vshPrepareDiskXML for creating XML to detach
 disk
   virsh: domain: Add --print-xml flag for command change-media
   virsh: domain: Fix the change-media command
   qemu: hotplug: Use checker function to check if disk is empty
   qemu: driver: Fix cold-update of removable storage devices
   util: storage: Fix check for empty storage device
   conf: disk: Simplify checking if source definition was parsed
 
  src/conf/domain_conf.c|  12 ++--
  src/qemu/qemu_driver.c|  16 ++---
  src/qemu/qemu_hotplug.c   |   2 +-
  src/util/virstoragefile.c |   4 ++
  tools/virsh-domain.c  | 171 
 --
  tools/virsh.pod   |   7 +-
  6 files changed, 112 insertions(+), 100 deletions(-)
 

ACK series.

Michal

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


Re: [libvirt] [PATCH 2/7] virsh: domain: Add --print-xml flag for command change-media

2015-03-17 Thread Michal Privoznik
On 12.03.2015 18:09, Peter Krempa wrote:
 Allow printing the XML that would be used mostly for debugging purposes.
 ---
  tools/virsh-domain.c | 17 +
  tools/virsh.pod  |  3 +++
  2 files changed, 16 insertions(+), 4 deletions(-)
 
 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
 index 8bc0512..23d0b63 100644
 --- a/tools/virsh-domain.c
 +++ b/tools/virsh-domain.c
 @@ -12274,6 +12274,10 @@ static const vshCmdOptDef opts_change_media[] = {
   .type = VSH_OT_BOOL,
   .help = N_(force media changing)
  },
 +{.name = print-xml,
 + .type = VSH_OT_BOOL,
 + .help = N_(print XML document rather than change media)
 +},
  {.name = NULL}
  };
 
 @@ -12354,12 +12358,17 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
  if (!(disk_xml = vshPrepareDiskXML(disk_node, source, path, 
 prepare_type)))
  goto cleanup;
 
 -if (virDomainUpdateDeviceFlags(dom, disk_xml, flags) != 0) {
 -vshError(ctl, _(Failed to complete action %s on media), action);
 -goto cleanup;
 +if (vshCommandOptBool(cmd, print-xml)) {
 +vshPrint(ctl, %s, disk_xml);
 +} else {
 +if (virDomainUpdateDeviceFlags(dom, disk_xml, flags) != 0) {
 +vshError(ctl, _(Failed to complete action %s on media), 
 action);
 +goto cleanup;
 +}
 +
 +vshPrint(ctl, _(succeeded to complete action %s on media\n), 
 action);
  }
 
 -vshPrint(ctl, _(succeeded to complete action %s on media\n), action);
  ret = true;
 
   cleanup:
 diff --git a/tools/virsh.pod b/tools/virsh.pod
 index 714de34..7d43f6f 100644
 --- a/tools/virsh.pod
 +++ b/tools/virsh.pod
 @@ -2581,6 +2581,7 @@ expected.
 
  =item Bchange-media Idomain Ipath [I--eject] [I--insert]
  [I--update] [Isource] [I--force] [[I--live] [I--config] | 
 [I--current]]
 +[I--print-xml]
 
  Change media of CDROM or floppy drive. Ipath can be the fully-qualified 
 path
  or the unique target name (target dev='hdc') of the disk device. Isource
 @@ -2604,6 +2605,8 @@ the hypervisor's implementation.
  Both I--live and I--config flags may be given, but I--current is
  exclusive. If no flag is specified, behavior is different depending
  on hypervisor.
 +If I--print-xml is specified the XML that would be used to change media is
 +printed instead of changing the media.

s/specified/specified,/

Michal

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


Re: [libvirt] [PATCH v2] parallels: minor cleanup

2015-03-17 Thread Michal Privoznik
On 17.03.2015 16:21, Maxim Nestratov wrote:
 v2 change:
 rebased to the current master

We usually put the diff to previous versions in between commit message
and diff stat. That way git ignores the diff and it's not part of the
commit message.

 
 indentation is fixed, unnecessary error message removed,
 unnecessary job freeing removed

This is not much explanatory.

 
 Signed-off-by: Maxim Nestratov mnestra...@parallels.com
 ---
  src/parallels/parallels_sdk.c |5 +
  1 files changed, 1 insertions(+), 4 deletions(-)
 
 diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
 index ee71bd6..a0b62cd 100644
 --- a/src/parallels/parallels_sdk.c
 +++ b/src/parallels/parallels_sdk.c
 @@ -701,7 +701,7 @@ prlsdkGetNetInfo(PRL_HANDLE netAdapter, 
 virDomainNetDefPtr net, bool isCt)
  goto cleanup;
  
  pret = PrlVmDevNet_GetHostInterfaceName(netAdapter, net-ifname, 
 buflen);
 -prlsdkCheckRetGoto(pret, cleanup);
 +prlsdkCheckRetGoto(pret, cleanup);
  
  if (isCt  netAdapterIndex == (PRL_UINT32) -1) {
  /* venet devices don't have mac address and
 @@ -1350,7 +1350,6 @@ prlsdkLoadDomains(parallelsConnPtr privconn)
  
   error:
  PrlHandle_Free(result);
 -PrlHandle_Free(job);
  return -1;
  }
  
 @@ -1730,8 +1729,6 @@ prlsdkDomainChangeState(virDomainPtr domain,
  
  pdom = dom-privateData;
  pret = chstate(privconn, pdom-sdkdom);
 -virReportError(VIR_ERR_OPERATION_FAILED,
 -   _(Can't change domain state: %d), pret);
  if (PRL_FAILED(pret)) {
  virResetLastError();
  
 

I've updated the commit message, ACKed and pushed.

Michal

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


[libvirt] [PATCH 2/5] virsh: Adapt to new HW address scenario

2015-03-17 Thread Michal Privoznik
Make sure we don't print (null) (which in fact is printf()'s
cleverness anyway, not ours). If no HW address is present, print
N/A string just like we do for other fields.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 tools/virsh-domain-monitor.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index c9bf156..0717076 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2278,7 +2278,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 /* When the interface has no IP address */
 if (!iface-naddrs) {
 vshPrintExtra(ctl,  %-10s %-17s%-12s %s\n,
-  iface-name, iface-hwaddr, N/A, N/A);
+  iface-name,
+  iface-hwaddr ? iface-hwaddr : N/A, N/A, N/A);
 continue;
 }
 
@@ -2312,7 +2313,8 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
 /* Don't repeat interface name */
 if (full || !j)
 vshPrintExtra(ctl,  %-10s %-17s%s\n,
-  iface-name, iface-hwaddr, ip_addr_str);
+  iface-name,
+  iface-hwaddr ? iface-hwaddr : , ip_addr_str);
 else
 vshPrintExtra(ctl,  %-10s %-17s%s\n,
   -, -, ip_addr_str);
-- 
2.0.5

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


[libvirt] [PATCH 3/5] qemuAgentGetInterfaces: Don't error out on missing HW address

2015-03-17 Thread Michal Privoznik
Now that we allow HW address to be not present on our RPC layer,
don't error out if qemu-ga hasn't provided any.

Signed-off-by: Michal Privoznik mpriv...@redhat.com
---
 src/qemu/qemu_agent.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 5f90b15..a7b3279 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2054,13 +2054,6 @@ qemuAgentGetInterfaces(qemuAgentPtr mon,
 goto error;
 
 hwaddr = virJSONValueObjectGetString(tmp_iface, 
hardware-address);
-if (!hwaddr) {
-virReportError(VIR_ERR_INTERNAL_ERROR, %s,
-   _(qemu agent didn't provide
-  'hardware-address' field));
-goto error;
-}
-
 if (VIR_STRDUP(iface-hwaddr, hwaddr)  0)
 goto error;
 }
-- 
2.0.5

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


Re: [libvirt] [PATCH 3/3 v3] Add midonet virtual port type support to qemu

2015-03-17 Thread Laine Stump
On 02/23/2015 03:54 PM, Antoni Segura Puimedon wrote:
 Use the utilities introduced in the previous patches so the qemu
 driver is able to create tap devices that are bound (and unbound
 on domain destroyal) to Midonet virtual ports.

 Signed-off-by: Antoni Segura Puimedon toni+libv...@midokura.com
 ---
  src/conf/domain_conf.h  |  1 +
  src/qemu/qemu_hotplug.c | 25 ++---
  src/qemu/qemu_process.c | 13 +
  src/util/virnetdevtap.c | 11 ---
  4 files changed, 36 insertions(+), 14 deletions(-)

 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index 325afa8..cafe50f 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -42,6 +42,7 @@
  # include virnetdevmacvlan.h
  # include virsysinfo.h
  # include virnetdevvportprofile.h
 +# include virnetdevmidonet.h
  # include virnetdevopenvswitch.h

I'm not sure why virnetdevopenvswitch.h is included here, as nothing
from it is used in domain_conf.h. Maybe it was there because
virnetdevbandwidth was already there. At any rate, it shouldn't be there
(I'll send a patch to fix that in a bit), and neither should
virnetdevmidonet.h. Instead, virnetdevmidonet.h should be included in
qemu_process.c and qemu_hotplug.c, where the functions are actually used.

I changed that locally and will squash it in.

  # include virnetdevbandwidth.h
  # include virnetdevvlan.h
 diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
 index 8691c7e..34d7988 100644
 --- a/src/qemu/qemu_hotplug.c
 +++ b/src/qemu/qemu_hotplug.c
 @@ -1141,9 +1141,15 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
  }
  
  vport = virDomainNetGetActualVirtPortProfile(net);
 -if (vport  vport-virtPortType == 
 VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
 -   ignore_value(virNetDevOpenvswitchRemovePort(
 -   virDomainNetGetActualBridgeName(net), 
 net-ifname));
 +if (vport) {
 +if (vport-virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) 
 {
 +ignore_value(virNetDevMidonetUnbindPort(vport));
 +} else if (vport-virtPortType == 
 VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
 +ignore_value(virNetDevOpenvswitchRemovePort(
 + virDomainNetGetActualBridgeName(net),
 + net-ifname));
 +}
 +}
  }
  
  virDomainNetRemoveHostdev(vm-def, net);
 @@ -2934,10 +2940,15 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
  }
  
  vport = virDomainNetGetActualVirtPortProfile(net);
 -if (vport  vport-virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
 -ignore_value(virNetDevOpenvswitchRemovePort(
 -virDomainNetGetActualBridgeName(net),
 -net-ifname));
 +if (vport) {
 +if (vport-virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
 +ignore_value(virNetDevMidonetUnbindPort(vport));
 +} else if (vport-virtPortType == 
 VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
 +ignore_value(virNetDevOpenvswitchRemovePort(
 + virDomainNetGetActualBridgeName(net),
 + net-ifname));
 +}
 +}
  
  networkReleaseActualDevice(vm-def, net);
  virDomainNetDefFree(net);
 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
 index 1d4e957..982f802 100644
 --- a/src/qemu/qemu_process.c
 +++ b/src/qemu/qemu_process.c
 @@ -5291,10 +5291,15 @@ void qemuProcessStop(virQEMUDriverPtr driver,
  /* release the physical device (or any other resources used by
   * this interface in the network driver
   */
 -if (vport  vport-virtPortType == 
 VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
 -ignore_value(virNetDevOpenvswitchRemovePort(
 -   virDomainNetGetActualBridgeName(net),
 -   net-ifname));
 +if (vport) {
 +if (vport-virtPortType == VIR_NETDEV_VPORT_PROFILE_MIDONET) {
 +ignore_value(virNetDevMidonetUnbindPort(vport));
 +} else if (vport-virtPortType == 
 VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {
 +ignore_value(virNetDevOpenvswitchRemovePort(
 + virDomainNetGetActualBridgeName(net),
 + net-ifname));
 +}
 +}
  

So much common code. This should really go in a utility function in the
new qemu_interface.c (along with lots of other code, so it's nothing to
worry about here; just thought I'd mention it)

  /* kick the device out of the hostdev list too */
  virDomainNetRemoveHostdev(def, net);
 diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
 index 83b4131..f6152e9 100644
 --- a/src/util/virnetdevtap.c
 +++ b/src/util/virnetdevtap.c
 @@ -26,6 +26,7 @@
  

[libvirt] [PATCH 0/5] Couple of virDomainInterfaceAddresses fixes

2015-03-17 Thread Michal Privoznik
While testing the new API I've noticed some leaks and other
errors.  The very first patch changes the RPC protocol, but hey -
on an unreleased procedure yet!

Michal Privoznik (5):
  RPC: Allow HW address in remote_domain_interface struct to be NULL
  virsh: Adapt to new HW address scenario
  qemuAgentGetInterfaces: Don't error out on missing HW address
  cmdDomIfAddr: Free @ip_addr_str
  qemuGetDHCPInterfaces: Don't leak @network

 daemon/remote.c  |  5 -
 include/libvirt/libvirt-domain.h |  2 +-
 src/libvirt-domain.c |  3 ++-
 src/qemu/qemu_agent.c|  7 ---
 src/qemu/qemu_driver.c   |  6 +-
 src/remote/remote_driver.c   |  3 ++-
 src/remote/remote_protocol.x |  2 +-
 src/remote_protocol-structs  |  2 +-
 tools/virsh-domain-monitor.c | 11 +++
 9 files changed, 23 insertions(+), 18 deletions(-)

-- 
2.0.5

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


  1   2   >