Re: [Libvir] API confusion...

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 03:47:05PM -0600, Spencer Parker wrote:
> Since I am kind of an idiot and don't know what I am doing...I am having
> trouble with getting network stats to work in Python.  I have everything
> correct...but I am just not sure exactly what it is looking for.  I get this
> error:
> 
> libvir: Xen error : invalid argument in xenHypervisorDomainInterfaceStats:
> invalid path, should be vif..
> 
> I guess I just need some kind of example to work from on this.

As described in the error message, try setting the path to something
like "vif1.0" where 1 is the domain ID and 0 is the interface number.
You can enumerate interfaces available by dumping the domain XML.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Jim Paris
Henri Cook wrote:
> Hi guys,
> 
> I just tried to port a few customers over to this libvirt setup i'm
> hoping to run and I couldn't get their machines started because there's
> no mechanism to specify a model in the XML!
> 
> I know redhat have changed KVM's default driver to e1000, which I think
> is the one I like the most and almost if not all of my VMs use. Ubuntu
> haven't done that yet however!
> 
> Is there a model directive in the latest version? In the works? Just so
> I know which solution I should pursue (updating libvirt or harassing
> ubuntu to change the default)

Hi,

I posted a series of patches to do this last year:
  http://www.mail-archive.com/libvir-list@redhat.com/msg03554.html
It generated some discussion but AFAIK didn't go anywhere.

Henri, if you want a quick hack to add specific options to kvm, you
can just specify a script as the KVM binary and have it add or modify
arguments as you wish.  For example, I used:

  #!/bin/bash
  i=0
  ARGV=("$@")
  while [ $i -lt $# ] ; do
  # Use rtl8139 network card instead of default ne2k_pci
  ARGV[$i]=${ARGV[$i]/#nic/nic,model=rtl8139}
  i=$((i+1))
  done
  exec /usr/bin/kvm [EMAIL PROTECTED]


-jim

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


[Libvir] [PATCH 2/2] lxc: Shutdown and destroy container

2008-04-08 Thread Dave Leskovec
This is a repost of the shutdown and destroy container support.  Changes in this
version:

* Moved state changes to after the signal is successfully sent rather than
restoring if it failed.
* Signal handling in lxc_container goes away since the tty forwarding process is
no longer the container root process.
* Since the tty forwarding process is now outside the container, we have to kill
and wait for it in the destroy.

Thanks!

-- 
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization
---
 src/lxc_container.c |   21 +++
 src/lxc_driver.c|   94 ++--
 2 files changed, 112 insertions(+), 3 deletions(-)

Index: b/src/lxc_container.c
===
--- a/src/lxc_container.c	2008-04-04 16:19:02.0 -0700
+++ b/src/lxc_container.c	2008-04-04 17:10:04.0 -0700
@@ -235,6 +235,16 @@
 }
 #endif
 
+#if 0
+static void lxcExecSigintHandler(int sig ATTRIBUTE_UNUSED,
+ siginfo_t *signalInfo,
+ void *context ATTRIBUTE_UNUSED)
+{
+DEBUG("container received SIGINT from %d", signalInfo->si_pid);
+kill(SIGINT, initPid);
+}
+#endif
+
 static int lxcExecWithTty(lxc_vm_t *vm)
 {
 int rc = -1;
@@ -255,7 +265,16 @@
 sigAction.sa_mask = sigMask;
 sigAction.sa_flags = SA_SIGINFO;
 if (0 != sigaction(SIGCHLD, &sigAction, NULL)) {
-DEBUG("sigaction failed: %s\n", strerror(errno));
+DEBUG("sigaction failed for SIGCHLD: %s\n", strerror(errno));
+goto exit_with_error;
+}
+
+sigAction.sa_sigaction = lxcExecSigintHandler;
+sigfillset(&sigMask);
+sigAction.sa_mask = sigMask;
+sigAction.sa_flags = SA_SIGINFO;
+if (0 != sigaction(SIGINT, &sigAction, NULL)) {
+DEBUG("sigaction failed for SIGINT: %s\n", strerror(errno));
 goto exit_with_error;
 }
 
Index: b/src/lxc_driver.c
===
--- a/src/lxc_driver.c	2008-04-04 16:50:35.0 -0700
+++ b/src/lxc_driver.c	2008-04-04 17:18:46.0 -0700
@@ -710,6 +710,96 @@
 return dom;
 }
 
+/**
+ * lxcDomainShutdown:
+ * @dom: Ptr to domain to shutdown
+ *
+ * Sends SIGINT to container root process to request it to shutdown
+ *
+ * Returns 0 on success or -1 in case of error
+ */
+static int lxcDomainShutdown(virDomainPtr dom)
+{
+int rc = -1;
+lxc_driver_t *driver = (lxc_driver_t*)dom->conn->privateData;
+lxc_vm_t *vm = lxcFindVMByID(driver, dom->id);
+
+if (!vm) {
+lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with id %d"), dom->id);
+goto error_out;
+}
+
+if (0 > (kill(vm->def->id, SIGINT))) {
+if (ESRCH != errno) {
+lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
+ _("sending SIGTERM failed: %s"), strerror(errno));
+
+goto error_out;
+}
+}
+
+vm->state = VIR_DOMAIN_SHUTDOWN;
+
+rc = 0;
+
+error_out:
+return rc;
+}
+
+/**
+ * lxcDomainDestroy:
+ * @dom: Ptr to domain to destroy
+ *
+ * Sends SIGKILL to container root process to terminate the container
+ *
+ * Returns 0 on success or -1 in case of error
+ */
+static int lxcDomainDestroy(virDomainPtr dom)
+{
+int rc = -1;
+lxc_driver_t *driver = (lxc_driver_t*)dom->conn->privateData;
+lxc_vm_t *vm = lxcFindVMByID(driver, dom->id);
+int childStatus;
+
+if (!vm) {
+lxcError(dom->conn, dom, VIR_ERR_INVALID_DOMAIN,
+ _("no domain with id %d"), dom->id);
+goto error_out;
+}
+
+if (0 > (kill(vm->def->id, SIGKILL))) {
+if (ESRCH != errno) {
+lxcError(dom->conn, dom, VIR_ERR_INTERNAL_ERROR,
+ _("sending SIGKILL failed: %s"), strerror(errno));
+
+goto error_out;
+}
+}
+
+vm->state = VIR_DOMAIN_SHUTDOWN;
+
+waitpid(vm->def->id, &childStatus, 0);
+rc = WEXITSTATUS(childStatus);
+DEBUG("container exited with rc: %d", rc);
+
+/* also need to kill tty forward process */
+/* wrap this with error handling etc.  in the right place? */
+/* also wait for the process */
+kill(vm->pid, SIGKILL);
+
+vm->state = VIR_DOMAIN_SHUTOFF;
+vm->pid = -1;
+vm->def->id = -1;
+driver->nactivevms--;
+driver->ninactivevms++;
+
+rc = 0;
+
+error_out:
+return rc;
+}
+
 static int lxcStartup(void)
 {
 uid_t uid = getuid();
@@ -811,9 +901,9 @@
 lxcDomainLookupByName, /* domainLookupByName */
 NULL, /* domainSuspend */
 NULL, /* domainResume */
-NULL, /* domainShutdown */
+lxcDomainShutdown, /* domainShutdown */
 NULL, /* domainReboot */
-NULL, /* domainDestroy */
+lxcDomainDestroy, /* domainDestroy */
 lxcGetOSType, /* domainGetOSType */
 NULL, /* domainGetMaxMemory */
 NULL, /* domainSetMaxMemory */
--
Libvir-list mailing list
Libvir-list@redhat.com

[Libvir] [PATCH 1/2] lxc: start container

2008-04-08 Thread Dave Leskovec
This is a repost of the start container support.  Changes from the last version:

* Report an error when allocation for init string fails in 
lxcExecContainerInit()
* Change to find by name in lxcStartDomain()
* Move tty forwarding process outside of the container.  This allows
consolidating the forwarding into a single process at a later time.  This also
means the the container init process as specified by the user now runs as the
container root process with pid = 1.  The tty setup will require some (hopefully
minor) modifications when pts namespaces are enabled.
* Add header comments to a number of the functions.

This is an updated rough outline of the functions involved in starting a
container and the namespace and process under which they run:
lxcVmStart() - runs under libvirtd process
lxcSetupTtyTunnel() - opens and configures parent tty
lxcSetupContainerTty() - opens container tty
fork
child process calls lxcTtyForward() see below
parent continues
lxcStartContainer - see below
return

lxcStartContainer() - runs in parent namespace, libvirtd process
Allocate stack for container
clone() - child process will start in lxcChild() see below
return

lxcChild() - runs within container, child process from clone()
mount user filesystems
mount container /proc
lxcExecWithTty() - see below, will not return

lxcExecWithTty() - runs within container, root process
lxcSetContainerStdio - sets container tty as primary console
lxcExecContainerInit - see below, should not return
exit()

lxcExecContainerInit() - runs within container, root process
exec containers init
if exec fails, exit()

Thanks!

-- 
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization

---
 src/Makefile.am |1 
 src/lxc_conf.h  |2 
 src/lxc_container.c |  345 
 src/lxc_container.h |   44 ++
 src/lxc_driver.c|  340 ++-
 5 files changed, 730 insertions(+), 2 deletions(-)

Index: b/src/Makefile.am
===
--- a/src/Makefile.am	2008-03-31 15:12:01.0 -0700
+++ b/src/Makefile.am	2008-03-31 15:15:56.0 -0700
@@ -61,6 +61,7 @@
 		openvz_driver.c openvz_driver.h			\
 		lxc_driver.c lxc_driver.h			\
 		lxc_conf.c lxc_conf.h\
+		lxc_container.c lxc_container.h\
 nodeinfo.h nodeinfo.c   \
 		storage_conf.h storage_conf.c			\
 		storage_driver.h storage_driver.c		\
Index: b/src/lxc_container.h
===
--- /dev/null	1970-01-01 00:00:00.0 +
+++ b/src/lxc_container.h	2008-03-31 15:15:56.0 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright IBM Corp. 2008
+ *
+ * lxc_container.h: header file for fcns run inside container
+ *
+ * Authors:
+ *  David L. Leskovec 
+ *
+ * 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
+ */
+
+#ifndef LXC_CONTAINER_H
+#define LXC_CONTAINER_H
+
+#ifdef WITH_LXC
+
+/* Function declarations */
+int lxcChild( void *argv );
+
+#endif /* LXC_DRIVER_H */
+
+#endif /* LXC_CONTAINER_H */
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
+
Index: b/src/lxc_driver.c
===
--- a/src/lxc_driver.c	2008-03-31 15:12:01.0 -0700
+++ b/src/lxc_driver.c	2008-04-04 16:50:35.0 -0700
@@ -25,17 +25,22 @@
 
 #ifdef WITH_LXC
 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
 #include "lxc_conf.h"
+#include "lxc_container.h"
 #include "lxc_driver.h"
 #include "driver.h"
 #include "internal.h"
+#include "util.h"
 
 /* debug macros */
 #define DEBUG(fmt,...) VIR_DEBUG(__FILE__, fmt, __VA_ARGS__)
@@ -375,11 +380,342 @@
 return lxcGenerateXML(dom->conn, driver, vm, vm->def);
 }
 
+static int lxcStartContainer(virConnectPtr conn,
+ lxc_driver_t* driver,
+ lxc_vm_t *vm)
+{
+int rc = -1;
+int flags;
+int stacksize = getpagesize() * 4;
+void *stack, *stacktop;
+
+/* allocate a stack for the 

[Libvir] [PATCH 0/2] Start, shutdown and destroy linux containers

2008-04-08 Thread Dave Leskovec
Reposting the patches to start, shutdown and destroy containers with updates for
feedback received so far.

Thanks!

-- 
Best Regards,
Dave Leskovec
IBM Linux Technology Center
Open Virtualization

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


Re: [Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Jim Meyering
"Richard W.M. Jones" <[EMAIL PROTECTED]> wrote:
> On Tue, Apr 08, 2008 at 05:12:28PM +0200, Jim Meyering wrote:
>> And if someone does e.g. virsh define DIR_NAME
>> on a system that lets you read directories, they
>> won't be too surprised that the contents of the
>> directory is invalid XML.
>>
>> Here's the updated patch:
>
> Patch looks good.
>
> What are these systems that let you read directories?

Plenty.  It used to work on Linux, but no longer does.
I've just confirmed that "cat /" succeeds (but prints nothing useful)
on Solaris 10, freebsd 6.1, openbsd 3.9, and netbsd 1.6.

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


[Libvir] API confusion...

2008-04-08 Thread Spencer Parker
Since I am kind of an idiot and don't know what I am doing...I am having
trouble with getting network stats to work in Python.  I have everything
correct...but I am just not sure exactly what it is looking for.  I get this
error:

libvir: Xen error : invalid argument in xenHypervisorDomainInterfaceStats:
invalid path, should be vif..

I guess I just need some kind of example to work from on this.

-- 
Spencer Parker
___

"if you can't go to heaven, may you at least die in Ireland."

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


Re: [Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 05:12:28PM +0200, Jim Meyering wrote:
> And if someone does e.g. virsh define DIR_NAME
> on a system that lets you read directories, they
> won't be too surprised that the contents of the
> directory is invalid XML.
> 
> Here's the updated patch:

Patch looks good.

What are these systems that let you read directories?

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

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


[Libvir] [PATCH] Have xenDaemonDetachDevice() remove device configuration

2008-04-08 Thread Ryan Scott


When a user runs 'virsh detach-disk' on a running domain, the disk is 
removed, but reappears after the domain is rebooted.  This seems odd, as 
someone who types detach-disk most likely wants the change to be permanent.


This patch updates the code in xenDaemonDetachDevice() to pass the 
rm_cfg flag to Xen, so that the change is committed to the domain's 
configuration file.


This change depends on a xen patch that was committed to unstable on 
March 20: 
http://lists.xensource.com/archives/html/xen-changelog/2008-03/msg00122.html


-Ryan

diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -3347,7 +3347,7 @@ xenDaemonDetachDevice(virDomainPtr domai
 if (virDomainXMLDevID(domain, xml, class, ref, sizeof(ref)))
 return (-1);
 return(xend_op(domain->conn, domain->name, "op", "device_destroy",
-"type", class, "dev", ref, NULL));
+"type", class, "dev", ref, "force", "0", "rm_cfg", "1", NULL));
 }

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


[Libvir] [PATCH] (for discussion only) KVM migration v1

2008-04-08 Thread Richard W.M. Jones
This patch implements KVM to KVM migration.  It is for discussion
only, partly because it doesn't work for some reason I can't quite
work out at the moment.

We implement a second version of the migration protocol.  This second
version has two differences:

(1) Prepare step is replaced by Prepare2, which passes the domain XML.
As explained previously this is required for KVM because we use this
on the target host to recreate the precise qemu-kvm command line as on
the source host.

(2) Finish step is replaced by Finish2.  There are two differences
here: firstly Finish2 is always called on the destination host, even
if the migration failed.  Secondly the return code from the migration
(Perform step) is passed to Finish2.  This is required for KVM
migration because if the migration failed we need to tear down the
empty qemu shell, otherwise failed migrations could leave effectively
zombie qemu processes around.

libvirt.c:virDomainMigrate function has been changed so that it can
support either form of migration protocol, and the Xen driver
continues to use version 1.  The changes here are pretty minor, and
there are no changes to the Xen driver.

The additional code involves implementing Prepare2 / Finish2 in the
remote protocol, and of course implementing migration in the qemu
driver itself.

A final word about the parameters to virDomainMigrate.

 - flags is ignored.  All KVM migrations are "live", it doesn't matter
   if you supply the live flag or not.

 - desturi may optionally be used to control the TCP port used for
   migration.  If desturi is NULL then a TCP port is chosen at
   random (or in future, some suitable secure method will be used
   instead).  If desturi is set to "tcp://hostname:port" then the
   given port number is used, and hostname is expected to be the
   hostname or IP address of the target server.

You cannot do localhost->localhost migrations (even though this is
supported by KVM) because libvirtd doesn't like you creating two VMs
with the same UUID, even if only temporarily.  So to test this you
really need two machines, or at least two instances of libvirtd
configured not to stomp on each other.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
Index: qemud/remote.c
===
RCS file: /data/cvs/libvirt/qemud/remote.c,v
retrieving revision 1.28
diff -u -r1.28 remote.c
--- qemud/remote.c  4 Apr 2008 15:09:19 -   1.28
+++ qemud/remote.c  8 Apr 2008 18:43:58 -
@@ -1285,6 +1285,66 @@
 }
 
 static int
+remoteDispatchDomainMigratePrepare2 (struct qemud_server *server 
ATTRIBUTE_UNUSED,
+ struct qemud_client *client,
+ remote_message_header *req,
+ remote_domain_migrate_prepare2_args *args,
+ remote_domain_migrate_prepare2_ret *ret)
+{
+int r;
+char *cookie = NULL;
+int cookielen = 0;
+char *uri_in;
+char **uri_out;
+char *dname;
+CHECK_CONN (client);
+
+uri_in = args->uri_in == NULL ? NULL : *args->uri_in;
+dname = args->dname == NULL ? NULL : *args->dname;
+
+/* Wacky world of XDR ... */
+uri_out = calloc (1, sizeof (*uri_out));
+
+r = __virDomainMigratePrepare2 (client->conn, &cookie, &cookielen,
+uri_in, uri_out,
+args->flags, dname, args->resource,
+args->dom_xml);
+if (r == -1) return -1;
+
+/* remoteDispatchClientRequest will free cookie, uri_out and
+ * the string if there is one.
+ */
+ret->cookie.cookie_len = cookielen;
+ret->cookie.cookie_val = cookie;
+ret->uri_out = *uri_out == NULL ? NULL : uri_out;
+
+return 0;
+}
+
+static int
+remoteDispatchDomainMigrateFinish2 (struct qemud_server *server 
ATTRIBUTE_UNUSED,
+struct qemud_client *client,
+remote_message_header *req,
+remote_domain_migrate_finish2_args *args,
+remote_domain_migrate_finish2_ret *ret)
+{
+virDomainPtr ddom;
+CHECK_CONN (client);
+
+ddom = __virDomainMigrateFinish2 (client->conn, args->dname,
+  args->cookie.cookie_val,
+  args->cookie.cookie_len,
+  args->uri,
+  args->flags,
+  args->retcode);
+if (ddom == NULL) return -1;
+
+make_nonnull_domain (&ret->ddom, ddom);
+
+return 0;
+}
+
+static int
 remoteDispatchListDefinedDomains (struct qemud_server *server 

[Libvir] FYI: configure.in (ALL_LINGUAS): Fix typo: s/Latn/latin/

2008-04-08 Thread Jim Meyering
FYI, I committed this:

 Mon Apr  8 17:32:07 CET 2008 Jim Meyering <[EMAIL PROTECTED]>

+   * configure.in (ALL_LINGUAS): Fix typo: s/Latn/latin/.
+
Don't fail to read a file because it's non-seekable (e.g., a pipe).
* src/util.c (fread_file_lim): New function.
(__virFileReadAll): Use fread_file_lim, rather than requiring
diff --git a/configure.in b/configure.in
index cc41185..bd6b744 100644
--- a/configure.in
+++ b/configure.in
@@ -888,7 +888,7 @@ if test -d po
 then
 ALL_LINGUAS=`(cd po > /dev/null && ls *.po) | sed 's+\.po$++'`
 else
-ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et 
eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr 
ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq [EMAIL PROTECTED] sr 
sv ta te th tr uk ur vi zh_CN zh_TW zu"
+ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et 
eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr 
ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq [EMAIL PROTECTED] sr 
sv ta te th tr uk ur vi zh_CN zh_TW zu"
 fi

 dnl Extra link-time flags for Cygwin.
--
1.5.5.rc3.14.g78bf3

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


Re: [Libvir] Zombie KVMs?

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 05:51:46PM +0100, Henri Cook wrote:
> Does anyone ever see:
> 
> root 18628  3.2  0.0  0 0 ?Z17:30   0:40  \_
> [kvm] 
> 
> Zombie copies of KVM under libvirtd? They're unkillable (without
> restarting libvirtd) - although libvirt all still functions as normal

I think I have seen this happen once or twice.  If you find a method
to reproduce it reliably, definitely file a bug.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


[Libvir] Zombie KVMs?

2008-04-08 Thread Henri Cook
Hey all,

Does anyone ever see:

root 18628  3.2  0.0  0 0 ?Z17:30   0:40  \_
[kvm] 

Zombie copies of KVM under libvirtd? They're unkillable (without
restarting libvirtd) - although libvirt all still functions as normal

Henri

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


Re: [Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Daniel P. Berrange
On Tue, Apr 08, 2008 at 04:04:53PM +0100, Richard W.M. Jones wrote:
> On Tue, Apr 08, 2008 at 05:00:03PM +0200, Jim Meyering wrote:
> > This fix addresses a problem exposed in an ovirt script whereby
> > trying to use bash process substitution, e.g., in
> > virsh define <(command to generate xml)
> > would fail.
> > 
> > Oops.  Just noticed that the indentation in the added function
> > (gnulib style) is not consistent with the rest of the file.
> > I'll adjust that before committing, of course.
> > 
> > Don't fail to read a file because it's non-seekable (e.g., a pipe).
> > * src/util.c (fread_file_lim): New function.
> > (__virFileReadAll): Use fread_file_lim, rather than requiring
> > that stat.st_size provide a usable file size.
> > * tests/read-non-seekable: New test, for the above.
> > * tests/Makefile.am (test_scripts): Add read-non-seekable.
> > * tests/test-lib.sh (mkfifo_or_skip_): New helper function.
> 
> This fix looks good.  In fact I'd go further and remove the test for
> S_ISDIR(st.st_mode) and the stat buffer altogether.

Yep I agree - patch looks good aside from that.

Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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


Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Daniel P. Berrange
On Tue, Apr 08, 2008 at 03:16:08PM +0100, Richard W.M. Jones wrote:
> On Tue, Apr 08, 2008 at 02:57:15PM +0100, Daniel P. Berrange wrote:
> > This patch seems incomplete - there's no code to include the  tag
> > when dumping the XML.
> 
> Yeah, agreed - forgot about that :-(

Oh, you may also find you need to tweak the test suite too, since that
validates the args for QEMU and don't currently include the model=

> > We should also implement the same for Xen driver really, since that has the
> > choice of ne2k/rtl8139/e1000 too
> 
> I'll have a look.

No need to delay the commit of the KVM impl though of course.

Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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


Re: [Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Jim Meyering
"Richard W.M. Jones" <[EMAIL PROTECTED]> wrote:

> On Tue, Apr 08, 2008 at 05:00:03PM +0200, Jim Meyering wrote:
>> This fix addresses a problem exposed in an ovirt script whereby
>> trying to use bash process substitution, e.g., in
>> virsh define <(command to generate xml)
>> would fail.
>>
>> Oops.  Just noticed that the indentation in the added function
>> (gnulib style) is not consistent with the rest of the file.
>> I'll adjust that before committing, of course.
>>
>>  Don't fail to read a file because it's non-seekable (e.g., a pipe).
>>  * src/util.c (fread_file_lim): New function.
>>  (__virFileReadAll): Use fread_file_lim, rather than requiring
>>  that stat.st_size provide a usable file size.
>>  * tests/read-non-seekable: New test, for the above.
>>  * tests/Makefile.am (test_scripts): Add read-non-seekable.
>>  * tests/test-lib.sh (mkfifo_or_skip_): New helper function.
>
> This fix looks good.  In fact I'd go further and remove the test for
> S_ISDIR(st.st_mode) and the stat buffer altogether.

Thanks for the quick feedback.
Yeah, that's probably cleaner.

And if someone does e.g. virsh define DIR_NAME
on a system that lets you read directories, they
won't be too surprised that the contents of the
directory is invalid XML.

Here's the updated patch:

Don't fail to read a file because it's non-seekable (e.g., a pipe).
* src/util.c (fread_file_lim): New function.
(__virFileReadAll): Use fread_file_lim, rather than requiring
that stat.st_size provide a usable file size.
* tests/read-non-seekable: New test, for the above.
* tests/Makefile.am (test_scripts): Add read-non-seekable.
* tests/test-lib.sh (mkfifo_or_skip_): New helper function.

Signed-off-by: Jim Meyering <[EMAIL PROTECTED]>
---
 src/util.c  |   99 +++---
 tests/Makefile.am   |1 +
 tests/read-non-seekable |   47 ++
 tests/test-lib.sh   |   12 ++
 4 files changed, 127 insertions(+), 32 deletions(-)
 create mode 100755 tests/read-non-seekable

diff --git a/src/util.c b/src/util.c
index 0667780..801f615 100644
--- a/src/util.c
+++ b/src/util.c
@@ -49,6 +49,10 @@

 #include "util-lib.c"

+#ifndef MIN
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
 #define MAX_ERROR_LEN   1024

 #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
@@ -283,14 +287,64 @@ virExecNonBlock(virConnectPtr conn,

 #endif /* __MINGW32__ */

+/* Like gnulib's fread_file, but read no more than the specified maximum
+   number of bytes.  If the length of the input is <= max_len, and
+   upon error while reading that data, it works just like fread_file.  */
+static char *
+fread_file_lim (FILE *stream, size_t max_len, size_t *length)
+{
+char *buf = NULL;
+size_t alloc = 0;
+size_t size = 0;
+int save_errno;
+
+for (;;) {
+size_t count;
+size_t requested;
+
+if (size + BUFSIZ + 1 > alloc) {
+char *new_buf;
+
+alloc += alloc / 2;
+if (alloc < size + BUFSIZ + 1)
+alloc = size + BUFSIZ + 1;
+
+new_buf = realloc (buf, alloc);
+if (!new_buf) {
+save_errno = errno;
+break;
+}
+
+buf = new_buf;
+}
+
+/* Ensure that (size + requested <= max_len); */
+requested = MIN (size < max_len ? max_len - size : 0,
+ alloc - size - 1);
+count = fread (buf + size, 1, requested, stream);
+size += count;
+
+if (count != requested || requested == 0) {
+save_errno = errno;
+if (ferror (stream))
+break;
+buf[size] = '\0';
+*length = size;
+return buf;
+}
+}
+
+free (buf);
+errno = save_errno;
+return NULL;
+}

-int __virFileReadAll(const char *path,
- int maxlen,
- char **buf)
+int __virFileReadAll(const char *path, int maxlen, char **buf)
 {
 FILE *fh;
-struct stat st;
 int ret = -1;
+size_t len;
+char *s;

 if (!(fh = fopen(path, "r"))) {
 virLog("Failed to open file '%s': %s",
@@ -298,39 +352,21 @@ int __virFileReadAll(const char *path,
 goto error;
 }

-if (fstat(fileno(fh), &st) < 0) {
-virLog("Failed to stat file '%s': %s",
-   path, strerror(errno));
+s = fread_file_lim(fh, maxlen+1, &len);
+if (s == NULL) {
+virLog("Failed to read '%s': %s", path, strerror (errno));
 goto error;
 }

-if (S_ISDIR(st.st_mode)) {
-virLog("Ignoring directory '%s'", path);
+if (len > maxlen || (int)len != len) {
+free(s);
+virLog("File '%s' is too large %d, max %d",
+   path, (int)len, maxlen);
 goto error;
 }

-if (st.st_size > maxlen) {
-virLog("File '%s' is too large %d, max %d", path, (int)st.st_size, 
maxlen);
-goto error;
-}

Re: [Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 05:00:03PM +0200, Jim Meyering wrote:
> This fix addresses a problem exposed in an ovirt script whereby
> trying to use bash process substitution, e.g., in
> virsh define <(command to generate xml)
> would fail.
> 
> Oops.  Just noticed that the indentation in the added function
> (gnulib style) is not consistent with the rest of the file.
> I'll adjust that before committing, of course.
> 
>   Don't fail to read a file because it's non-seekable (e.g., a pipe).
>   * src/util.c (fread_file_lim): New function.
>   (__virFileReadAll): Use fread_file_lim, rather than requiring
>   that stat.st_size provide a usable file size.
>   * tests/read-non-seekable: New test, for the above.
>   * tests/Makefile.am (test_scripts): Add read-non-seekable.
>   * tests/test-lib.sh (mkfifo_or_skip_): New helper function.

This fix looks good.  In fact I'd go further and remove the test for
S_ISDIR(st.st_mode) and the stat buffer altogether.

+1

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v

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


Re: [Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Jim Meyering
Jim Meyering <[EMAIL PROTECTED]> wrote:
> FYI, I expect to add fread_file_lim or something like it to gnulib,
> and it already has some unit tests (passed).
> I removed the "*  tab-width: 4" line because it seriously
> mangled the code that I initially added.  Besides saying "tab-width 4"
> is contradictory with the "indent-tabs-mode: nil" setting.
>
> This fix addresses a problem exposed in an ovirt script whereby
> trying to use bash process substitution, e.g., in
> virsh define <(command to generate xml)
> would fail.
>
> Oops.  Just noticed that the indentation in the added function
> (gnulib style) is not consistent with the rest of the file.
> I'll adjust that before committing, of course.
>
>   Don't fail to read a file because it's non-seekable (e.g., a pipe).
>   * src/util.c (fread_file_lim): New function.
>   (__virFileReadAll): Use fread_file_lim, rather than requiring
>   that stat.st_size provide a usable file size.
>   * tests/read-non-seekable: New test, for the above.
>   * tests/Makefile.am (test_scripts): Add read-non-seekable.
>   * tests/test-lib.sh (mkfifo_or_skip_): New helper function.

One possible change:

realloc the result to fit the size of the just-read data.
Otherwise, even a small string ends up using a BUFSIZ+1-byte buffer.

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


[Libvir] Don't fail to read a file because it's non-seekable (e.g., a pipe).

2008-04-08 Thread Jim Meyering
FYI, I expect to add fread_file_lim or something like it to gnulib,
and it already has some unit tests (passed).
I removed the "*  tab-width: 4" line because it seriously
mangled the code that I initially added.  Besides saying "tab-width 4"
is contradictory with the "indent-tabs-mode: nil" setting.

This fix addresses a problem exposed in an ovirt script whereby
trying to use bash process substitution, e.g., in
virsh define <(command to generate xml)
would fail.

Oops.  Just noticed that the indentation in the added function
(gnulib style) is not consistent with the rest of the file.
I'll adjust that before committing, of course.

Don't fail to read a file because it's non-seekable (e.g., a pipe).
* src/util.c (fread_file_lim): New function.
(__virFileReadAll): Use fread_file_lim, rather than requiring
that stat.st_size provide a usable file size.
* tests/read-non-seekable: New test, for the above.
* tests/Makefile.am (test_scripts): Add read-non-seekable.
* tests/test-lib.sh (mkfifo_or_skip_): New helper function.

Signed-off-by: Jim Meyering <[EMAIL PROTECTED]>
---
 src/util.c  |   87 +-
 tests/Makefile.am   |1 +
 tests/read-non-seekable |   47 +
 tests/test-lib.sh   |   12 ++
 4 files changed, 130 insertions(+), 17 deletions(-)
 create mode 100755 tests/read-non-seekable

diff --git a/src/util.c b/src/util.c
index 0667780..e951eb5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -49,6 +49,10 @@

 #include "util-lib.c"

+#ifndef MIN
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
 #define MAX_ERROR_LEN   1024

 #define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
@@ -283,6 +287,61 @@ virExecNonBlock(virConnectPtr conn,

 #endif /* __MINGW32__ */

+/* Like gnulib's fread_file, but read no more than the specified maximum
+   number of bytes.  If the length of the input is <= max_len, and
+   upon error while reading that data, it works just like fread_file.  */
+static char *
+fread_file_lim (FILE *stream, size_t max_len, size_t *length)
+{
+  char *buf = NULL;
+  size_t alloc = 0;
+  size_t size = 0;
+  int save_errno;
+
+  for (;;)
+{
+  size_t count;
+  size_t requested;
+
+  if (size + BUFSIZ + 1 > alloc)
+{
+  char *new_buf;
+
+  alloc += alloc / 2;
+  if (alloc < size + BUFSIZ + 1)
+alloc = size + BUFSIZ + 1;
+
+  new_buf = realloc (buf, alloc);
+  if (!new_buf)
+{
+  save_errno = errno;
+  break;
+}
+
+  buf = new_buf;
+}
+
+  /* Ensure that (size + requested <= max_len); */
+  requested = MIN (size < max_len ? max_len - size : 0,
+   alloc - size - 1);
+  count = fread (buf + size, 1, requested, stream);
+  size += count;
+
+  if (count != requested || requested == 0)
+{
+  save_errno = errno;
+  if (ferror (stream))
+break;
+  buf[size] = '\0';
+  *length = size;
+  return buf;
+}
+}
+
+  free (buf);
+  errno = save_errno;
+  return NULL;
+}

 int __virFileReadAll(const char *path,
  int maxlen,
@@ -291,6 +350,8 @@ int __virFileReadAll(const char *path,
 FILE *fh;
 struct stat st;
 int ret = -1;
+size_t len;
+char *s;

 if (!(fh = fopen(path, "r"))) {
 virLog("Failed to open file '%s': %s",
@@ -309,28 +370,21 @@ int __virFileReadAll(const char *path,
 goto error;
 }

-if (st.st_size > maxlen) {
-virLog("File '%s' is too large %d, max %d", path, (int)st.st_size, 
maxlen);
-goto error;
-}
-
-*buf = malloc(st.st_size + 1);
-if (*buf == NULL) {
-virLog("Failed to allocate data");
+s = fread_file_lim(fh, maxlen+1, &len);
+if (s == NULL) {
+virLog("Failed to read '%s': %s", path, strerror (errno));
 goto error;
 }

-if ((ret = fread(*buf, st.st_size, 1, fh)) != 1) {
-free(*buf);
-*buf = NULL;
-virLog("Failed to read config file '%s': %s",
-   path, strerror(errno));
+if (len > maxlen || (int)len != len) {
+free(s);
+virLog("File '%s' is too large %d, max %d",
+   path, (int)st.st_size, maxlen);
 goto error;
 }

-(*buf)[st.st_size] = '\0';
-
-ret = st.st_size;
+*buf = s;
+ret = len;

  error:
 if (fh)
@@ -739,6 +793,5 @@ virParseMacAddr(const char* str, unsigned char *addr)
  *  indent-tabs-mode: nil
  *  c-indent-level: 4
  *  c-basic-offset: 4
- *  tab-width: 4
  * End:
  */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 901e88a..ca12b84 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -46,6 +46,7 @@ noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest 
virshtest conftest \
 test_scripts = \
daemon-conf \
int-overflow \
+   re

Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Pau Garcia i Quiles

Quoting "Richard W.M. Jones" <[EMAIL PROTECTED]>:


This patch allows selection of the NIC model for QEMU/KVM domains.
The selection is done by adding a  element to the XML, as in
this example:


  
  


The model type string is only checked to make sure it's a short
alpha-numeric + underscore, since it seems impractical to extract the
actual list of supported models.


I've found how to get the list of supported models:

[EMAIL PROTECTED]:~$ kvm -net nic,model=? -hda ''
Warning: vlan 0 is not connected to host network
qemu: Supported ISA NICs: ne2k_isa
qemu: Supported PCI NICs: i82551 i82557b i82559er ne2k_pci pcnet  
rtl8139 e1000 virtio




If you choose a supported model then QEMU starts up with this extra
-nic parameter:

  /usr/bin/qemu-kvm -M pc -m 500 -smp 1 -monitor pty \
-boot c -hda /var/lib/xen/images/rhel51x32kvm.img \
-net nic,macaddr=00:16:3e:33:b8:d3,vlan=0,model=ne2k_pci -net   
user,vlan=0 \

-usb -vnc 127.0.0.1:0

If you choose a non-existant model then you get the error:

  libvir: QEMU error : internal error QEMU quit during monitor startup




--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


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


Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 02:57:15PM +0100, Daniel P. Berrange wrote:
> This patch seems incomplete - there's no code to include the  tag
> when dumping the XML.

Yeah, agreed - forgot about that :-(

> We should also implement the same for Xen driver really, since that has the
> choice of ne2k/rtl8139/e1000 too

I'll have a look.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Henri Cook
I'm sorry , didn't read the patch properly first!





Richard W.M. Jones wrote:
> This patch allows selection of the NIC model for QEMU/KVM domains.
> The selection is done by adding a  element to the XML, as in
> this example:
>
> 
>   
>   
> 
>
> The model type string is only checked to make sure it's a short
> alpha-numeric + underscore, since it seems impractical to extract the
> actual list of supported models.
>
> If you choose a supported model then QEMU starts up with this extra
> -nic parameter:
>
>   /usr/bin/qemu-kvm -M pc -m 500 -smp 1 -monitor pty \
> -boot c -hda /var/lib/xen/images/rhel51x32kvm.img \
> -net nic,macaddr=00:16:3e:33:b8:d3,vlan=0,model=ne2k_pci -net user,vlan=0 
> \
> -usb -vnc 127.0.0.1:0
>
> If you choose a non-existant model then you get the error:
>
>   libvir: QEMU error : internal error QEMU quit during monitor startup
>
> Rich.
>
>   
> 
>
> --
> Libvir-list mailing list
> Libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

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


Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Henri Cook
What about when the model name doesn't include an underscore? like e1000

H

Richard W.M. Jones wrote:
> This patch allows selection of the NIC model for QEMU/KVM domains.
> The selection is done by adding a  element to the XML, as in
> this example:
>
> 
>   
>   
> 
>
> The model type string is only checked to make sure it's a short
> alpha-numeric + underscore, since it seems impractical to extract the
> actual list of supported models.
>
> If you choose a supported model then QEMU starts up with this extra
> -nic parameter:
>
>   /usr/bin/qemu-kvm -M pc -m 500 -smp 1 -monitor pty \
> -boot c -hda /var/lib/xen/images/rhel51x32kvm.img \
> -net nic,macaddr=00:16:3e:33:b8:d3,vlan=0,model=ne2k_pci -net user,vlan=0 
> \
> -usb -vnc 127.0.0.1:0
>
> If you choose a non-existant model then you get the error:
>
>   libvir: QEMU error : internal error QEMU quit during monitor startup
>
> Rich.
>
>   
> 
>
> --
> Libvir-list mailing list
> Libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

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


Re: [Libvir] [PATCH] Catch qemu VM-start errors

2008-04-08 Thread Daniel P. Berrange
On Tue, Apr 08, 2008 at 12:50:39PM +0100, Richard W.M. Jones wrote:
> Patch to fix the aforementioned problem when qemu subprocess fails to
> start.

ACK

Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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


Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Daniel P. Berrange
On Tue, Apr 08, 2008 at 02:17:56PM +0100, Richard W.M. Jones wrote:
> This patch allows selection of the NIC model for QEMU/KVM domains.
> The selection is done by adding a  element to the XML, as in
> this example:
> 
> 
>   
>   
> 
> 
> The model type string is only checked to make sure it's a short
> alpha-numeric + underscore, since it seems impractical to extract the
> actual list of supported models.
> 
> If you choose a supported model then QEMU starts up with this extra
> -nic parameter:
> 
>   /usr/bin/qemu-kvm -M pc -m 500 -smp 1 -monitor pty \
> -boot c -hda /var/lib/xen/images/rhel51x32kvm.img \
> -net nic,macaddr=00:16:3e:33:b8:d3,vlan=0,model=ne2k_pci -net user,vlan=0 
> \
> -usb -vnc 127.0.0.1:0
> 
> If you choose a non-existant model then you get the error:
> 
>   libvir: QEMU error : internal error QEMU quit during monitor startup

This patch seems incomplete - there's no code to include the  tag
when dumping the XML.

We should also implement the same for Xen driver really, since that has the
choice of ne2k/rtl8139/e1000 too

Regards,
Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

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


Re: [Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Daniel Veillard
On Tue, Apr 08, 2008 at 02:17:56PM +0100, Richard W.M. Jones wrote:
> This patch allows selection of the NIC model for QEMU/KVM domains.
> The selection is done by adding a  element to the XML, as in
> this example:
> 
> 
>   
>   
> 
> 
> The model type string is only checked to make sure it's a short
> alpha-numeric + underscore, since it seems impractical to extract the
> actual list of supported models.
> 
> If you choose a supported model then QEMU starts up with this extra
> -nic parameter:
> 
>   /usr/bin/qemu-kvm -M pc -m 500 -smp 1 -monitor pty \
> -boot c -hda /var/lib/xen/images/rhel51x32kvm.img \
> -net nic,macaddr=00:16:3e:33:b8:d3,vlan=0,model=ne2k_pci -net user,vlan=0 
> \
> -usb -vnc 127.0.0.1:0
> 
> If you choose a non-existant model then you get the error:
> 
>   libvir: QEMU error : internal error QEMU quit during monitor startup

  The patch looks fine by me, +1

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

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


[Libvir] [PATCH] Allow selection of the NIC model in QEMU/KVM

2008-04-08 Thread Richard W.M. Jones
This patch allows selection of the NIC model for QEMU/KVM domains.
The selection is done by adding a  element to the XML, as in
this example:


  
  


The model type string is only checked to make sure it's a short
alpha-numeric + underscore, since it seems impractical to extract the
actual list of supported models.

If you choose a supported model then QEMU starts up with this extra
-nic parameter:

  /usr/bin/qemu-kvm -M pc -m 500 -smp 1 -monitor pty \
-boot c -hda /var/lib/xen/images/rhel51x32kvm.img \
-net nic,macaddr=00:16:3e:33:b8:d3,vlan=0,model=ne2k_pci -net user,vlan=0 \
-usb -vnc 127.0.0.1:0

If you choose a non-existant model then you get the error:

  libvir: QEMU error : internal error QEMU quit during monitor startup

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
Index: docs/libvir.html
===
RCS file: /data/cvs/libvirt/docs/libvir.html,v
retrieving revision 1.114
diff -u -r1.114 libvir.html
--- docs/libvir.html7 Apr 2008 10:54:40 -   1.114
+++ docs/libvir.html8 Apr 2008 12:57:20 -
@@ -1096,6 +1096,14 @@
   
 
 
+
+
+  
+  
+
+
+(where the network card model is one of those supported by
+  QEMU or KVM - see the relevant manual pages).
   
   Virtual network
 Provides a virtual network using a bridge device in the host.
Index: src/qemu_conf.c
===
RCS file: /data/cvs/libvirt/src/qemu_conf.c,v
retrieving revision 1.46
diff -u -r1.46 qemu_conf.c
--- src/qemu_conf.c 28 Mar 2008 20:38:21 -  1.46
+++ src/qemu_conf.c 8 Apr 2008 12:57:23 -
@@ -706,6 +706,7 @@
 xmlChar *script = NULL;
 xmlChar *address = NULL;
 xmlChar *port = NULL;
+xmlChar *model = NULL;
 
 net->type = QEMUD_NET_USER;
 
@@ -767,6 +768,8 @@
(net->type == QEMUD_NET_ETHERNET) &&
xmlStrEqual(cur->name, BAD_CAST "script")) {
 script = xmlGetProp(cur, BAD_CAST "path");
+} else if (xmlStrEqual (cur->name, BAD_CAST "model")) {
+model = xmlGetProp (cur, BAD_CAST "type");
 }
 }
 cur = cur->next;
@@ -926,6 +929,38 @@
 xmlFree(address);
 }
 
+/* NIC model (see -net nic,model=?).  We only check that it looks
+ * reasonable, not that it is a supported NIC type.  FWIW kvm
+ * supports these types as of April 2008:
+ * i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
+ */
+if (model != NULL) {
+int i, len, char_ok;
+
+len = xmlStrlen (model);
+if (len >= QEMUD_MODEL_MAX_LEN) {
+qemudReportError (conn, NULL, NULL, VIR_ERR_INVALID_ARG,
+  _("Model name '%s' is too long"), model);
+goto error;
+}
+for (i = 0; i < len; ++i) {
+char_ok =
+(model[i] >= '0' && model[i] <= '9') ||
+(model[i] >= 'a' && model[i] <= 'z') ||
+(model[i] >= 'A' && model[i] <= 'Z') || model[i] == '_';
+if (!char_ok) {
+qemudReportError (conn, NULL, NULL, VIR_ERR_INVALID_ARG,
+  _("Model name contains invalid characters"));
+goto error;
+}
+}
+strncpy (net->model, BAD_CAST model, len);
+net->model[len] = '\0';
+
+xmlFree (model);
+} else
+net->model[0] = '\0';
+
 return 0;
 
  error:
@@ -941,6 +976,8 @@
 xmlFree(script);
 if (bridge)
 xmlFree(bridge);
+if (model)
+xmlFree(model);
 return -1;
 }
 
@@ -1829,13 +1866,22 @@
 } else {
 int vlan = 0;
 while (net) {
+char model[100];
 char nic[100];
 
-if (snprintf(nic, sizeof(nic), 
"nic,macaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d",
+if (net->model[0] != '\0') {
+if (snprintf (model, sizeof (model), ",model=%s", net->model)
+>= sizeof (model))
+goto error;
+} else
+model[0] = '\0';
+
+if (snprintf(nic, sizeof(nic),
+ "nic,macaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d%s",
  net->mac[0], net->mac[1],
  net->mac[2], net->mac[3],
  net->mac[4], net->mac[5],
- vlan) >= sizeof(nic))
+ vlan, model) >= sizeof(nic))
 goto error;
 
 if (!((*argv)[++n] = strd

Re: [Libvir] [PATCH] Catch qemu VM-start errors

2008-04-08 Thread Daniel Veillard
On Tue, Apr 08, 2008 at 12:50:39PM +0100, Richard W.M. Jones wrote:
> Patch to fix the aforementioned problem when qemu subprocess fails to
> start.

  Fine by me, +1,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

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


[Libvir] [PATCH] Catch qemu VM-start errors

2008-04-08 Thread Richard W.M. Jones
Patch to fix the aforementioned problem when qemu subprocess fails to
start.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
Index: src/qemu_driver.c
===
RCS file: /data/cvs/libvirt/src/qemu_driver.c,v
retrieving revision 1.64
diff -u -r1.64 qemu_driver.c
--- src/qemu_driver.c   28 Mar 2008 20:38:21 -  1.64
+++ src/qemu_driver.c   8 Apr 2008 11:51:29 -
@@ -603,7 +603,7 @@
   struct qemud_driver *driver,
   struct qemud_vm *vm) {
 char **argv = NULL, **tmp;
-int i;
+int i, ret;
 char logfile[PATH_MAX];
 
 if (qemudIsActiveVM(vm)) {
@@ -681,8 +681,9 @@
 qemudLog(QEMUD_WARN, _("Unable to write argv to logfile %d: %s"),
  errno, strerror(errno));
 
-if (virExecNonBlock(conn, argv, &vm->pid,
-vm->stdin, &vm->stdout, &vm->stderr) == 0) {
+ret = virExecNonBlock(conn, argv, &vm->pid,
+  vm->stdin, &vm->stdout, &vm->stderr);
+if (ret == 0) {
 vm->id = driver->nextvmid++;
 vm->state = vm->migrateFrom[0] ? VIR_DOMAIN_PAUSED : 
VIR_DOMAIN_RUNNING;
 
@@ -704,28 +705,30 @@
 vm->ntapfds = 0;
 }
 
-if (virEventAddHandle(vm->stdout,
-  POLLIN | POLLERR | POLLHUP,
-  qemudDispatchVMEvent,
-  driver) < 0) {
-qemudShutdownVMDaemon(conn, driver, vm);
-return -1;
-}
+if (ret == 0) {
+if (virEventAddHandle(vm->stdout,
+  POLLIN | POLLERR | POLLHUP,
+  qemudDispatchVMEvent,
+  driver) < 0) {
+qemudShutdownVMDaemon(conn, driver, vm);
+return -1;
+}
 
-if (virEventAddHandle(vm->stderr,
-  POLLIN | POLLERR | POLLHUP,
-  qemudDispatchVMEvent,
-  driver) < 0) {
-qemudShutdownVMDaemon(conn, driver, vm);
-return -1;
-}
+if (virEventAddHandle(vm->stderr,
+  POLLIN | POLLERR | POLLHUP,
+  qemudDispatchVMEvent,
+  driver) < 0) {
+qemudShutdownVMDaemon(conn, driver, vm);
+return -1;
+}
 
-if (qemudWaitForMonitor(conn, driver, vm) < 0) {
-qemudShutdownVMDaemon(conn, driver, vm);
-return -1;
+if (qemudWaitForMonitor(conn, driver, vm) < 0) {
+qemudShutdownVMDaemon(conn, driver, vm);
+return -1;
+}
 }
 
-return 0;
+return ret;
 }
 
 static int qemudVMData(struct qemud_driver *driver ATTRIBUTE_UNUSED,
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Henri Cook
Sorry - I tried to make a patch, but it appears it makes libvirtd
segfault (it starts but when i try to use virsh -c qemu:///system create
vm.cfg it segfaults).

Also - when building my own copy of libvirt - I can connect via virsh -c
qemu:///system, but just 'virsh' says it cannot connect to the
hypervisor - any idea what could cause that? I'm root at the time

As I said, my C-fu is weak - it's probably not useable, if anyone feels
really generous i'd appreciate some criticism, otherwise probably best
if one of you guys made it :p

I think for the meantime i'm going to hard code model=e1000 into my
build, since all my VMs will use that (no windows ones)

Henri

Richard W.M. Jones wrote:
> On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
>   
>> I've made a hack for this in the meantime that adds the 
>> 
>
> You have a patch?
>
>   
>> Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0
>> down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?
>> 
>
> This should be enough to get rid of the bridge, but if not then you
> need to look at the error messages and the output of 'brctl show'.
>
> Rich.
>
>   

--- libvirt-0.4.0/src/qemu_conf.h	2007-12-04 13:26:35.0 +
+++ libvirt-0.4.0-new/src/qemu_conf.h	2008-04-08 11:08:40.0 +0100
@@ -68,6 +68,7 @@
 
 #define QEMUD_MAC_ADDRESS_LEN 6
 #define QEMUD_OS_TYPE_MAX_LEN 10
+#define	QEMUD_NET_DRIVER_MAX_LEN 10
 #define QEMUD_OS_ARCH_MAX_LEN 10
 #define QEMUD_OS_MACHINE_MAX_LEN 10
 
@@ -90,6 +91,8 @@
 struct qemud_vm_net_def {
 int type;
 unsigned char mac[QEMUD_MAC_ADDRESS_LEN];
+unsigned char model[QEMUD_NET_DRIVER_MAX_LEN]; 
+
 union {
 struct {
 char ifname[BR_IFNAME_MAXLEN];

--- libvirt-0.4.0/src/qemu_conf.c	2007-12-12 13:30:49.0 +
+++ libvirt-0.4.0-new/src/qemu_conf.c	2008-04-08 12:36:02.0 +0100
@@ -605,6 +605,7 @@
 xmlChar *script = NULL;
 xmlChar *address = NULL;
 xmlChar *port = NULL;
+xmlChar *model = NULL;
 
 net->type = QEMUD_NET_USER;
 
@@ -666,6 +667,8 @@
(net->type == QEMUD_NET_ETHERNET) &&
xmlStrEqual(cur->name, BAD_CAST "script")) {
 script = xmlGetProp(cur, BAD_CAST "path");
+} else if (xmlStrEqual(cur->name, BAD_CAST "model")) {
+	model = xmlGetProp(cur, BAD_CAST "type");
 }
 }
 cur = cur->next;
@@ -822,6 +825,17 @@
 }
 xmlFree(address);
 }
+
+// Model can apply to all interface configurations, should we check for all the known supported model types?
+// Otherwise it's an optional parameter, so no real checking need be done
+if (model != NULL) {
+	int len = 0;
+	if ((len = xmlStrlen(model)) >= QEMUD_NET_DRIVER_MAX_LEN) {
+		qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Interface model type '%s' is too long"), model);
+goto error;
+	}		
+}
 
 return 0;
 
@@ -838,6 +852,8 @@
 xmlFree(script);
 if (bridge)
 xmlFree(bridge);
+if (model)
+	xmlFree(model);
 return -1;
 }
 
@@ -1679,13 +1695,27 @@
 int vlan = 0;
 while (net) {
 char nic[100];
+char model[QEMUD_NET_DRIVER_MAX_LEN];
 
-if (snprintf(nic, sizeof(nic), "nic,macaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d",
+			// Model's optional, if it's not set simply set the temporary 'model' variable to ''
+			if (net->model == NULL)
+			{
+snprintf(model, sizeof(model), ",");
+			}
+			else
+			{
+snprintf(model, sizeof(model), ",model=%s,", net->model);
+			}
+			
+if (snprintf(nic, sizeof(nic), "nic%smacaddr=%02x:%02x:%02x:%02x:%02x:%02x,vlan=%d",
+			 model,
  net->mac[0], net->mac[1],
  net->mac[2], net->mac[3],
  net->mac[4], net->mac[5],
  vlan) >= sizeof(nic))
 goto error;
+
+free(model);
 
 if (!((*argv)[++n] = strdup("-net")))
 goto no_memory;
--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Pau Garcia i Quiles

Quoting "Richard W.M. Jones" <[EMAIL PROTECTED]>:


On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:

I just tried to port a few customers over to this libvirt setup i'm
hoping to run and I couldn't get their machines started because there's
no mechanism to specify a model in the XML!

I know redhat have changed KVM's default driver to e1000, which I think
is the one I like the most and almost if not all of my VMs use. Ubuntu
haven't done that yet however!

Is there a model directive in the latest version? In the works? Just so
I know which solution I should pursue (updating libvirt or harassing
ubuntu to change the default)


There isn't a way to select the model, but there ought to be.  In KVM
64 the following NIC models are supported:

  i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio

Part of the problem with implementing this will be validating the
model (unless we just pass the model string directly to qemu which
could lead to errors).  The documentation suggests running qemu with
'-net nic,model=?' to list the models, and there is code in
qemu/hw/pci.c to implement this, but it just doesn't work for me.

  $ qemu-kvm -net nic,model=?

  [ prints full help because of the missing hda parameter ]

  $ qemu-kvm -net nic,model=? hda=/dev/null
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/dev/null

  $ qemu-kvm -net nic,model=? hda=/dev/zero
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/dev/zero

  $ touch /tmp/file
  $ qemu-kvm -net nic,model=? hda=/tmp/file
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/tmp/file

  $ dd if=/dev/zero of=/tmp/file bs=1024 count=1024
  1024+0 records in
  1024+0 records out
  1048576 bytes (1.0 MB) copied, 0.00765395 s, 137 MB/s
  $ qemu-kvm -net nic,model=? hda=/tmp/file
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/tmp/file


The same error happens in KVM and Qemu (not qemu-kvm) on Ubuntu. I'd  
say the problem belongs to Qemu, not to KVM.


--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)


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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Henri Cook
There's nothing in brctl show for virbr0 - br0 still exists but that's
in use (And shouldn't be causing the problem?)

Maybe it's a one off - i'll try to recreate

It could be a patch, maybe, I think bits of it are really bad C (i.e.
hackery at its worst) - i'll make sure it works then see if i can merge
it with source - unless someone who knows more and can do the error
checking beats me too it, it's only about 6 lines

Cheers,

Henri

Richard W.M. Jones wrote:
> On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
>   
>> I've made a hack for this in the meantime that adds the 
>> 
>
> You have a patch?
>
>   
>> Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0
>> down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?
>> 
>
> This should be enough to get rid of the bridge, but if not then you
> need to look at the error messages and the output of 'brctl show'.
>
> Rich.
>
>   

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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 10:19:02AM +0100, Henri Cook wrote:
> I've made a hack for this in the meantime that adds the 

You have a patch?

> Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0
> down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?

This should be enough to get rid of the bridge, but if not then you
need to look at the error messages and the output of 'brctl show'.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


Re: [Libvir] [PATCH] Add xen and hvm guest types to test drive caps

2008-04-08 Thread Daniel Veillard
On Fri, Apr 04, 2008 at 10:47:08AM -0400, Cole Robinson wrote:
> Daniel P. Berrange wrote:
> > On Tue, Mar 04, 2008 at 04:17:34PM -0500, Cole Robinson wrote:
> >> The attached patch adds xen and hvm guest types to the test driver's 
> >> capabilities. It was currently set to offer only a 'linux' type which
> >> doesn't seem to follow the conventions of the other drivers, so I
> >> removed that. Please yell if I'm wrong :)
> > 
> > THis patch all seems fine to me. The only problem you'll likely hit is
> > that the domain XML parser won't like the full-virt style  block
> > where you list a  tag instead of kernel/initrd. Of course you can
> > do HVM +  kernel/initrd too, so I've no problem adding this patch - just
> > that we'll likely need to add more XML parsing support to the test driver
> > to give full coverage of the HVM style configs.
> > 
> >> @@ -984,6 +984,8 @@ static char *testGetCapabilities (virConnectPtr conn)
> >>  char *xml;
> >>  int cell1[] = { 0, 2, 4, 6, 8, 10, 12, 14 };
> >>  int cell2[] = { 1, 3, 5, 7, 9, 11, 13, 15 };
> >> +const char *guest_types[] = { "hvm", "xen" };
> >> +int num_guest_types = 2, i;
> > 
> > Having a 'num_guest_types' variable is not neccessary...
> > 
> >> +for (i = 0; i < num_guest_types; ++i) {
> > 
> > Just use  'sizeof(guest_types)/sizeof(guest_types[0])' instead
> > 
> > Regards,
> > Dan.
> 
> I forgot to resend this :/

  And i forgot to apply it ;-)
Looks good, this is now in CVS,

  thanks !

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Henri Cook
I've made a hack for this in the meantime that adds the 
option to the  section and allows me to pass in any string
for addition - since I really wanted this functionality. Obviously this
means i'm now compiling my Ubuntu package from source which isn't ideal,
it'll probably get overwritten by apt at any moment :o

Also, i got in a bit of a pickle last night which I had to reboot to fix:

[EMAIL PROTECTED]:~# /usr/sbin/libvirtd -d
libvir: QEMU error : cannot create bridge 'virbr0' : File exists
Failed to autostart network 'default': cannot create bridge 'virbr0' :
File exists

Is there a way to fix this without rebooting? ifconfig virbr0 0.0.0.0
down && brctl delbr virbr0 - doesn't seem to be enough, what did I miss?

On the  options - an error message does seem like the best
option: with model=foo in the -net options

qemu: Unsupported NIC: foo

I'd love to put all that in myself but my C-fu is seriously limited - I
can only do simple work without more time to learn things properly, like
adding things to the XML based on all the previous examples *g*

Cheers,

Henri

Daniel Veillard wrote:
> On Tue, Apr 08, 2008 at 09:05:41AM +0100, Richard W.M. Jones wrote:
>   
>> On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
>> 
>>> I just tried to port a few customers over to this libvirt setup i'm
>>> hoping to run and I couldn't get their machines started because there's
>>> no mechanism to specify a model in the XML!
>>>
>>> I know redhat have changed KVM's default driver to e1000, which I think
>>> is the one I like the most and almost if not all of my VMs use. Ubuntu
>>> haven't done that yet however!
>>>
>>> Is there a model directive in the latest version? In the works? Just so
>>> I know which solution I should pursue (updating libvirt or harassing
>>> ubuntu to change the default)
>>>   
>> There isn't a way to select the model, but there ought to be.  In KVM
>> 64 the following NIC models are supported:
>>
>>   i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
>>
>> Part of the problem with implementing this will be validating the
>> model (unless we just pass the model string directly to qemu which
>> could lead to errors).  The documentation suggests running qemu with
>> '-net nic,model=?' to list the models, and there is code in
>> qemu/hw/pci.c to implement this, but it just doesn't work for me.
>>
>> 
>
> Then what happen if you pass a wrong string ? Is there any way to get a
> meaningful error back from qemu and report it. Thet would IMHO be quite
> better than tracking the evolution of the emulation in QEmu, plus the
> added benefit of not being tied to a strict version of QEmu,
>
> Daniel
>
>   

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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Richard W.M. Jones
On Tue, Apr 08, 2008 at 04:45:23AM -0400, Daniel Veillard wrote:
> Then what happen if you pass a wrong string ? Is there any way to get a
> meaningful error back from qemu and report it. Thet would IMHO be quite
> better than tracking the evolution of the emulation in QEmu, plus the
> added benefit of not being tied to a strict version of QEmu,

The error handling in this part of the code seems a bit confused at
the moment.  For example:

if (virExecNonBlock(conn, argv, &vm->pid,
vm->stdin, &vm->stdout, &vm->stderr) == 0) {
/* [add new qemu to list of VMs] */
}

/* [free up various resources] */

if (virEventAddHandle(vm->stdout,
  POLLIN | POLLERR | POLLHUP,
  qemudDispatchVMEvent,
  driver) < 0) {
qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}

/* [another call to virEventAddHandle] */

if (qemudWaitForMonitor(conn, driver, vm) < 0) {
qemudShutdownVMDaemon(conn, driver, vm);
return -1;
}

return 0;

If virExecNonBlock fails, because one of the system calls such as
fork(2) or pipe(2) fails, then vm->stdout may be uninitialized.  I
think it will assume the value 0 in this case and virEventAddHandle
will quite happily register a handler for fd 0.

On the other hand it is tricky to know what to do when launching a
process.  In the case where KVM doesn't understand part of the command
line arguments, the fork & exec will both succeed and the earliest
point where we will see any error will be at qemudWaitForMonitor
(because the monitor won't come up -- note this code is synchronous).

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Daniel Veillard
On Tue, Apr 08, 2008 at 09:05:41AM +0100, Richard W.M. Jones wrote:
> On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
> > I just tried to port a few customers over to this libvirt setup i'm
> > hoping to run and I couldn't get their machines started because there's
> > no mechanism to specify a model in the XML!
> > 
> > I know redhat have changed KVM's default driver to e1000, which I think
> > is the one I like the most and almost if not all of my VMs use. Ubuntu
> > haven't done that yet however!
> > 
> > Is there a model directive in the latest version? In the works? Just so
> > I know which solution I should pursue (updating libvirt or harassing
> > ubuntu to change the default)
> 
> There isn't a way to select the model, but there ought to be.  In KVM
> 64 the following NIC models are supported:
> 
>   i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
> 
> Part of the problem with implementing this will be validating the
> model (unless we just pass the model string directly to qemu which
> could lead to errors).  The documentation suggests running qemu with
> '-net nic,model=?' to list the models, and there is code in
> qemu/hw/pci.c to implement this, but it just doesn't work for me.
> 

Then what happen if you pass a wrong string ? Is there any way to get a
meaningful error back from qemu and report it. Thet would IMHO be quite
better than tracking the evolution of the emulation in QEmu, plus the
added benefit of not being tied to a strict version of QEmu,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

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


Re: [Libvir] e1000 - Specifying model in XML Configs

2008-04-08 Thread Richard W.M. Jones
On Mon, Apr 07, 2008 at 10:51:56PM +0100, Henri Cook wrote:
> I just tried to port a few customers over to this libvirt setup i'm
> hoping to run and I couldn't get their machines started because there's
> no mechanism to specify a model in the XML!
> 
> I know redhat have changed KVM's default driver to e1000, which I think
> is the one I like the most and almost if not all of my VMs use. Ubuntu
> haven't done that yet however!
> 
> Is there a model directive in the latest version? In the works? Just so
> I know which solution I should pursue (updating libvirt or harassing
> ubuntu to change the default)

There isn't a way to select the model, but there ought to be.  In KVM
64 the following NIC models are supported:

  i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio

Part of the problem with implementing this will be validating the
model (unless we just pass the model string directly to qemu which
could lead to errors).  The documentation suggests running qemu with
'-net nic,model=?' to list the models, and there is code in
qemu/hw/pci.c to implement this, but it just doesn't work for me.

  $ qemu-kvm -net nic,model=?
  
  [ prints full help because of the missing hda parameter ]
  
  $ qemu-kvm -net nic,model=? hda=/dev/null
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/dev/null
  
  $ qemu-kvm -net nic,model=? hda=/dev/zero
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/dev/zero
  
  $ touch /tmp/file
  $ qemu-kvm -net nic,model=? hda=/tmp/file
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/tmp/file
  
  $ dd if=/dev/zero of=/tmp/file bs=1024 count=1024
  1024+0 records in
  1024+0 records out
  1048576 bytes (1.0 MB) copied, 0.00765395 s, 137 MB/s
  $ qemu-kvm -net nic,model=? hda=/tmp/file
  open /dev/kvm: Permission denied
  Could not initialize KVM, will disable KVM support
  Warning: vlan 0 is not connected to host network
  qemu: could not open disk image hda=/tmp/file

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top

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


Re: [Libvir] Wiki Pages?

2008-04-08 Thread Daniel Veillard
On Mon, Apr 07, 2008 at 09:14:03PM +0100, Daniel P. Berrange wrote:
> On Mon, Apr 07, 2008 at 03:35:51PM -0400, Daniel Veillard wrote:
> > Well if you have maintainance experience, why not ... except libvirt.org
> > is a RHEL-4 box, i.e. not the easiest for bleeding edge stuff.
> > if you feel this is reasonnable, and won't waste too much time, I agree
> > this can be really useful too, I'm fine with the idea.
> 
> FYI, the et.redhat.com  which hosts  virt-manager.org / ovirt.org /
> freeipa.org is setup to provide Wikis - we can easily add a libvirt
> mediawiki instance there if desired.

  Thanks to Henry for his offer, but i think adding the Wiki on et.redhat.com
would make a lot of sense, since it's already set up (just a bit of config
seems needed) and existing people around the project can manage it.
  I have added wiki.libvirt.org to point to et.redhat.com, this should 
propagate to DNS shortly. That should allow to plug the Wiki in easilly
I suppose,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

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