[libvirt] [patch] Add openvzDomainSetMemoryInternal

2009-10-27 Thread Yuji NISHIDA

Hi all,

This patch is to set KMEMSIZE for OpenVZ.
This function is used for initializing the parameter of KMEMSIZE to  
start container.
openvzDomainSetMemory should be left for another purpose so I added  
new one.


I think users should specify memory as kbyte ( or bigger ).

---
 src/openvz/openvz_driver.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index f64ad1e..5c1fefa 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -69,6 +69,7 @@ static int openvzGetMaxVCPUs(virConnectPtr conn,  
const char *type);

 static int openvzDomainGetMaxVcpus(virDomainPtr dom);
 static int openvzDomainSetVcpus(virDomainPtr dom, unsigned int  
nvcpus);
 static int openvzDomainSetVcpusInternal(virConnectPtr conn,  
virDomainObjPtr vm, unsigned int nvcpus);
+static int openvzDomainSetMemoryInternal(virConnectPtr conn,  
virDomainObjPtr vm, unsigned long memory);


 static void openvzDriverLock(struct openvz_driver *driver)
 {
@@ -803,6 +804,14 @@ openvzDomainDefineXML(virConnectPtr conn, const  
char *xml)

 }
 }

+if (vm-def-memory  0) {
+if (openvzDomainSetMemoryInternal(conn, vm, vm-def-memory)  
 0) {

+openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+ %s, _(Could not set memory size));
+ goto cleanup;
+}
+}
+
 dom = virGetDomain(conn, vm-def-name, vm-def-uuid);
 if (dom)
 dom-id = -1;
@@ -1364,6 +1373,29 @@ static int openvzNumDefinedDomains 
(virConnectPtr conn) {

 return ninactive;
 }

+static int openvzDomainSetMemoryInternal(virConnectPtr conn,  
virDomainObjPtr vm,

+ unsigned long mem) {
+struct openvz_driver *driver = conn-privateData;
+char str_mem[16];
+const char *prog[] = { VZCTL, --quiet, set, PROGRAM_SENTINAL,
+   --kmemsize, str_mem, --save, NULL };
+
+/* memory has to be changed its format from kbyte to byte */
+snprintf( str_mem, sizeof(str_mem), %lu, mem * 1024 );
+
+openvzSetProgramSentinal(prog, vm-def-name);
+if (virRun(conn, prog, NULL)  0) {
+openvzError(conn, VIR_ERR_INTERNAL_ERROR,
+   _(Could not exec %s), VZCTL);
+goto cleanup;
+}
+
+return 0;
+
+cleanup:
+return -1;
+}
+
 static virDriver openvzDriver = {
 VIR_DRV_OPENVZ,
 OPENVZ,
--
1.5.3.4


-
Yuji Nishida
nish...@nict.go.jp

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


[libvirt] [PATCH 1/2] add ebtables wrapper

2009-10-27 Thread Gerhard Stenzel
This patch adds the files which implement the ebtables wrapper.

Signed-off-by: Gerhard Stenzel gerhard.sten...@de.ibm.com
---

 configure.in |3 
 src/Makefile.am  |1 
 src/libvirt_private.syms |7 +
 src/util/ebtables.c  |  441 ++
 src/util/ebtables.h  |   65 +++
 5 files changed, 517 insertions(+), 0 deletions(-)
 create mode 100644 src/util/ebtables.c
 create mode 100644 src/util/ebtables.h

diff --git a/configure.in b/configure.in
index 2f9db72..d8abf9f 100644
--- a/configure.in
+++ b/configure.in
@@ -287,6 +287,9 @@ fi
 AC_PATH_PROG([IPTABLES_PATH], [iptables], /sbin/iptables, [/usr/sbin:$PATH])
 AC_DEFINE_UNQUOTED([IPTABLES_PATH], $IPTABLES_PATH, [path to iptables 
binary])
 
+AC_PATH_PROG([EBTABLES_PATH], [ebtables], /sbin/ebtables, [/usr/sbin:$PATH])
+AC_DEFINE_UNQUOTED([EBTABLES_PATH], $EBTABLES_PATH, [path to ebtables 
binary])
+
 if test $with_openvz = yes; then
 AC_DEFINE_UNQUOTED([WITH_OPENVZ], 1, [whether OpenVZ driver is enabled])
 fi
diff --git a/src/Makefile.am b/src/Makefile.am
index 8e27ea7..055573a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -51,6 +51,7 @@ UTIL_SOURCES =
\
util/event.c util/event.h   \
util/hash.c util/hash.h \
util/iptables.c util/iptables.h \
+   util/ebtables.c util/ebtables.h \
util/logging.c util/logging.h   \
util/memory.c util/memory.h \
util/pci.c util/pci.h   \
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 98ea7f8..42fb654 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -234,6 +234,13 @@ iptablesRemoveUdpInput;
 iptablesSaveRules;
 
 
+# ebtables.h
+ebtablesRemoveForwardAllowIn;
+ebtablesAddForwardAllowIn;
+ebtablesAddForwardPolicyReject;
+ebtablesContextNew;
+ebtablesSaveRules;
+
 # libvirt_internal.h
 virStateInitialize;
 virStateCleanup;
diff --git a/src/util/ebtables.c b/src/util/ebtables.c
new file mode 100644
index 000..78f273a
--- /dev/null
+++ b/src/util/ebtables.c
@@ -0,0 +1,441 @@
+/*
+ * Copyright (C) 2009 IBM Corp.
+ * Copyright (C) 2007-2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ *
+ * based on iptables.c
+ * Authors:
+ * Gerhard Stenzel gerhard.sten...@de.ibm.com
+ */
+
+#include config.h
+
+#include stdio.h
+#include stdlib.h
+#include stdarg.h
+#include string.h
+#include errno.h
+#include limits.h
+#include unistd.h
+#include fcntl.h
+#include sys/types.h
+#include sys/stat.h
+
+#ifdef HAVE_SYS_WAIT_H
+#include sys/wait.h
+#endif
+
+#ifdef HAVE_PATHS_H
+#include paths.h
+#endif
+
+#include internal.h
+#include ebtables.h
+#include util.h
+#include memory.h
+#include virterror_internal.h
+#include logging.h
+
+struct _ebtablesContext
+{
+ebtRules *input_filter;
+ebtRules *forward_filter;
+ebtRules *nat_postrouting;
+};
+
+enum {
+ADD = 0,
+REMOVE,
+CREATE,
+POLICY,
+INSERT
+};
+
+static void
+ebtRulesSave(ebtRules *rules)
+{
+(void) rules;
+}
+
+static void
+ebtRuleFree(ebtRule *rule)
+{
+VIR_FREE(rule-rule);
+
+if (rule-argv) {
+int i = 0;
+while (rule-argv[i])
+VIR_FREE(rule-argv[i++]);
+VIR_FREE(rule-argv);
+}
+}
+
+static int
+ebtRulesAppend(ebtRules *rules,
+   char *rule,
+   const char **argv,
+   int command_idx)
+{
+if (VIR_REALLOC_N(rules-rules, rules-nrules+1)  0) {
+int i = 0;
+while (argv[i])
+VIR_FREE(argv[i++]);
+VIR_FREE(argv);
+return ENOMEM;
+}
+
+rules-rules[rules-nrules].rule= rule;
+rules-rules[rules-nrules].argv= argv;
+rules-rules[rules-nrules].command_idx = command_idx;
+
+rules-nrules++;
+
+return 0;
+}
+
+static int
+ebtRulesRemove(ebtRules *rules,
+   char *rule)
+{
+int i;
+
+for (i = 0; i  rules-nrules; i++)
+if (STREQ(rules-rules[i].rule, rule))
+break;
+
+if (i = rules-nrules)
+return EINVAL;
+

[libvirt] [PATCH 0/2] Add MAC filtering to qemu

2009-10-27 Thread Gerhard Stenzel
The following series of patches is a prototype implementation of a ebtables 
based MAC address filter. I hope to have addressed all the previous comments.

At the moment, some defaults are set when libvirtd starts and when a domain is 
started or destroyed. The plan is to extend this filter capability to the API 
level and virsh command level. The plan is also to add more filtering features 
like VLAN filtering and QoS filtering.

Thanks, Gerhard
---

Gerhard Stenzel (2):
  add MAC address based port filtering to qemu
  add ebtables wrapper


 configure.in  |3 
 po/POTFILES.in|1 
 src/Makefile.am   |5 
 src/libvirt_private.syms  |7 +
 src/qemu/qemu.conf|2 
 src/qemu/qemu_bridge_filter.c |  108 ++
 src/qemu/qemu_bridge_filter.h |   39 
 src/qemu/qemu_conf.c  |   25 ++
 src/qemu/qemu_conf.h  |4 
 src/qemu/qemu_driver.c|   16 +
 src/util/ebtables.c   |  441 +
 src/util/ebtables.h   |   65 ++
 12 files changed, 715 insertions(+), 1 deletions(-)
 create mode 100644 src/qemu/qemu_bridge_filter.c
 create mode 100644 src/qemu/qemu_bridge_filter.h
 create mode 100644 src/util/ebtables.c
 create mode 100644 src/util/ebtables.h

-- 
Best regards, 

Gerhard Stenzel, 
---
IBM Deutschland Research  Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Erich Baier
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

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


Re: [libvirt] [PATCH] Avoid segv if ncf_init fails

2009-10-27 Thread David Lutterkort
On Fri, 2009-10-23 at 20:31 +0100, Daniel P. Berrange wrote:
 On Fri, Oct 23, 2009 at 03:13:17PM -0400, Laine Stump wrote:
  If ncf_init() fails, it takes responsibility to call ncf_close() when
  appropriate. Having libvirt call it results in a double close, which
  ends up segv'ing.
 
 Hmm, it would be good if ncf_init  set the passed in pointer to NULL
 when it failed, then your existing cleanup check would have been
 safe.

Agreed - that that doesn't happen was an oversight. I'll fix that.

David


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


Re: [libvirt] [PATCH] Avoid segv if ncf_init fails

2009-10-27 Thread David Lutterkort
On Tue, 2009-10-27 at 14:23 +, David Lutterkort wrote:
 On Fri, 2009-10-23 at 20:31 +0100, Daniel P. Berrange wrote:
  On Fri, Oct 23, 2009 at 03:13:17PM -0400, Laine Stump wrote:
   If ncf_init() fails, it takes responsibility to call ncf_close() when
   appropriate. Having libvirt call it results in a double close, which
   ends up segv'ing.
  
  Hmm, it would be good if ncf_init  set the passed in pointer to NULL
  when it failed, then your existing cleanup check would have been
  safe.
 
 Agreed - that that doesn't happen was an oversight. I'll fix that.

Spoke too soon - ncf_init returns -2 when allocations fail so badly that
we can't even allocate the struct netcf (in which case ncf_init should
reset the pointer to NULL, but doesn't - that's the bug that needs to be
addressed) 

It can also return -1 for all kinds of other failures; in that case you
have a struct netcf that's good enough to pass to ncf_error to get more
error details.

David


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


[libvirt] [PATCH] Fix --with-init-script configure option

2009-10-27 Thread Matthew Booth
The --with-init-script configure option was broken, and always defaulted based
on the existence of /etc/redhat-release. This was a systematic typo based on
mixed use of init-script and init-scripts.
---
 configure.in   |   14 +++---
 daemon/Makefile.am |4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/configure.in b/configure.in
index 2f9db72..42ed29b 100644
--- a/configure.in
+++ b/configure.in
@@ -243,17 +243,17 @@ dnl init script flavor
 dnl
 AC_MSG_CHECKING([for init script flavor])
 AC_ARG_WITH([init-script],
-[AC_HELP_STRING([--with-init-scripts=[redhat|auto|none]],
-[Style of init scripts to install (defaults to auto)])])
-if test x$with_init_scripts = x -o x$with_init_scripts = xauto; then
+[AC_HELP_STRING([--with-init-script=[redhat|auto|none]],
+[Style of init script to install (defaults to auto)])])
+if test x$with_init_script = x -o x$with_init_script = xauto; then
 if test -f /etc/redhat-release ; then
-with_init_scripts=redhat
+with_init_script=redhat
 else
-with_init_scripts=none
+with_init_script=none
 fi
 fi
-AM_CONDITIONAL([LIBVIRT_INIT_SCRIPTS_RED_HAT], test x$with_init_scripts = 
xredhat)
-AC_MSG_RESULT($with_init_scripts)
+AM_CONDITIONAL([LIBVIRT_INIT_SCRIPT_RED_HAT], test x$with_init_script = 
xredhat)
+AC_MSG_RESULT($with_init_script)
 
 dnl RHEL-5 has a peculiar version of Xen, which requires some special casing
 AC_ARG_WITH([rhel5-api],
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index 84aab04..ab3f238 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -188,7 +188,7 @@ install-logrotate: libvirtd.logrotate
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d/
$(INSTALL_DATA) $ $(DESTDIR)$(sysconfdir)/logrotate.d/libvirtd
 
-if LIBVIRT_INIT_SCRIPTS_RED_HAT
+if LIBVIRT_INIT_SCRIPT_RED_HAT
 install-init: libvirtd.init
mkdir -p $(DESTDIR)$(sysconfdir)/rc.d/init.d
$(INSTALL_SCRIPT) libvirtd.init \
@@ -222,7 +222,7 @@ install-init:
 uninstall-init:
 libvirtd.init:
 
-endif # DBUS_INIT_SCRIPTS_RED_HAT
+endif # LIBVIRT_INIT_SCRIPT_RED_HAT
 
 # This must be added last, since functions it provides/replaces
 # are used by nearly every other library.
-- 
1.6.2.5

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


[libvirt] Trouble starting a QEMU guest with IPv6 VNC address

2009-10-27 Thread Kaitlin Rupert

Hello,

I am trying to start a QEMU guest with an IPv6 VNC address.  I can 
specify the address and start the guest, but the VNC port shows up under 
the IPv4 list:


# virsh dumpxml domU1 | grep graphics
graphics type='vnc' port='5900' autoport='no' listen='::1' 
keymap='en-us'/


# cat /proc/net/tcp | grep 170C
   2: :170C : 0A : 00: 
 00 621103 1 88007a043a80 299 0 0 2 -1 



# cat /proc/net/tcp6 | grep 170C
#

# ps -ef | grep qemu
root 16451 1 43 04:17 ?00:00:18 
/usr/bin/qemu-system-x86_64 -S -M pc -m 128 -smp 1 -name domU1 -uuid 
2aebe290-d1ed-11dd-90eb-001a64bc024c -monitor pty -pidfile 
/var/run/libvirt/qemu//domU1.pid -no-acpi -boot c -drive 
file=/tmp/default-kvm-dimage,if=ide,index=0,boot=on -net 
nic,macaddr=11:22:33:aa:bb:cc,vlan=0 -net tap,fd=17,vlan=0 -serial none 
-parallel none -usb -vnc ::1:0 -k en-us


I started the same guest manually, but I appended an ,ipv6' flag to the 
vnc option (see below).  With this change, the port shows up in the IPv6 
list.


# /usr/bin/qemu-system-x86_64 -M pc -m 128 -smp 1 -name domU1 -uuid 
2aebe290-d1ed-11dd-90eb-001a64bc024c -monitor pty -pidfile 
/var/run/libvirt/qemu//domU1.pid -no-acpi -boot c -drive 
file=/tmp/default-kvm-dimage,if=ide,index=0,boot=on -net 
nic,macaddr=11:22:33:aa:bb:cc,vlan=0 -net tap,fd=17,vlan=0 -serial none 
-parallel none -usb -vnc ::1:0,ipv6 -k en-us


# cat /proc/net/tcp6 | grep 170C
   2: :170C 
: 0A : 00: 
 00 621485 1 88007a30ad00 299 0 0 2 -1


# cat /proc/net/tcp | grep 170C
#

I'd like to fix the qemu driver so that it specifies this flag, but I am 
unsure whether a guest XML change or some other change is appropriate 
here.  Would it be better to have the qemu driver code do some detection 
on the address that is passed in?


Thanks!
--
Kaitlin Rupert
IBM Linux Technology Center
kait...@linux.vnet.ibm.com

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


[libvirt] [PATCH] qemu: Fix an error message in GetVcpus

2009-10-27 Thread Cole Robinson

Signed-off-by: Cole Robinson crobi...@redhat.com
---
 src/qemu/qemu_driver.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 082cb04..a3beedb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -3481,7 +3481,8 @@ qemudDomainGetVcpus(virDomainPtr dom,
 
 if (!virDomainIsActive(vm)) {
 qemudReportError(dom-conn, dom, NULL, VIR_ERR_OPERATION_INVALID,
- %s,_(cannot pin vcpus on an inactive domain));
+ %s,
+ _(cannot list vcpu pinning for an inactive domain));
 goto cleanup;
 }
 
-- 
1.6.5.rc2

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


[libvirt] [PATCH] Fix p2p migration without a passed uri.

2009-10-27 Thread Cole Robinson

Signed-off-by: Cole Robinson crobi...@redhat.com
---
 src/libvirt.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 926c539..126675e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3217,7 +3217,7 @@ virDomainMigrate (virDomainPtr domain,
 char *dstURI = NULL;
 if (uri == NULL) {
 dstURI = virConnectGetURI(dconn);
-if (!uri)
+if (!dstURI)
 return NULL;
 }
 
-- 
1.6.5.rc2

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


[libvirt] [PATCH] Improve error reporting for virConnectGetHostname calls

2009-10-27 Thread Cole Robinson
All drivers have copy + pasted inadequate error reporting which wraps
util.c:virGetHostname. Move all error reporting to this function, and improve
what we report.

Signed-off-by: Cole Robinson crobi...@redhat.com
---
 daemon/libvirtd.c   |3 +--
 src/lxc/lxc_driver.c|   10 +-
 src/qemu/qemu_driver.c  |   14 ++
 src/test/test_driver.c  |   10 +-
 src/uml/uml_driver.c|   10 +-
 src/util/util.c |   18 +++---
 src/util/util.h |2 +-
 src/vbox/vbox_tmpl.c|   11 +--
 src/xen/xen_driver.c|   10 +-
 src/xen/xend_internal.c |3 +--
 tools/virsh.c   |2 +-
 11 files changed, 26 insertions(+), 67 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 03d091a..058e684 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -939,9 +939,8 @@ static struct qemud_server *qemudNetworkInit(struct 
qemud_server *server) {
 if (!mdns_name) {
 char groupname[64], *localhost, *tmp;
 /* Extract the host part of the potentially FQDN */
-localhost = virGetHostname();
+localhost = virGetHostname(NULL);
 if (localhost == NULL) {
-virReportOOMError(NULL);
 goto cleanup;
 }
 if ((tmp = strchr(localhost, '.')))
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index ef97364..73f1c8e 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2058,16 +2058,8 @@ cleanup:
 
 static char *lxcGetHostname (virConnectPtr conn)
 {
-char *result;
-
-result = virGetHostname();
-if (result == NULL) {
-virReportSystemError (conn, errno,
-  %s, _(failed to determine host name));
-return NULL;
-}
 /* Caller frees this string. */
-return result;
+return virGetHostname(conn);
 }
 
 static int lxcFreezeContainer(lxc_driver_t *driver, virDomainObjPtr vm)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a3beedb..86546e5 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2623,16 +2623,8 @@ cleanup:
 static char *
 qemudGetHostname (virConnectPtr conn)
 {
-char *result;
-
-result = virGetHostname();
-if (result == NULL) {
-virReportSystemError (conn, errno,
-  %s, _(failed to determine host name));
-return NULL;
-}
 /* Caller frees this string. */
-return result;
+return virGetHostname(conn);
 }
 
 static int qemudListDomains(virConnectPtr conn, int *ids, int nids) {
@@ -6283,9 +6275,7 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
 if (port == QEMUD_MIGRATION_NUM_PORTS) port = 0;
 
 /* Get hostname */
-if ((hostname = virGetHostname()) == NULL) {
-virReportSystemError (dconn, errno,
-  %s, _(failed to determine host name));
+if ((hostname = virGetHostname(dconn)) == NULL) {
 goto cleanup;
 }
 
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 36f8158..4a081be 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -994,16 +994,8 @@ static int testGetVersion(virConnectPtr conn 
ATTRIBUTE_UNUSED,
 
 static char *testGetHostname (virConnectPtr conn)
 {
-char *result;
-
-result = virGetHostname();
-if (result == NULL) {
-virReportSystemError(conn, errno,
- %s, _(cannot lookup hostname));
-return NULL;
-}
 /* Caller frees this string. */
-return result;
+return virGetHostname(conn);
 }
 
 static int testGetMaxVCPUs(virConnectPtr conn ATTRIBUTE_UNUSED,
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 9a7fe42..cd92a6b 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -1131,16 +1131,8 @@ cleanup:
 static char *
 umlGetHostname (virConnectPtr conn)
 {
-char *result;
-
-result = virGetHostname();
-if (result == NULL) {
-virReportSystemError(conn, errno,
- %s, _(cannot lookup hostname));
-return NULL;
-}
 /* Caller frees this string. */
-return result;
+return virGetHostname(conn);
 }
 
 static int umlListDomains(virConnectPtr conn, int *ids, int nids) {
diff --git a/src/util/util.c b/src/util/util.c
index 98f8a14..49eac6d 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1804,30 +1804,42 @@ int virDiskNameToIndex(const char *name) {
 #define AI_CANONIDN 0
 #endif
 
-char *virGetHostname(void)
+char *virGetHostname(virConnectPtr conn)
 {
 int r;
 char hostname[HOST_NAME_MAX+1], *result;
 struct addrinfo hints, *info;
 
 r = gethostname (hostname, sizeof(hostname));
-if (r == -1)
+if (r == -1) {
+virReportSystemError (conn, errno,
+  %s, _(failed to determine host name));
 return NULL;
+}
 NUL_TERMINATE(hostname);
 
 memset(hints, 0, 

[libvirt] [PATCH] qemu: migrate: Error if we collide with an inactive domain

2009-10-27 Thread Cole Robinson
Currently the check for a VM name/uuid collision on the migrate destination
only errors for active domains. Not sure why this wouldn't apply for non
running VMs as well, so drop the check.

Signed-off-by: Cole Robinson crobi...@redhat.com
---
 src/qemu/qemu_driver.c |   11 ---
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 86546e5..fb952d8 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6341,13 +6341,10 @@ qemudDomainMigratePrepare2 (virConnectPtr dconn,
 
 if (!vm) vm = virDomainFindByName(driver-domains, dname);
 if (vm) {
-if (virDomainIsActive(vm)) {
-qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
-  _(domain with the same name or UUID already 
exists as '%s'),
-  vm-def-name);
-goto cleanup;
-}
-virDomainObjUnlock(vm);
+qemudReportError (dconn, NULL, NULL, VIR_ERR_OPERATION_FAILED,
+  _(domain with the same name or UUID already exists 
as '%s'),
+  vm-def-name);
+goto cleanup;
 }
 
 if (!(vm = virDomainAssignDef(dconn,
-- 
1.6.5.rc2

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


[libvirt] [PATCH] virterror: Add a missing 'break' for VIR_ERR_INVALID_SECRET

2009-10-27 Thread Cole Robinson

Signed-off-by: Cole Robinson crobi...@redhat.com
---
 src/util/virterror.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/util/virterror.c b/src/util/virterror.c
index 657cb3f..10f979c 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -1082,6 +1082,7 @@ virErrorMsg(virErrorNumber error, const char *info)
 errmsg = _(Invalid secret);
 else
 errmsg = _(Invalid secret: %s);
+break;
 case VIR_ERR_NO_SECRET:
 if (info == NULL)
 errmsg = _(Secret not found);
-- 
1.6.5.rc2

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


Re: [libvirt] [PATCH 3/3] test: Support virNodeDeviceCreate and virNodeDeviceDestroy

2009-10-27 Thread Cole Robinson
On 10/17/2009 09:10 AM, Matthias Bolte wrote:
 2009/10/16 Cole Robinson crobi...@redhat.com:

 Signed-off-by: Cole Robinson crobi...@redhat.com
 ---
 Â src/test/test_driver.c | Â 129 
 +++-
 Â 1 files changed, 127 insertions(+), 2 deletions(-)

 diff --git a/src/test/test_driver.c b/src/test/test_driver.c
 index 0541a73..888bc9c 100644
 --- a/src/test/test_driver.c
 +++ b/src/test/test_driver.c
 @@ -4376,6 +4376,131 @@ cleanup:
 Â  Â  return ret;
 Â }

 +static virNodeDevicePtr
 +testNodeDeviceCreateXML(virConnectPtr conn,
 + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â const char *xmlDesc,
 + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â unsigned int flags ATTRIBUTE_UNUSED)
 +{
 + Â  Â testConnPtr driver = conn-privateData;
 + Â  Â virNodeDeviceDefPtr def = NULL;
 + Â  Â virNodeDeviceObjPtr obj = NULL;
 + Â  Â char *wwnn = NULL, *wwpn = NULL;
 + Â  Â int parent_host = -1;
 + Â  Â virNodeDevicePtr dev = NULL;
 + Â  Â virNodeDevCapsDefPtr caps;
 +
 + Â  Â testDriverLock(driver);
 +
 + Â  Â def = virNodeDeviceDefParseString(conn, xmlDesc, CREATE_DEVICE);
 + Â  Â if (def == NULL) {
 + Â  Â  Â  Â goto cleanup;
 + Â  Â }
 +
 + Â  Â /* We run these next two simply for validation */
 + Â  Â if (virNodeDeviceGetWWNs(conn, def, wwnn, wwpn) == -1) {
 + Â  Â  Â  Â goto cleanup;
 + Â  Â }
 +
 + Â  Â if (virNodeDeviceGetParentHost(conn,
 + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  driver-devs,
 + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  def-name,
 + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  def-parent,
 + Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  parent_host) == -1) {
 + Â  Â  Â  Â goto cleanup;
 + Â  Â }
 +
 + Â  Â /* 'name' is supposed to be filled in by the node device backend, 
 which
 + Â  Â  * we don't have. Use WWPN instead. */
 + Â  Â VIR_FREE(def-name);
 + Â  Â if (!(def-name = strdup(wwpn))) {
 + Â  Â  Â  Â virReportOOMError(dev-conn);
 
 dev is NULL here, call virReportOOMError(conn) instead.
 
 + Â  Â  Â  Â goto cleanup;
 + Â  Â }
 +
 + Â  Â /* Fill in a random 'host' value, since this would also come from
 + Â  Â  * the backend */
 + Â  Â caps = def-caps;
 + Â  Â while (caps) {
 + Â  Â  Â  Â if (caps-type != VIR_NODE_DEV_CAP_SCSI_HOST)
 + Â  Â  Â  Â  Â  Â continue;
 +
 + Â  Â  Â  Â caps-data.scsi_host.host = virRandom(1024);
 + Â  Â  Â  Â caps = caps-next;
 + Â  Â }
 +
 +
 + Â  Â if (!(obj = virNodeDeviceAssignDef(conn, driver-devs, def))) {
 + Â  Â  Â  Â goto cleanup;
 + Â  Â }
 + Â  Â virNodeDeviceObjUnlock(obj);
 +
 + Â  Â dev = virGetNodeDevice(conn, def-name);
 + Â  Â def = NULL;
 +cleanup:
 + Â  Â testDriverUnlock(driver);
 + Â  Â if (def)
 + Â  Â  Â  Â virNodeDeviceDefFree(def);
 + Â  Â VIR_FREE(wwnn);
 + Â  Â VIR_FREE(wwpn);
 + Â  Â return dev;
 +}
 +
 
 ACK
 
 Matthias

I've pushed this with the fix you pointed out.

Thanks,
Cole

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


[libvirt] virsh: error: failed to disconnect from the hypervisor in F12/rawhide with Xen

2009-10-27 Thread Pasi Kärkkäinen
Hello,

I have a testbox running current Fedora 12 (rawhide), with custom 2.6.31.4 Xen 
pv_ops dom0 kernel.

[r...@f12test ~]# xm list
NameID   Mem VCPUs  State   Time(s)
Domain-0 0  1020 4 r- 33.8
c54test 1024 1 0.0

[r...@f12test ~]# virsh list
 Id Name State
--
  0 Domain-0 running

virsh: error: failed to disconnect from the hypervisor

[r...@f12test ~]# virsh --connect xen:/// version
Compiled against library: libvir 0.7.1
Using library: libvir 0.7.1
Using API: Xen 3.0.1
Running hypervisor: Xen 3.4.0

virsh: error: failed to disconnect from the hypervisor
*** glibc detected *** virsh: double free or corruption (fasttop): 
0x00936250 ***
=== Backtrace: =
/lib64/libc.so.6[0x3d9ec75dc6]
virsh[0x406d91]
virsh[0x406f29]
virsh[0x406de3]
virsh[0x414582]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x3d9ec1eb4d]
virsh[0x405b59]
=== Memory map: 
snip, memory map removed


[r...@f12test ~]# rpm -qa | grep -i libvirt
libvirt-python-0.7.1-13.fc12.x86_64
libvirt-0.7.1-13.fc12.x86_64
libvirt-client-0.7.1-13.fc12.x86_64

[r...@f12test ~]# rpm -qa | grep -i xen
kernel-2.6.31.4-1.2.73.xendom0.fc12.x86_64
xen-3.4.1-5.fc12.x86_64
xen-runtime-3.4.1-5.fc12.x86_64
kernel-devel-2.6.31.4-1.2.73.xendom0.fc12.x86_64
xen-libs-3.4.1-5.fc12.x86_64
xen-hypervisor-3.4.1-5.fc12.x86_64


Any ideas?

-- Pasi

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


Re: [libvirt] virsh: error: failed to disconnect from the hypervisor in F12/rawhide with Xen

2009-10-27 Thread Pasi Kärkkäinen
On Tue, Oct 27, 2009 at 10:04:45AM -0600, Jim Fehlig wrote:
 Pasi Kärkkäinen wrote:
  Hello,
 
  I have a testbox running current Fedora 12 (rawhide), with custom 2.6.31.4 
  Xen pv_ops dom0 kernel.
 
  [r...@f12test ~]# xm list
  NameID   Mem VCPUs  State   
  Time(s)
  Domain-0 0  1020 4 r- 
  33.8
  c54test 1024 1 
  0.0
 
  [r...@f12test ~]# virsh list
   Id Name State
  --
0 Domain-0 running
 
  virsh: error: failed to disconnect from the hypervisor
 
  [r...@f12test ~]# virsh --connect xen:/// version
  Compiled against library: libvir 0.7.1
  Using library: libvir 0.7.1
  Using API: Xen 3.0.1
  Running hypervisor: Xen 3.4.0
 
  virsh: error: failed to disconnect from the hypervisor
  *** glibc detected *** virsh: double free or corruption (fasttop): 
  0x00936250 ***

 
 The failed to disconnect from the hypervisor and double free issues
 have been fixed in 0.7.2.
 

Ok, thanks!

Hopefully 0.7.2 will hit F12/rawhide soon..

-- Pasi

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


Re: [libvirt] virsh: error: failed to disconnect from the hypervisor in F12/rawhide with Xen

2009-10-27 Thread Jim Fehlig
Pasi Kärkkäinen wrote:
 Hello,

 I have a testbox running current Fedora 12 (rawhide), with custom 2.6.31.4 
 Xen pv_ops dom0 kernel.

 [r...@f12test ~]# xm list
 NameID   Mem VCPUs  State   
 Time(s)
 Domain-0 0  1020 4 r- 33.8
 c54test 1024 1 0.0

 [r...@f12test ~]# virsh list
  Id Name State
 --
   0 Domain-0 running

 virsh: error: failed to disconnect from the hypervisor

 [r...@f12test ~]# virsh --connect xen:/// version
 Compiled against library: libvir 0.7.1
 Using library: libvir 0.7.1
 Using API: Xen 3.0.1
 Running hypervisor: Xen 3.4.0

 virsh: error: failed to disconnect from the hypervisor
 *** glibc detected *** virsh: double free or corruption (fasttop): 
 0x00936250 ***
   

The failed to disconnect from the hypervisor and double free issues
have been fixed in 0.7.2.

Regards,
Jim

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


Re: [libvirt] Trouble starting a QEMU guest with IPv6 VNC address

2009-10-27 Thread Kaitlin Rupert
It looks like specifying an address of [::1] instead of ::1 will work. 
However, that seems like a bug.  The bracket syntax is specific to qemu, 
which means the user needs to have prior knowledge of this.


Kaitlin Rupert wrote:

Hello,

I am trying to start a QEMU guest with an IPv6 VNC address.  I can 
specify the address and start the guest, but the VNC port shows up under 
the IPv4 list:


# virsh dumpxml domU1 | grep graphics
graphics type='vnc' port='5900' autoport='no' listen='::1' 
keymap='en-us'/


# cat /proc/net/tcp | grep 170C
   2: :170C : 0A : 00: 
 00 621103 1 88007a043a80 299 0 0 2 -1


# cat /proc/net/tcp6 | grep 170C
#

# ps -ef | grep qemu
root 16451 1 43 04:17 ?00:00:18 
/usr/bin/qemu-system-x86_64 -S -M pc -m 128 -smp 1 -name domU1 -uuid 
2aebe290-d1ed-11dd-90eb-001a64bc024c -monitor pty -pidfile 
/var/run/libvirt/qemu//domU1.pid -no-acpi -boot c -drive 
file=/tmp/default-kvm-dimage,if=ide,index=0,boot=on -net 
nic,macaddr=11:22:33:aa:bb:cc,vlan=0 -net tap,fd=17,vlan=0 -serial none 
-parallel none -usb -vnc ::1:0 -k en-us


I started the same guest manually, but I appended an ,ipv6' flag to the 
vnc option (see below).  With this change, the port shows up in the IPv6 
list.


# /usr/bin/qemu-system-x86_64 -M pc -m 128 -smp 1 -name domU1 -uuid 
2aebe290-d1ed-11dd-90eb-001a64bc024c -monitor pty -pidfile 
/var/run/libvirt/qemu//domU1.pid -no-acpi -boot c -drive 
file=/tmp/default-kvm-dimage,if=ide,index=0,boot=on -net 
nic,macaddr=11:22:33:aa:bb:cc,vlan=0 -net tap,fd=17,vlan=0 -serial none 
-parallel none -usb -vnc ::1:0,ipv6 -k en-us


# cat /proc/net/tcp6 | grep 170C
   2: :170C 
: 0A : 00: 
 00 621485 1 88007a30ad00 299 0 0 2 -1


# cat /proc/net/tcp | grep 170C
#

I'd like to fix the qemu driver so that it specifies this flag, but I am 
unsure whether a guest XML change or some other change is appropriate 
here.  Would it be better to have the qemu driver code do some detection 
on the address that is passed in?


Thanks!



--
Kaitlin Rupert
IBM Linux Technology Center
kait...@linux.vnet.ibm.com

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


Re: [libvirt] [PATCH] Avoid segv if ncf_init fails

2009-10-27 Thread Laine Stump

On 10/27/2009 10:28 AM, David Lutterkort wrote:

On Tue, 2009-10-27 at 14:23 +, David Lutterkort wrote:
   

On Fri, 2009-10-23 at 20:31 +0100, Daniel P. Berrange wrote:
 

On Fri, Oct 23, 2009 at 03:13:17PM -0400, Laine Stump wrote:
   

If ncf_init() fails, it takes responsibility to call ncf_close() when
appropriate. Having libvirt call it results in a double close, which
ends up segv'ing.
 

Hmm, it would be good if ncf_init  set the passed in pointer to NULL
when it failed, then your existing cleanup check would have been
safe.
   

Agreed - that that doesn't happen was an oversight. I'll fix that.
 

Spoke too soon - ncf_init returns -2 when allocations fail so badly that
we can't even allocate the struct netcf (in which case ncf_init should
reset the pointer to NULL, but doesn't - that's the bug that needs to be
addressed)

It can also return -1 for all kinds of other failures; in that case you
have a struct netcf that's good enough to pass to ncf_error to get more
error details.
   



Hmm. I guess I should setup my error scenario again and see if it was 
returning -2 - it was pretty simple to reproduce, I would just run 
libvirtd as non-root and connect to it with virsh.


If it was returning -2. I'll send a new patch for libvirt that, if the 
return is -1, retrieves the extra error stuff and reports it, then does 
ncf_close().

David



   


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


Re: [libvirt] Trouble starting a QEMU guest with IPv6 VNC address

2009-10-27 Thread Laine Stump

On 10/27/2009 01:47 PM, Kaitlin Rupert wrote:
It looks like specifying an address of [::1] instead of ::1 will work. 
However, that seems like a bug.  The bracket syntax is specific to 
qemu, which means the user needs to have prior knowledge of this.


Not exactly specific to qemu. Many other protocols use it (eg SIP, 
pretty much any URL - see section 3.2.2 of RFC3986). Basically, anywhere 
the IP address might have a port tacked onto it with :n syntax *needs* 
to have the brackets and, due to this precedent, many other places 
accept it anyway.


My opinion would be that in cases where the port may be specified 
URL-style as part of the address (I haven't looked to see if that's the 
case here), then the brackets should be required; if port cannot be 
specified using :n syntax, then brackets should NOT be required, but 
should be accepted.


(In practice, I found that having some places where brackets were 
required and some where it wasn't necessitated lots of extra code and 
was just a nuisance all around (even worse to have places where brackets 
weren't even accepted).





Kaitlin Rupert wrote:

Hello,

I am trying to start a QEMU guest with an IPv6 VNC address.  I can 
specify the address and start the guest, but the VNC port shows up 
under the IPv4 list:


# virsh dumpxml domU1 | grep graphics
graphics type='vnc' port='5900' autoport='no' listen='::1' 
keymap='en-us'/


# cat /proc/net/tcp | grep 170C
   2: :170C : 0A : 00: 
 00 621103 1 88007a043a80 299 0 0 2 -1


# cat /proc/net/tcp6 | grep 170C
#

# ps -ef | grep qemu
root 16451 1 43 04:17 ?00:00:18 
/usr/bin/qemu-system-x86_64 -S -M pc -m 128 -smp 1 -name domU1 -uuid 
2aebe290-d1ed-11dd-90eb-001a64bc024c -monitor pty -pidfile 
/var/run/libvirt/qemu//domU1.pid -no-acpi -boot c -drive 
file=/tmp/default-kvm-dimage,if=ide,index=0,boot=on -net 
nic,macaddr=11:22:33:aa:bb:cc,vlan=0 -net tap,fd=17,vlan=0 -serial 
none -parallel none -usb -vnc ::1:0 -k en-us


I started the same guest manually, but I appended an ,ipv6' flag to 
the vnc option (see below).  With this change, the port shows up in 
the IPv6 list.


# /usr/bin/qemu-system-x86_64 -M pc -m 128 -smp 1 -name domU1 -uuid 
2aebe290-d1ed-11dd-90eb-001a64bc024c -monitor pty -pidfile 
/var/run/libvirt/qemu//domU1.pid -no-acpi -boot c -drive 
file=/tmp/default-kvm-dimage,if=ide,index=0,boot=on -net 
nic,macaddr=11:22:33:aa:bb:cc,vlan=0 -net tap,fd=17,vlan=0 -serial 
none -parallel none -usb -vnc ::1:0,ipv6 -k en-us


# cat /proc/net/tcp6 | grep 170C
   2: :170C 
: 0A : 
00:  00 621485 1 88007a30ad00 299 0 0 
2 -1


# cat /proc/net/tcp | grep 170C
#

I'd like to fix the qemu driver so that it specifies this flag, but I 
am unsure whether a guest XML change or some other change is 
appropriate here.  Would it be better to have the qemu driver code do 
some detection on the address that is passed in?


Thanks!





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