Re: [libvirt] unable to set security context (NFSv4 problem?)

2010-04-16 Thread Harald Dunkel
Hi folks,

On 04/15/10 22:06, Spencer Shimko wrote:
 
 What is security_driver set to in /etc/libvirt/qemu.conf?
 

It is not set at all. AFAICS there is no man page for qemu.conf,
but according to KISS I had assumed that the security_driver
stuff is disabled by default. Is it?

 
 Out of curiosity, are you using the SELinux support in Debian?
 

For both NFS client and server:

selinux is enabled in the kernel. Debian's libselinux1 package
is installed, too, because it seems to be an essential dependency
for other packages. There are no selinux policies set up, and the
selinux-basics package is not installed, either.

Would you suggest to rebuild the kernel without selinux?

BTW, the NFS server uses reiserfs for its exported partitions.


Regards

Harri

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


[libvirt] [PATCH] nwfilter: Clear all state tracking from a drop rule

2010-04-16 Thread Stefan Berger
Don't use state-matching in a drop rule.

Signed-off-by: Stefan Berger stef...@us.ibm.com

Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
===
--- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
+++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -1380,13 +1380,16 @@ _iptablesCreateRuleInstance(int directio
 return 0;
 }
 
-if (match)
-virBufferVSprintf(buf,  %s, match);
-
 if (rule-action == VIR_NWFILTER_RULE_ACTION_ACCEPT)
 target = accept_target;
-else
+else {
 target = DROP;
+match = NULL;
+}
+
+if (match)
+virBufferVSprintf(buf,  %s, match);
+
 
 virBufferVSprintf(buf,
-j %s CMD_DEF_POST CMD_SEPARATOR


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


[libvirt] [PATCH] Fix device_del in JSON mode for QEMU

2010-04-16 Thread Daniel P. Berrange
The 'device_del' command expects a parameter called 'id' but we
were passing 'config'.

* src/qemu/qemu_monitor_json.c: Fix device_del command parameter
---
 src/qemu/qemu_monitor_json.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 001b32b..c3ed47c 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2021,7 +2021,7 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
 virJSONValuePtr reply = NULL;
 
 cmd = qemuMonitorJSONMakeCommand(device_del,
- s:config, devalias,
+ s:id, devalias,
  NULL);
 if (!cmd)
 return -1;
-- 
1.6.6.1

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


[libvirt] [PATCH] Fix network hotplug to use device_add in QEMU

2010-04-16 Thread Daniel P. Berrange
The initial boot of VMs uses -device for NICs where available. The
corresponding monitor command is device_add, but the network hotplug
code was still using device_del by mistake.

* src/qemu/qemu_driver.c: Use device_add for NIC hotplug where
  available
---
 src/qemu/qemu_driver.c |   28 
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 5c15c1d..9e0a353 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7210,17 +7210,29 @@ static int qemudDomainAttachNetDevice(virConnectPtr 
conn,
 close(tapfd);
 tapfd = -1;
 
-if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
-goto try_remove;
+if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
+if (!(nicstr = qemuBuildNicDevStr(net, vlan)))
+goto try_remove;
+} else {
+if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
+goto try_remove;
+}
 
 qemuDomainObjEnterMonitorWithDriver(driver, vm);
-if (qemuMonitorAddPCINetwork(priv-mon, nicstr,
- guestAddr)  0) {
-qemuDomainObjExitMonitorWithDriver(driver, vm);
-goto try_remove;
+if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
+if (qemuMonitorAddDevice(priv-mon, nicstr)  0) {
+qemuDomainObjExitMonitorWithDriver(driver, vm);
+goto try_remove;
+}
+} else {
+if (qemuMonitorAddPCINetwork(priv-mon, nicstr,
+ guestAddr)  0) {
+qemuDomainObjExitMonitorWithDriver(driver, vm);
+goto try_remove;
+}
+net-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+memcpy(net-info.addr.pci, guestAddr, sizeof(guestAddr));
 }
-net-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-memcpy(net-info.addr.pci, guestAddr, sizeof(guestAddr));
 qemuDomainObjExitMonitorWithDriver(driver, vm);
 
 ret = 0;
-- 
1.6.6.1

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


[libvirt] [PATCH] Fix error reporting for getfd + host_net_add in QEMU

2010-04-16 Thread Daniel P. Berrange
If either of the getfd or host_net_add monitor commands return
any text, this indicates an error condition. Don't ignore this!

* src/qemu/qemu_monitor_text.c: Report errors for getfd and
  host_net_add
---
 src/qemu/qemu_monitor_text.c |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 48c9a54..6ad07b1 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -1666,6 +1666,13 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
 goto cleanup;
 }
 
+if (STRNEQ(reply, )) {
+qemuReportError(VIR_ERR_INTERNAL_ERROR,
+_(unable to send TAP file handle: %s),
+reply);
+goto cleanup;
+}
+
 ret = 0;
 
 cleanup:
@@ -1725,11 +1732,16 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
 
 if (qemuMonitorCommand(mon, cmd, reply)  0) {
 qemuReportError(VIR_ERR_OPERATION_FAILED,
-_(failed to close fd in qemu with '%s'), cmd);
+_(failed to add host net with '%s'), cmd);
 goto cleanup;
 }
 
-/* XXX error messages here ? */
+if (STRNEQ(reply, )) {
+qemuReportError(VIR_ERR_INTERNAL_ERROR,
+_(unable to add host net: %s),
+reply);
+goto cleanup;
+}
 
 ret = 0;
 
-- 
1.6.6.1

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


Re: [libvirt] Execute a command in a Guest Domain using libvirt.

2010-04-16 Thread Daniel P. Berrange
On Fri, Apr 16, 2010 at 11:02:45AM +0530, Kumar L Srikanth-B22348 wrote:
 Hi,
 
 I created a Domain using libvirt virsh console.
 
 Can I execute a command [like 'ifconfig'] in Guest Domain and get the
 output using libvirt?

Libvirt doesn't currently provide any APIs for interacting with the OS
inside the guest domain. You'll need to either hardcode IP address or
set some static DHCP mapping, so you can reliably determine what to
connect to.


Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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: [libvirt] [PATCH] Don't ship generated python/libvirt.? files.

2010-04-16 Thread Daniel P. Berrange
On Thu, Apr 15, 2010 at 12:49:33PM +0200, Philipp Hahn wrote:
 
 libvirt.c and libvirt.h are auto-generated files. Mentioning their names
 in *_SOURCES includes them in the distribution. During an out-of-tree
 build these shipped files are included instead of the auto-generated
 version, potentially breaking the build (as it happend in 0.8.0, because
 the shipped libvirt.h was missing the declaration for
 'libvirt_virDomainUpdateDeviceFlags')
 
 Use the nodist_*_SOURCES automake variable instead.
 
 Signed-off-by: Philipp Hahn h...@univention.de
 ---
  python/Makefile.am |3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

 diff --git a/python/Makefile.am b/python/Makefile.am
 index 6b67e38..eda2866 100644
 --- a/python/Makefile.am
 +++ b/python/Makefile.am
 @@ -34,7 +34,8 @@ all-local: libvirt.py
  
  pyexec_LTLIBRARIES = libvirtmod.la
  
 -libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c libvirt.c libvirt.h
 +libvirtmod_la_SOURCES = libvirt-override.c typewrappers.c
 +nodist_libvirtmod_la_SOURCES = libvirt.c libvirt.h
  # Python = 2.4 header files contain a redundant decl, hence we
  # need extra flags here
  libvirtmod_la_CFLAGS = $(WARN_PYTHON_CFLAGS)

ACK, I don't know why we've never seen this problem before...


Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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: [libvirt] [PATCH] nwfilter: Clear all state tracking from a drop rule

2010-04-16 Thread Daniel P. Berrange
On Fri, Apr 16, 2010 at 06:33:50AM -0400, Stefan Berger wrote:
 Don't use state-matching in a drop rule.
 
 Signed-off-by: Stefan Berger stef...@us.ibm.com
 
 Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
 ===
 --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
 +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
 @@ -1380,13 +1380,16 @@ _iptablesCreateRuleInstance(int directio
  return 0;
  }
  
 -if (match)
 -virBufferVSprintf(buf,  %s, match);
 -
  if (rule-action == VIR_NWFILTER_RULE_ACTION_ACCEPT)
  target = accept_target;
 -else
 +else {
  target = DROP;
 +match = NULL;
 +}
 +
 +if (match)
 +virBufferVSprintf(buf,  %s, match);
 +
  
  virBufferVSprintf(buf,
 -j %s CMD_DEF_POST CMD_SEPARATOR
 

ACK

Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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: [libvirt] [RFC PATCH 1/5] Qemu Monitor API entry point.

2010-04-16 Thread Daniel P. Berrange
On Tue, Apr 13, 2010 at 02:36:46PM -0400, Chris Lalancette wrote:
 Signed-off-by: Chris Lalancette clala...@redhat.com
 ---
  include/libvirt/Makefile.am|1 +
  include/libvirt/libvirt_qemu.h |   30 
  src/Makefile.am|   11 -
  src/driver.h   |5 ++
  src/esx/esx_driver.c   |1 +
  src/internal.h |1 +
  src/libvirt_qemu.c |   96 
 
  src/lxc/lxc_driver.c   |1 +
  src/opennebula/one_driver.c|1 +
  src/openvz/openvz_driver.c |1 +
  src/phyp/phyp_driver.c |1 +
  src/qemu/qemu_driver.c |1 +
  src/remote/remote_driver.c |1 +
  src/test/test_driver.c |1 +
  src/uml/uml_driver.c   |1 +
  src/vbox/vbox_tmpl.c   |1 +
  src/xen/xen_driver.c   |1 +
  src/xenapi/xenapi_driver.c |1 +
  18 files changed, 155 insertions(+), 1 deletions(-)
  create mode 100644 include/libvirt/libvirt_qemu.h
  create mode 100644 src/libvirt_qemu.c
 
 diff --git a/include/libvirt/Makefile.am b/include/libvirt/Makefile.am
 index 8589dc5..ac5f32c 100644
 --- a/include/libvirt/Makefile.am
 +++ b/include/libvirt/Makefile.am
 @@ -3,6 +3,7 @@
  virincdir = $(includedir)/libvirt
  
  virinc_HEADERS = libvirt.h   \
 +  libvirt_qemu.h \
virterror.h

Minor nitpick - I'd prefer an '-' instead of '_'

 diff --git a/include/libvirt/libvirt_qemu.h b/include/libvirt/libvirt_qemu.h
 new file mode 100644
 index 000..7d78a7f
 --- /dev/null
 +++ b/include/libvirt/libvirt_qemu.h
 @@ -0,0 +1,30 @@
 +/* -*- c -*-
 + * libvirt_qemu.h:
 + * Summary: qemu specific interfaces
 + * Description: Provides the interfaces of the libvirt library to handle
 + *  qemu specific methods
 + *
 + * Copy:  Copyright (C) 2010 Red Hat, Inc.
 + *
 + * See COPYING.LIB for the License of this software
 + *
 + * Author: Chris Lalancette clala...@redhat.com
 + */
 +
 +#ifndef __VIR_QEMU_H__
 +#define __VIR_QEMU_H__
 +
 +#include libvirt.h
 +
 +#ifdef __cplusplus
 +extern C {
 +#endif
 +
 +int virQemuMonitorCommand(virDomainPtr domain, const char *cmd, char 
 **result,
 +  unsigned int flags);

For naming, we should continue to keep the object name as the prefix, since
this makes things a little easier for python bindings. eg

   virDomainQemuMonitorRunCommand


 diff --git a/src/Makefile.am b/src/Makefile.am
 index d54e6d0..c01c94e 100644
 --- a/src/Makefile.am
 +++ b/src/Makefile.am
 @@ -32,7 +32,7 @@ if WITH_NETWORK
  UUID=$(shell uuidgen 2/dev/null)
  endif
  
 -lib_LTLIBRARIES = libvirt.la
 +lib_LTLIBRARIES = libvirt.la libvirt_qemu.la

And a '-' here too :-)

  
  moddir = $(libdir)/libvirt/drivers
  mod_LTLIBRARIES =
 @@ -945,6 +945,15 @@ libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
  libvirt_test_la_LDFLAGS = $(test_LDFLAGS)
  libvirt_test_la_CFLAGS = $(COVERAGE_CFLAGS)
  
 +libvirt_qemu_la_SOURCES = libvirt_qemu.c util/threads.c util/threads.h \
 +   util/threads-pthread.h   \
 +   util/threads-win32.h \
 +   util/virterror.c \
 +   util/virterror_internal.h

Do we need to directly recompile those pieces here ? I think
if you just add 'libvirt.la' to the libvirt_qemu_la_LIBADD
it should be able to link to the existing built functions 

 +
 +libvirt_qemu_la_LDFLAGS = $(libvirt_la_LDFALGS)
 +libvirt_qemu_la_CFLAGS = $(COVERAGE_CFLAGS)
 +
  
  libexec_PROGRAMS =
  
 diff --git a/src/driver.h b/src/driver.h
 index f8db9c1..651653d 100644
 --- a/src/driver.h
 +++ b/src/driver.h
 @@ -448,6 +448,10 @@ typedef int
  (*virDrvDomainSnapshotDelete)(virDomainSnapshotPtr snapshot,
unsigned int flags);
  
 +typedef int
 +(*virDrvQemuMonitorCommand)(virDomainPtr domain, const char *cmd,
 +char **result, unsigned int flags);
 +
  
  /**
   * _virDriver:
 @@ -558,6 +562,7 @@ struct _virDriver {
  virDrvDomainSnapshotCurrent domainSnapshotCurrent;
  virDrvDomainRevertToSnapshot domainRevertToSnapshot;
  virDrvDomainSnapshotDelete domainSnapshotDelete;
 +virDrvQemuMonitorCommand qemuMonitorCommand;
  };

As mentioned in my reply to your question in patch 0, I think we
could possibly ignore the drivers here, and just call directly to
the QEMU function ?

 diff --git a/src/internal.h b/src/internal.h
 index 2e73210..57dc660 100644
 --- a/src/internal.h
 +++ b/src/internal.h
 @@ -22,6 +22,7 @@
  # include gettext.h
  
  # include libvirt/libvirt.h
 +# include libvirt/libvirt_qemu.h
  # include libvirt/virterror.h

It'd be better to avoid that here if possible - just have it included
in libvirt_qemu.c so we avoid polluting all the drivers with the QEMU
specific header

  # include libvirt_internal.h
 diff 

Re: [libvirt] [RFC PATCH 2/5] Add namespace callback hooks to domain_conf.

2010-04-16 Thread Daniel P. Berrange
On Tue, Apr 13, 2010 at 02:36:47PM -0400, Chris Lalancette wrote:
 Signed-off-by: Chris Lalancette clala...@redhat.com
 ---
  src/conf/domain_conf.c|  106 
 +
  src/conf/domain_conf.h|   26 --
  src/esx/esx_driver.c  |4 +-
  src/lxc/lxc_controller.c  |2 +-
  src/lxc/lxc_driver.c  |   10 ++--
  src/opennebula/one_driver.c   |4 +-
  src/openvz/openvz_driver.c|4 +-
  src/phyp/phyp_driver.c|2 +-
  src/security/virt-aa-helper.c |2 +-
  src/test/test_driver.c|   12 ++--
  src/uml/uml_driver.c  |4 +-
  src/vbox/vbox_tmpl.c  |2 +-
  src/xen/xend_internal.c   |4 +-
  src/xen/xm_internal.c |2 +-
  src/xenapi/xenapi_driver.c|4 +-
  tests/bochsconf2xmltest   |  Bin 0 - 714002 bytes
  tests/qemuxml2argvtest.c  |2 +-
  tests/qemuxml2xmltest.c   |2 +-
  tests/xmconfigtest.c  |2 +-
  tests/xml2vmxtest.c   |2 +-
  20 files changed, 127 insertions(+), 69 deletions(-)
  create mode 100755 tests/bochsconf2xmltest


 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index 82f2d15..95a8dfb 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -794,6 +794,19 @@ int virDomainSnapshotObjUnref(virDomainSnapshotObjPtr 
 snapshot);
  int virDomainSnapshotHasChildren(virDomainSnapshotObjPtr snap,
  virDomainSnapshotObjListPtr snapshots);
  
 +typedef void *(*virDomainDefNamespaceParse)(xmlDocPtr, xmlNodePtr,
 +xmlXPathContextPtr);
 +typedef void (*virDomainDefNamespaceFree)(void *);
 +typedef int (*virDomainDefNamespaceXMLFormat)(virBufferPtr, void *);
 +typedef const char *(*virDomainDefNamespaceHref)(void);
 +
 +struct xmlNamespace {
 +virDomainDefNamespaceParse parse;
 +virDomainDefNamespaceFree free;
 +virDomainDefNamespaceXMLFormat format;
 +virDomainDefNamespaceHref href;
 +};

Lets rename that struct to have a virDomain prefix, since 'xmlNamespace'
could easily clash with something libxml might define.

 +
  /* Guest VM main configuration */
  typedef struct _virDomainDef virDomainDef;
  typedef virDomainDef *virDomainDefPtr;
 @@ -863,6 +876,9 @@ struct _virDomainDef {
  virSecurityLabelDef seclabel;
  virDomainWatchdogDefPtr watchdog;
  virCPUDefPtr cpu;
 +
 +void *namespaceData;
 +struct xmlNamespace ns;
  };

As mentioned in the other patch reply, I think it'd be preferable to
keep a struct with the parser config in virCapsPtr, so we don't need
to add to this struct, nor pass it into all the parse/format methods.

  
  /* Guest VM runtime state */
 @@ -965,21 +981,18 @@ virDomainDeviceDefPtr 
 virDomainDeviceDefParse(virCapsPtr caps,
int flags);
  virDomainDefPtr virDomainDefParseString(virCapsPtr caps,
  const char *xmlStr,
 +struct xmlNamespace *ns,
  int flags);
  virDomainDefPtr virDomainDefParseFile(virCapsPtr caps,
const char *filename,
 +  struct xmlNamespace *ns,
int flags);
  virDomainDefPtr virDomainDefParseNode(virCapsPtr caps,
xmlDocPtr doc,
xmlNodePtr root,
 +  struct xmlNamespace *ns,
int flags);
  
 -virDomainObjPtr virDomainObjParseFile(virCapsPtr caps,
 -  const char *filename);
 -virDomainObjPtr virDomainObjParseNode(virCapsPtr caps,
 -  xmlDocPtr xml,
 -  xmlNodePtr root);
 -
  int virDomainDefAddImplicitControllers(virDomainDefPtr def);
  
  # endif
 @@ -1024,6 +1037,7 @@ int virDomainLoadAllConfigs(virCapsPtr caps,
  const char *autostartDir,
  int liveStatus,
  virDomainLoadConfigNotify notify,
 +struct xmlNamespace *ns,
  void *opaque);
  

Regards,
Daniel
-- 
|: Red Hat, Engineering, London-o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.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: [libvirt] [RFC PATCH 3/5] Qemu remote protocol.

2010-04-16 Thread Daniel P. Berrange
On Tue, Apr 13, 2010 at 02:36:48PM -0400, Chris Lalancette wrote:
 Signed-off-by: Chris Lalancette clala...@redhat.com
 ---
  daemon/Makefile.am|   25 +-
  daemon/dispatch.c |  171 
 +++--
  daemon/libvirtd.h |1 +
  daemon/qemu_dispatch_args.h   |5 +
  daemon/qemu_dispatch_prototypes.h |   12 +++
  daemon/qemu_dispatch_ret.h|5 +
  daemon/qemu_dispatch_table.h  |   14 +++
  daemon/qemu_generate_stubs.pl |  170 
  daemon/remote.c   |   43 +
  daemon/remote.h   |8 ++
  src/Makefile.am   |   37 -
  src/remote/qemu_protocol.c|   60 +
  src/remote/qemu_protocol.h|   69 +++
  src/remote/qemu_protocol.x|   55 
  src/remote/remote_driver.c|  105 +--
  15 files changed, 665 insertions(+), 115 deletions(-)
  create mode 100644 daemon/qemu_dispatch_args.h
  create mode 100644 daemon/qemu_dispatch_prototypes.h
  create mode 100644 daemon/qemu_dispatch_ret.h
  create mode 100644 daemon/qemu_dispatch_table.h
  create mode 100755 daemon/qemu_generate_stubs.pl
  create mode 100644 src/remote/qemu_protocol.c
  create mode 100644 src/remote/qemu_protocol.h
  create mode 100644 src/remote/qemu_protocol.x
 
 diff --git a/daemon/dispatch.c b/daemon/dispatch.c
 index f024900..d36d1a1 100644
 --- a/daemon/dispatch.c
 +++ b/daemon/dispatch.c
 @@ -336,85 +336,6 @@ cleanup:
  }
  
  
 -int
 -remoteDispatchClientCall (struct qemud_server *server,
 -  struct qemud_client *client,
 -  struct qemud_client_message *msg);
 -
 -
 -/*
 - * @server: the unlocked server object
 - * @client: the locked client object
 - * @msg: the complete incoming message packet, with header already decoded
 - *
 - * This function gets called from qemud when it pulls a incoming
 - * remote protocol messsage off the dispatch queue for processing.
 - *
 - * The @msg parameter must have had its header decoded already by
 - * calling remoteDecodeClientMessageHeader
 - *
 - * Returns 0 if the message was dispatched, -1 upon fatal error
 - */
 -int
 -remoteDispatchClientRequest (struct qemud_server *server,
 - struct qemud_client *client,
 - struct qemud_client_message *msg)
 -{
 -int ret;
 -remote_error rerr;
 -
 -DEBUG(prog=%d ver=%d type=%d satus=%d serial=%d proc=%d,
 -  msg-hdr.prog, msg-hdr.vers, msg-hdr.type,
 -  msg-hdr.status, msg-hdr.serial, msg-hdr.proc);
 -
 -memset(rerr, 0, sizeof rerr);
 -
 -/* Check version, etc. */
 -if (msg-hdr.prog != REMOTE_PROGRAM) {
 -remoteDispatchFormatError (rerr,
 -   _(program mismatch (actual %x, expected 
 %x)),
 -   msg-hdr.prog, REMOTE_PROGRAM);
 -goto error;
 -}
 -if (msg-hdr.vers != REMOTE_PROTOCOL_VERSION) {
 -remoteDispatchFormatError (rerr,
 -   _(version mismatch (actual %x, expected 
 %x)),
 -   msg-hdr.vers, REMOTE_PROTOCOL_VERSION);
 -goto error;
 -}
 -
 -switch (msg-hdr.type) {
 -case REMOTE_CALL:
 -return remoteDispatchClientCall(server, client, msg);
 -
 -case REMOTE_STREAM:
 -/* Since stream data is non-acked, async, we may continue to received
 - * stream packets after we closed down a stream. Just drop  ignore
 - * these.
 - */
 -VIR_INFO(Ignoring unexpected stream data serial=%d proc=%d 
 status=%d,
 - msg-hdr.serial, msg-hdr.proc, msg-hdr.status);
 -qemudClientMessageRelease(client, msg);
 -break;
 -
 -default:
 -remoteDispatchFormatError (rerr, _(type (%d) != REMOTE_CALL),
 -   (int) msg-hdr.type);
 -goto error;
 -}
 -
 -return 0;
 -
 -error:
 -ret = remoteSerializeReplyError(client, rerr, msg-hdr);
 -
 -if (ret = 0)
 -VIR_FREE(msg);
 -
 -return ret;
 -}
 -
 -
  /*
   * @server: the unlocked server object
   * @client: the locked client object
 @@ -427,10 +348,11 @@ error:
   *
   * Returns 0 if the reply was sent, or -1 upon fatal error
   */
 -int
 +static int
  remoteDispatchClientCall (struct qemud_server *server,
struct qemud_client *client,
 -  struct qemud_client_message *msg)
 +  struct qemud_client_message *msg,
 +  int qemu_protocol)
  {
  XDR xdr;
  remote_error rerr;
 @@ -469,7 +391,10 @@ remoteDispatchClientCall (struct qemud_server *server,
  }
  }
  
 -data = remoteGetDispatchData(msg-hdr.proc);
 +if (qemu_protocol)
 +data = qemuGetDispatchData(msg-hdr.proc);
 +else
 

Re: [libvirt] [PATCH] Fix device_del in JSON mode for QEMU

2010-04-16 Thread Daniel Veillard
On Fri, Apr 16, 2010 at 11:53:06AM +0100, Daniel P. Berrange wrote:
 The 'device_del' command expects a parameter called 'id' but we
 were passing 'config'.
 
 * src/qemu/qemu_monitor_json.c: Fix device_del command parameter
 ---
  src/qemu/qemu_monitor_json.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
 index 001b32b..c3ed47c 100644
 --- a/src/qemu/qemu_monitor_json.c
 +++ b/src/qemu/qemu_monitor_json.c
 @@ -2021,7 +2021,7 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
  virJSONValuePtr reply = NULL;
  
  cmd = qemuMonitorJSONMakeCommand(device_del,
 - s:config, devalias,
 + s:id, devalias,
   NULL);
  if (!cmd)
  return -1;

  ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] Fix error reporting for getfd + host_net_add in QEMU

2010-04-16 Thread Daniel Veillard
On Fri, Apr 16, 2010 at 11:53:28AM +0100, Daniel P. Berrange wrote:
 If either of the getfd or host_net_add monitor commands return
 any text, this indicates an error condition. Don't ignore this!
 
 * src/qemu/qemu_monitor_text.c: Report errors for getfd and
   host_net_add
 ---
  src/qemu/qemu_monitor_text.c |   16 ++--
  1 files changed, 14 insertions(+), 2 deletions(-)
 
 diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
 index 48c9a54..6ad07b1 100644
 --- a/src/qemu/qemu_monitor_text.c
 +++ b/src/qemu/qemu_monitor_text.c
 @@ -1666,6 +1666,13 @@ int qemuMonitorTextSendFileHandle(qemuMonitorPtr mon,
  goto cleanup;
  }
  
 +if (STRNEQ(reply, )) {
 +qemuReportError(VIR_ERR_INTERNAL_ERROR,
 +_(unable to send TAP file handle: %s),
 +reply);
 +goto cleanup;
 +}
 +
  ret = 0;
  
  cleanup:
 @@ -1725,11 +1732,16 @@ int qemuMonitorTextAddHostNetwork(qemuMonitorPtr mon,
  
  if (qemuMonitorCommand(mon, cmd, reply)  0) {
  qemuReportError(VIR_ERR_OPERATION_FAILED,
 -_(failed to close fd in qemu with '%s'), cmd);
 +_(failed to add host net with '%s'), cmd);
  goto cleanup;
  }
  
 -/* XXX error messages here ? */
 +if (STRNEQ(reply, )) {
 +qemuReportError(VIR_ERR_INTERNAL_ERROR,
 +_(unable to add host net: %s),
 +reply);
 +goto cleanup;
 +}
  
  ret = 0;
  

  Plus an error logging fix,

ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] Fix network hotplug to use device_add in QEMU

2010-04-16 Thread Daniel Veillard
On Fri, Apr 16, 2010 at 11:53:52AM +0100, Daniel P. Berrange wrote:
 The initial boot of VMs uses -device for NICs where available. The
 corresponding monitor command is device_add, but the network hotplug
 code was still using device_del by mistake.

  Err it looks to me that the code is still using the old PCI add
instead of device_add but not device_del or I'm mistaken.

 * src/qemu/qemu_driver.c: Use device_add for NIC hotplug where
   available
 ---
  src/qemu/qemu_driver.c |   28 
  1 files changed, 20 insertions(+), 8 deletions(-)
 
 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
 index 5c15c1d..9e0a353 100644
 --- a/src/qemu/qemu_driver.c
 +++ b/src/qemu/qemu_driver.c
 @@ -7210,17 +7210,29 @@ static int qemudDomainAttachNetDevice(virConnectPtr 
 conn,
  close(tapfd);
  tapfd = -1;
  
 -if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
 -goto try_remove;
 +if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
 +if (!(nicstr = qemuBuildNicDevStr(net, vlan)))
 +goto try_remove;
 +} else {
 +if (!(nicstr = qemuBuildNicStr(net, NULL, vlan)))
 +goto try_remove;
 +}
  
  qemuDomainObjEnterMonitorWithDriver(driver, vm);
 -if (qemuMonitorAddPCINetwork(priv-mon, nicstr,
 - guestAddr)  0) {
 -qemuDomainObjExitMonitorWithDriver(driver, vm);
 -goto try_remove;
 +if (qemuCmdFlags  QEMUD_CMD_FLAG_DEVICE) {
 +if (qemuMonitorAddDevice(priv-mon, nicstr)  0) {
 +qemuDomainObjExitMonitorWithDriver(driver, vm);
 +goto try_remove;
 +}
 +} else {
 +if (qemuMonitorAddPCINetwork(priv-mon, nicstr,
 + guestAddr)  0) {
 +qemuDomainObjExitMonitorWithDriver(driver, vm);
 +goto try_remove;
 +}
 +net-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
 +memcpy(net-info.addr.pci, guestAddr, sizeof(guestAddr));
  }
 -net-info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
 -memcpy(net-info.addr.pci, guestAddr, sizeof(guestAddr));
  qemuDomainObjExitMonitorWithDriver(driver, vm);
  
  ret = 0;

  But patch looks fine to me !

ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] [PATCH] nwfilter: Clear all state tracking from a drop rule

2010-04-16 Thread Stefan Berger
Daniel P. Berrange berra...@redhat.com wrote on 04/16/2010 07:09:12 
AM:


 Please respond to Daniel P. Berrange
 
 On Fri, Apr 16, 2010 at 06:33:50AM -0400, Stefan Berger wrote:
  Don't use state-matching in a drop rule.
  
  Signed-off-by: Stefan Berger stef...@us.ibm.com
  
  Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
  ===
  --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c
  +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c
  @@ -1380,13 +1380,16 @@ _iptablesCreateRuleInstance(int directio
   return 0;
   }
  
  -if (match)
  -virBufferVSprintf(buf,  %s, match);
  -
   if (rule-action == VIR_NWFILTER_RULE_ACTION_ACCEPT)
   target = accept_target;
  -else
  +else {
   target = DROP;
  +match = NULL;
  +}
  +
  +if (match)
  +virBufferVSprintf(buf,  %s, match);
  +
  
   virBufferVSprintf(buf,
  -j %s CMD_DEF_POST CMD_SEPARATOR
  
 
 ACK
 
 Daniel

Pushed.

  Stefan

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

Re: [libvirt] [PATCH v2 2/2] Use virCheckFlags for APIs added in 0.8.0

2010-04-16 Thread Jiri Denemark
 I scanned through the patch, and didn't see any instances where we are
 calling virCheckFlags after non-trivial work.  It is something to be
 aware of when using the macro in the future, since:
 
 {
 ptr *foo = somethingThatMallocs();
 virCheckFlags(0, NULL);
 
 would be a memory leak, masked because the return is hidden inside the
 virCheckFlags macro.

Yes. I added a note to macro documentation to make this issue more visible.

 ACK.

And pushed, thanks.

Jirka

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


Re: [libvirt] [PATCH v2 1/2] Introduce virCheckFlags for consistent flags checking

2010-04-16 Thread Jiri Denemark
  The idea is that every API implementation in driver which has flags
  parameter should first call virCheckFlags() macro to check the function
  was called with supported flags:
  
  virCheckFlags(VIR_SUPPORTED_FLAG_1 |
VIR_SUPPORTED_FLAG_2 |
VIR_ANOTHER_SUPPORTED_FLAG, -1);
  
  The error massage which is printed when unsupported flags are passed
  looks like:
  
  invalid argument in virFooBar: unsupported flags (0x2)
  
  Where the unsupported flags part only prints those flags which were
  passed but are not supported rather than all flags passed.
  ---
   src/internal.h |   23 +++
 
 I like this location better than the v1 attempt.  ACK (but note my
 comments on Matthias' ESX patch, depending on which gets pushed first).

Thanks, I pushed the patch.

  +/**
  + * virCheckFlags:
  + * @supported: an OR'ed set of supported flags
 
 Is it worth documenting that this must be 'int' or 'unsigned int', and
 that the macro doesn't work on uint64_t?  Or maybe it's worth trying to
 figure out a way to refactor the macro to support both sizes?  But that
 can be a followup, if we find a case where we ever need a larger size
 for flags, so it shouldn't hold up committing this.

I left it as is for now as we only use (unsigned) int flags now. Once we add
an API with 64b flags we can enhance this macro.

Jirka

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


Re: [libvirt] [PATCH] esx: Add nwfilter driver stub

2010-04-16 Thread Jiri Denemark
  +static virDrvOpenStatus
  +esxNWFilterOpen(virConnectPtr conn,
  +virConnectAuthPtr auth ATTRIBUTE_UNUSED,
  +int flags ATTRIBUTE_UNUSED)
  +{
 
 If Jirka's patch for virCheckFlags goes in first, you need to tweak this
 line.  Otherwise, his patch needs to touch this new file when it is rebased.

Hmm, this is not a public API, it's just internal function used when opening a
driver. I didn't change such functions in other places and I didn't do that
for this one either. If we decide we want to check internal APIs as well, we
can add the check for all of them at once.

Jirka

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


[libvirt] [PATCH] Don't build nwfilter examples when not building libvirtd

2010-04-16 Thread Matthew Booth
 * Makefile.am: Make examples/xml/nwfilter conditional on WITH_LIBVIRTD
---
 Makefile.am |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dd334b5..40352c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,8 +5,11 @@ GENHTML = genhtml
 
 SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \
   python tests po examples/domain-events/events-c examples/hellolibvirt \
-  examples/dominfo examples/domsuspend examples/python examples/apparmor \
-  examples/xml/nwfilter
+  examples/dominfo examples/domsuspend examples/python examples/apparmor
+
+if WITH_LIBVIRTD
+  SUBDIRS += examples/xml/nwfilter
+endif
 
 ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4
 
-- 
1.6.6.1

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


Re: [libvirt] [PATCH] Don't build nwfilter examples when not building libvirtd

2010-04-16 Thread Daniel Veillard
On Fri, Apr 16, 2010 at 02:49:46PM +0100, Matthew Booth wrote:
  * Makefile.am: Make examples/xml/nwfilter conditional on WITH_LIBVIRTD
 ---
  Makefile.am |7 +--
  1 files changed, 5 insertions(+), 2 deletions(-)
 
 diff --git a/Makefile.am b/Makefile.am
 index dd334b5..40352c4 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -5,8 +5,11 @@ GENHTML = genhtml
  
  SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \
python tests po examples/domain-events/events-c examples/hellolibvirt \
 -  examples/dominfo examples/domsuspend examples/python examples/apparmor \
 -  examples/xml/nwfilter
 +  examples/dominfo examples/domsuspend examples/python examples/apparmor
 +
 +if WITH_LIBVIRTD
 +  SUBDIRS += examples/xml/nwfilter
 +endif
  
  ACLOCAL_AMFLAGS = -I m4 -I gnulib/m4
  

sounds fine,

ACK,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


Re: [libvirt] unable to set security context (NFSv4 problem?)

2010-04-16 Thread Spencer Shimko

Harald Dunkel wrote:

Hi folks,

Since I have moved the image file of a domain to an NFS
partition I get an error message at start time:

# virsh start mydomain
error: Failed to start domain mydomain
error: unable to set security context '110:140' on '/storage/mydomain/vda.img': 
Invalid argument


What is security_driver set to in /etc/libvirt/qemu.conf?

It appears to be the security driver trying to update the security 
context stored on the filesystem as an extended attribute.  The NFS v4 
filesystem currently lacks extended attribute support.  Without extended 
attributes there isn't a place to store the security context associated 
with the image file, hence the error.


I've CC'd James Morris who, in addition to working on the original 
libvirt security driver implementation, happens to be spearheading the 
NFS xattr support.  Hopefully he can provide some more information.




The /storage partition is mounted with these options:

# cat /proc/mounts  | grep /storage
nasl002:/storage/ /storage nfs4 
rw,relatime,vers=4,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.19.96.31,addr=172.19.96.213
 0 0

If I use a local disk instead, then there is no such
problem.


The fact that it works on local disk is likely attributable to the local 
filesystem supporting extended attributes.  Examples of these 
filesystems include ext2/3/4 and xfs.




libvirt is version 0.7.7-4, as included with Debian.
Any helpful comment would be highly appreciated.


Out of curiosity, are you using the SELinux support in Debian?

--Spencer



Regards

Harri



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


Re: [libvirt] unable to set security context (NFSv4 problem?)

2010-04-16 Thread James Morris
On Thu, 15 Apr 2010, Spencer Shimko wrote:

 Harald Dunkel wrote:
  Hi folks,
  
  Since I have moved the image file of a domain to an NFS
  partition I get an error message at start time:
  
  # virsh start mydomain
  error: Failed to start domain mydomain
  error: unable to set security context '110:140' on
  '/storage/mydomain/vda.img': Invalid argument
 
 What is security_driver set to in /etc/libvirt/qemu.conf?
 
 It appears to be the security driver trying to update the security context
 stored on the filesystem as an extended attribute.  The NFS v4 filesystem
 currently lacks extended attribute support.  Without extended attributes there
 isn't a place to store the security context associated with the image file,
 hence the error.
 
 I've CC'd James Morris who, in addition to working on the original libvirt
 security driver implementation, happens to be spearheading the NFS xattr
 support.  Hopefully he can provide some more information.

For NFSv4, we're working on adding security labeling directly to the 
protocol (local SELinux xattrs will be transported with this new 
protocol).  The IETF process is slowing it down significantly.

Because of this, I'm adding a simple xattr protocol to NFSv3, which should 
allow for server storage/retrieval of SELinux labels (but without 
security enforcement on the server).  Currently trying to get some 
technical issues agreed upon upstream and also now wiring up SELinux to 
the current code.  We're hoping to see this in RHEL 6.x.



  
  
  The /storage partition is mounted with these options:
  
  # cat /proc/mounts  | grep /storage
  nasl002:/storage/ /storage nfs4
  rw,relatime,vers=4,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=172.19.96.31,addr=172.19.96.213
  0 0
  
  If I use a local disk instead, then there is no such
  problem.
 
 The fact that it works on local disk is likely attributable to the local
 filesystem supporting extended attributes.  Examples of these filesystems
 include ext2/3/4 and xfs.
 
  
  libvirt is version 0.7.7-4, as included with Debian.
  Any helpful comment would be highly appreciated.
 
 Out of curiosity, are you using the SELinux support in Debian?
 
 --Spencer
  
  
  Regards
  
  Harri
  
 

-- 
James Morris
jmor...@redhat.com

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


Re: [libvirt] unable to set security context (NFSv4 problem?)

2010-04-16 Thread Spencer Shimko

Harald Dunkel wrote:

Hi folks,

On 04/15/10 22:06, Spencer Shimko wrote:
  

What is security_driver set to in /etc/libvirt/qemu.conf?




It is not set at all. AFAICS there is no man page for qemu.conf,
but according to KISS I had assumed that the security_driver
stuff is disabled by default. Is it?
  
According to the comments in qemu.conf on Fedora, if SELinux is enabled 
on the host then security_driver defaults to selinux.  This is probably 
the case on Debian too.
  

Out of curiosity, are you using the SELinux support in Debian?




For both NFS client and server:

selinux is enabled in the kernel. Debian's libselinux1 package
is installed, too, because it seems to be an essential dependency
for other packages. There are no selinux policies set up, and the
selinux-basics package is not installed, either.

Would you suggest to rebuild the kernel without selinux?
  
Run /usr/sbin/sestatus to reliably check the status of SELinux on your 
system.  If it reports SELinux status: enabled try setting the 
security_driver field to none.


--Spencer

(Apologies for any thread butchery that has occurred.  My initial 
response was from the wrong email account and didn't hit the list as a 
result.)

BTW, the NFS server uses reiserfs for its exported partitions.


Regards

Harri
  


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


[libvirt] [PATCH 1/6] Fake host CPU for qemu tests

2010-04-16 Thread Jiri Denemark
---
 tests/testutilsqemu.c |   30 +-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 8dd26d4..e0e5e14 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -6,6 +6,7 @@
 # include testutilsqemu.h
 # include testutils.h
 # include memory.h
+# include cpu_conf.h
 
 static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
 {
@@ -62,13 +63,40 @@ virCapsPtr testQemuCapsInit(void) {
 static const char *const xen_machines[] = {
 xenner
 };
+static virCPUFeatureDef host_cpu_features[] = {
+{ (char *) lahf_lm,   -1 },
+{ (char *) xtpr,  -1 },
+{ (char *) cx16,  -1 },
+{ (char *) tm2,   -1 },
+{ (char *) est,   -1 },
+{ (char *) vmx,   -1 },
+{ (char *) ds_cpl,-1 },
+{ (char *) pbe,   -1 },
+{ (char *) tm,-1 },
+{ (char *) ht,-1 },
+{ (char *) ss,-1 },
+{ (char *) acpi,  -1 },
+{ (char *) ds,-1 }
+};
+static virCPUDef host_cpu = {
+VIR_CPU_TYPE_HOST,  /* type */
+0,  /* match */
+(char *) x86_64,  /* arch */
+(char *) core2duo,/* model */
+1,  /* sockets */
+2,  /* cores */
+1,  /* threads */
+ARRAY_CARDINALITY(host_cpu_features), /* nfeatures */
+host_cpu_features   /* features */
+};
 
 uname (utsname);
 if ((caps = virCapabilitiesNew(utsname.machine,
0, 0)) == NULL)
 return NULL;
 
-if ((machines = testQemuAllocMachines(nmachines)) == NULL)
+if ((caps-host.cpu = virCPUDefCopy(host_cpu)) == NULL ||
+(machines = testQemuAllocMachines(nmachines)) == NULL)
 goto cleanup;
 
 if ((guest = virCapabilitiesAddGuest(caps, hvm, i686, 32,
-- 
1.7.0.4

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


[libvirt] [PATCH 4/6] Move MIN macro to util.h so that others can use it

2010-04-16 Thread Jiri Denemark
---
 src/util/util.c |4 
 src/util/util.h |4 
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/util.c b/src/util/util.c
index 268944d..99383d1 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -79,10 +79,6 @@
 # define NSIG 32
 #endif
 
-#ifndef MIN
-# define MIN(a, b) ((a)  (b) ? (a) : (b))
-#endif
-
 #define VIR_FROM_THIS VIR_FROM_NONE
 
 #define virUtilError(code, ...)\
diff --git a/src/util/util.h b/src/util/util.h
index 4f0b233..6bf6bcc 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -32,6 +32,10 @@
 # include sys/select.h
 # include sys/types.h
 
+# ifndef MIN
+#  define MIN(a, b) ((a)  (b) ? (a) : (b))
+# endif
+
 int saferead(int fd, void *buf, size_t count) ATTRIBUTE_RETURN_CHECK;
 ssize_t safewrite(int fd, const void *buf, size_t count)
 ATTRIBUTE_RETURN_CHECK;
-- 
1.7.0.4

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


[libvirt] [PATCH 3/6] Deal with CPU models in []

2010-04-16 Thread Jiri Denemark
Qemu committed a patch which list some CPU names in [] when asked for
supported CPUs (qemu -cpu ?). Yet, it needs such CPUs to be passed
without those square braces. When probing for supported CPU models, we
can just strip the square braces and pretend we have never seen them.
---
 src/qemu/qemu_conf.c |   17 +
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 0cbedf2..8577ff1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -628,7 +628,9 @@ typedef int
const char ***retcpus);
 
 /* Format:
- * arch model
+ *  arch model
+ * recent qemu encloses some model names in []:
+ *  arch [model]
  */
 static int
 qemudParseX86Models(const char *output,
@@ -661,15 +663,22 @@ qemudParseX86Models(const char *output,
 continue;
 
 if (retcpus) {
+unsigned int len;
+
 if (VIR_REALLOC_N(cpus, count + 1)  0)
 goto error;
 
 if (next)
-cpus[count] = strndup(p, next - p - 1);
+len = next - p - 1;
 else
-cpus[count] = strdup(p);
+len = strlen(p);
+
+if (len  2  *p == '['  p[len - 1] == ']') {
+p++;
+len -= 2;
+}
 
-if (!cpus[count])
+if (!(cpus[count] = strndup(p, len)))
 goto error;
 }
 count++;
-- 
1.7.0.4

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


[libvirt] [PATCH 0/6] CPU selection fixes and tests

2010-04-16 Thread Jiri Denemark
4 out of the 8 tests added by patch 2/6 fail with current libvirt. After
5/6 some of them pass and some of them fail in a different way. After
6/6 all of them pass.

Jirka

Jiri Denemark (6):
  Fake host CPU for qemu tests
  Tests for CPU selection in qemu driver
  Deal with CPU models in []
  Move MIN macro to util.h so that others can use it
  Support removing features when converting data to CPU
  Use configured CPU model if possible

 src/cpu/cpu.c  |8 +-
 src/cpu/cpu.h  |6 +-
 src/cpu/cpu_x86.c  |   82 +++-
 src/qemu/qemu_conf.c   |   39 --
 src/util/util.c|4 -
 src/util/util.h|4 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml |   28 +++
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact2.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml |   35 
 .../qemuxml2argv-cpu-minimum1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml |   21 +
 .../qemuxml2argv-cpu-minimum2.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml |   25 ++
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml  |   38 +
 .../qemuxml2argv-cpu-topology1.args|1 +
 .../qemuxml2argv-cpu-topology1.xml |   21 +
 .../qemuxml2argv-cpu-topology2.args|1 +
 .../qemuxml2argv-cpu-topology2.xml |   22 +
 .../qemuxml2argv-cpu-topology3.args|1 +
 .../qemuxml2argv-cpu-topology3.xml |   21 +
 tests/qemuxml2argvtest.c   |9 ++
 tests/testutilsqemu.c  |   30 +++-
 24 files changed, 362 insertions(+), 39 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml

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


[libvirt] [PATCH 6/6] Use configured CPU model if possible

2010-04-16 Thread Jiri Denemark
Adds ability to provide a preferred CPU model for CPUID data decoding.
Such model would be considered as the best possible model (if it's
supported by hypervisor) regardless on number of features which have to
be added or removed for describing required CPU.
---
 src/cpu/cpu.c|8 +---
 src/cpu/cpu.h|6 --
 src/cpu/cpu_x86.c|   11 +--
 src/qemu/qemu_conf.c |   10 --
 4 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index 4a1588d..580b767 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -127,11 +127,13 @@ int
 cpuDecode(virCPUDefPtr cpu,
   const union cpuData *data,
   const char **models,
-  unsigned int nmodels)
+  unsigned int nmodels,
+  const char *preferred)
 {
 struct cpuArchDriver *driver;
 
-VIR_DEBUG(cpu=%p, data=%p, nmodels=%u, cpu, data, nmodels);
+VIR_DEBUG(cpu=%p, data=%p, nmodels=%u, preferred=%s,
+  cpu, data, nmodels, NULLSTR(preferred));
 if (models) {
 unsigned int i;
 for (i = 0; i  nmodels; i++)
@@ -160,7 +162,7 @@ cpuDecode(virCPUDefPtr cpu,
 return -1;
 }
 
-return driver-decode(cpu, data, models, nmodels);
+return driver-decode(cpu, data, models, nmodels, preferred);
 }
 
 
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 1494a7f..40f2a7d 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -49,7 +49,8 @@ typedef int
 (*cpuArchDecode)(virCPUDefPtr cpu,
  const union cpuData *data,
  const char **models,
- unsigned int nmodels);
+ unsigned int nmodels,
+ const char *preferred);
 
 typedef int
 (*cpuArchEncode)(const virCPUDefPtr cpu,
@@ -108,7 +109,8 @@ extern int
 cpuDecode   (virCPUDefPtr cpu,
  const union cpuData *data,
  const char **models,
- unsigned int nmodels);
+ unsigned int nmodels,
+ const char *preferred);
 
 extern int
 cpuEncode   (const char *arch,
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 014fe7d..90ea509 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1064,7 +1064,8 @@ static int
 x86Decode(virCPUDefPtr cpu,
   const union cpuData *data,
   const char **models,
-  unsigned int nmodels)
+  unsigned int nmodels,
+  const char *preferred)
 {
 int ret = -1;
 struct x86_map *map;
@@ -1109,6 +1110,12 @@ x86Decode(virCPUDefPtr cpu,
 }
 }
 
+if (preferred  STREQ(cpuCandidate-model, preferred)) {
+virCPUDefFree(cpuModel);
+cpuModel = cpuCandidate;
+break;
+}
+
 if (cpuModel == NULL
 || cpuModel-nfeatures  cpuCandidate-nfeatures) {
 virCPUDefFree(cpuModel);
@@ -1356,7 +1363,7 @@ x86Baseline(virCPUDefPtr *cpus,
 if (!(data = x86DataFromModel(base_model)))
 goto no_memory;
 
-if (x86Decode(cpu, data, models, nmodels)  0)
+if (x86Decode(cpu, data, models, nmodels, NULL)  0)
 goto error;
 
 cleanup:
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a1392fa..e6e6490 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1029,7 +1029,7 @@ qemudCapsInitCPU(virCapsPtr caps,
 cpu-threads = nodeinfo.threads;
 
 if (!(data = cpuNodeData(arch))
-|| cpuDecode(cpu, data, NULL, 0)  0)
+|| cpuDecode(cpu, data, NULL, 0, NULL)  0)
 goto error;
 
 caps-host.cpu = cpu;
@@ -3292,6 +3292,7 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
 
 if (ncpus  0  host) {
 virCPUCompareResult cmp;
+const char *preferred;
 
 cmp = cpuGuestData(host, def-cpu, data);
 switch (cmp) {
@@ -3309,8 +3310,13 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
 if (VIR_ALLOC(guest)  0 || !(guest-arch = strdup(ut-machine)))
 goto no_memory;
 
+if (def-cpu-match == VIR_CPU_MATCH_MINIMUM)
+preferred = host-model;
+else
+preferred = def-cpu-model;
+
 guest-type = VIR_CPU_TYPE_GUEST;
-if (cpuDecode(guest, data, cpus, ncpus)  0)
+if (cpuDecode(guest, data, cpus, ncpus, preferred)  0)
 goto cleanup;
 
 virBufferVSprintf(buf, %s, guest-model);
-- 
1.7.0.4

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


[libvirt] [PATCH 5/6] Support removing features when converting data to CPU

2010-04-16 Thread Jiri Denemark
So far, when CPUID data were converted into CPU model and features, the
features can only be added to the model. As a result, when a guest asked
for something like qemu64,-svm it would get a qemu32 plus a bunch of
additional features instead.

This patch adds support for removing feature from the base model.
Selection algorithm remains the same: the best CPU model is the model
which requires lowest number of features to be added/removed from it.
---
 src/cpu/cpu_x86.c|   71 -
 src/qemu/qemu_conf.c |   12 +++-
 2 files changed, 62 insertions(+), 21 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 205528d..014fe7d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -27,6 +27,7 @@
 
 #include logging.h
 #include memory.h
+#include utils.h
 #include cpu.h
 #include cpu_map.h
 #include cpu_x86.h
@@ -211,6 +212,27 @@ x86DataCopy(const union cpuData *data)
 }
 
 
+static void
+x86DataSubtract(union cpuData *data1,
+const union cpuData *data2)
+{
+unsigned int i;
+unsigned int len;
+
+len = MIN(data1-x86.basic_len, data2-x86.basic_len);
+for (i = 0; i  len; i++) {
+x86cpuidClearBits(data1-x86.basic + i,
+  data2-x86.basic + i);
+}
+
+len = MIN(data1-x86.extended_len, data2-x86.extended_len);
+for (i = 0; i  len; i++) {
+x86cpuidClearBits(data1-x86.extended + i,
+  data2-x86.extended + i);
+}
+}
+
+
 static union cpuData *
 x86DataFromModel(const struct x86_model *model)
 {
@@ -282,24 +304,28 @@ x86DataToCPU(const union cpuData *data,
  const struct x86_map *map)
 {
 virCPUDefPtr cpu;
-union cpuData *tmp = NULL;
-unsigned int i;
+union cpuData *copy = NULL;
+union cpuData *modelData = NULL;
 
 if (VIR_ALLOC(cpu)  0 ||
-(cpu-model = strdup(model-name)) == NULL ||
-(tmp = x86DataCopy(data)) == NULL)
+!(cpu-model = strdup(model-name)) ||
+!(copy = x86DataCopy(data)) ||
+!(modelData = x86DataFromModel(model)))
 goto no_memory;
 
-for (i = 0; i  model-ncpuid; i++) {
-x86cpuidClearBits(x86DataCpuid(tmp, model-cpuid[i].function),
-  model-cpuid + i);
-}
+x86DataSubtract(copy, modelData);
+x86DataSubtract(modelData, data);
+
+/* because feature policy is ignored for host CPU */
+cpu-type = VIR_CPU_TYPE_GUEST;
 
-if (x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_REQUIRE, tmp, map))
+if (x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_REQUIRE, copy, map) ||
+x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_DISABLE, modelData, map))
 goto error;
 
 cleanup:
-x86DataFree(tmp);
+x86DataFree(modelData);
+x86DataFree(copy);
 return cpu;
 
 no_memory:
@@ -1045,8 +1071,7 @@ x86Decode(virCPUDefPtr cpu,
 const struct x86_model *candidate;
 virCPUDefPtr cpuCandidate;
 virCPUDefPtr cpuModel = NULL;
-struct cpuX86cpuid *cpuid;
-int i;
+unsigned int i;
 
 if (data == NULL || (map = x86LoadMap()) == NULL)
 return -1;
@@ -1055,13 +1080,6 @@ x86Decode(virCPUDefPtr cpu,
 while (candidate != NULL) {
 bool allowed = (models == NULL);
 
-for (i = 0; i  candidate-ncpuid; i++) {
-cpuid = x86DataCpuid(data, candidate-cpuid[i].function);
-if (cpuid == NULL
-|| !x86cpuidMatchMasked(cpuid, candidate-cpuid + i))
-goto next;
-}
-
 for (i = 0; i  nmodels; i++) {
 if (models  models[i]  STREQ(models[i], candidate-name)) {
 allowed = true;
@@ -1078,6 +1096,19 @@ x86Decode(virCPUDefPtr cpu,
 if (!(cpuCandidate = x86DataToCPU(data, candidate, map)))
 goto out;
 
+if (cpu-type == VIR_CPU_TYPE_HOST) {
+cpuCandidate-type = VIR_CPU_TYPE_HOST;
+for (i = 0; i  cpuCandidate-nfeatures; i++) {
+switch (cpuCandidate-features[i].policy) {
+case VIR_CPU_FEATURE_DISABLE:
+virCPUDefFree(cpuCandidate);
+goto next;
+default:
+cpuCandidate-features[i].policy = -1;
+}
+}
+}
+
 if (cpuModel == NULL
 || cpuModel-nfeatures  cpuCandidate-nfeatures) {
 virCPUDefFree(cpuModel);
@@ -1310,6 +1341,8 @@ x86Baseline(virCPUDefPtr *cpus,
 if (VIR_ALLOC(cpu)  0 ||
 !(cpu-arch = strdup(cpus[0]-arch)))
 goto no_memory;
+cpu-type = VIR_CPU_TYPE_GUEST;
+cpu-match = VIR_CPU_MATCH_EXACT;
 
 for (i = 1; i  ncpus; i++) {
 struct x86_model *model;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8577ff1..a1392fa 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -3309,12 +3309,20 @@ qemuBuildCpuArgStr(const struct qemud_driver *driver,
 if (VIR_ALLOC(guest)  0 || !(guest-arch = 

[libvirt] [PATCH 2/6] Tests for CPU selection in qemu driver

2010-04-16 Thread Jiri Denemark
---
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact1.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml |   28 ++
 .../qemuxml2argvdata/qemuxml2argv-cpu-exact2.args  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml |   35 ++
 .../qemuxml2argv-cpu-minimum1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml |   21 +++
 .../qemuxml2argv-cpu-minimum2.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml |   25 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.args |1 +
 .../qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml  |   38 
 .../qemuxml2argv-cpu-topology1.args|1 +
 .../qemuxml2argv-cpu-topology1.xml |   21 +++
 .../qemuxml2argv-cpu-topology2.args|1 +
 .../qemuxml2argv-cpu-topology2.xml |   22 +++
 .../qemuxml2argv-cpu-topology3.args|1 +
 .../qemuxml2argv-cpu-topology3.xml |   21 +++
 tests/qemuxml2argvtest.c   |9 +
 17 files changed, 228 insertions(+), 0 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-minimum2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-strict1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology1.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology2.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-topology3.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
new file mode 100644
index 000..e48672c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M 
pc -cpu qemu64,-svm,-lm,-nx,-syscall,-clflush,-pse36,-mca -m 214 -smp 6 
-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net 
none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
new file mode 100644
index 000..2538b1d
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
@@ -0,0 +1,28 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu6/vcpu
+  os
+type arch='x86_64' machine='pc'hvm/type
+boot dev='network'/
+  /os
+  cpu match='exact'
+modelqemu64/model
+feature policy='disable' name='svm'/
+feature policy='disable' name='lm'/
+feature policy='disable' name='nx'/
+feature policy='disable' name='syscall'/
+feature policy='disable' name='clflush'/
+feature policy='disable' name='pse36'/
+feature policy='disable' name='mca'/
+  /cpu
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+  emulator/usr/bin/qemu/emulator
+  /devices
+/domain
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
new file mode 100644
index 000..d418d51
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M 
pc -cpu core2duo,+lahf_lm,+3dnowext,+xtpr,+ds_cpl,+tm,+ht,+ds,-nx -m 214 -smp 6 
-nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -net 
none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml 
b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
new file mode 100644
index 000..db25a72
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
@@ -0,0 +1,35 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu6/vcpu
+  os
+type arch='x86_64' machine='pc'hvm/type
+boot dev='network'/
+  /os
+  cpu match='exact'
+

Re: [libvirt] [PATCH 0/6] CPU selection fixes and tests

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 4 out of the 8 tests added by patch 2/6 fail with current libvirt. After
 5/6 some of them pass and some of them fail in a different way. After
 6/6 all of them pass.

I would suggest that before pushing, you reorder the patches so that
'make check' passes for every stage of the patch series.  This makes
patch bisection easier in the future (if we are trying to hunt down a
regression, it's better if every commit builds independently).
Admittedly, it can look a bit odd seeing the commit that fixes the bug
before the commit that introduces the test, even though they were
developed in the opposite order, but you get used to it.  And 'git
rebase -i' makes it so easy to do.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

[libvirt] [PATCH] Mark internal.h for translation

2010-04-16 Thread Jiri Denemark
Patch for virCheckFlags added a message marked for translation into internal.h
without including that file in POTFILES.in. I've just pushed the following
patch.

Jirka

From 39f3fee4a48ef39a2baab25e306d94238d1e1361 Mon Sep 17 00:00:00 2001
Message-Id: 
39f3fee4a48ef39a2baab25e306d94238d1e1361.1271439006.git.jdene...@redhat.com
From: Jiri Denemark jdene...@redhat.com
Date: Fri, 16 Apr 2010 19:21:10 +0200
Subject: [PATCH] Mark internal.h for translation
Mail-Followup-To: libvir-list@redhat.com

---
 po/POTFILES.in |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 406e4c2..58e7358 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -25,6 +25,7 @@ src/esx/esx_vi_methods.c
 src/esx/esx_vi_types.c
 src/esx/esx_vmx.c
 src/interface/netcf_driver.c
+src/internal.h
 src/libvirt.c
 src/lxc/lxc_container.c
 src/lxc/lxc_controller.c
-- 
1.7.0.4


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


Re: [libvirt] [PATCH 0/6] CPU selection fixes and tests

2010-04-16 Thread Jiri Denemark
 I would suggest that before pushing, you reorder the patches so that
 'make check' passes for every stage of the patch series.  This makes
 patch bisection easier in the future (if we are trying to hunt down a
 regression, it's better if every commit builds independently).
 Admittedly, it can look a bit odd seeing the commit that fixes the bug
 before the commit that introduces the test, even though they were
 developed in the opposite order, but you get used to it.  And 'git
 rebase -i' makes it so easy to do.

Well, to be honest, I first fixed the bug and then created the tests to check
I don't regress somewhere else, to check the bug is really fix and for the
future :-) I reordered the patches before posting as they seemed more logical
this way. But I can reorder them back, no problem.

Jirka

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


Re: [libvirt] [PATCH 1/6] Fake host CPU for qemu tests

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 ---
  tests/testutilsqemu.c |   30 +-
  1 files changed, 29 insertions(+), 1 deletions(-)
 
 diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
 index 8dd26d4..e0e5e14 100644
 --- a/tests/testutilsqemu.c
 +++ b/tests/testutilsqemu.c
 @@ -6,6 +6,7 @@
  # include testutilsqemu.h
  # include testutils.h
  # include memory.h
 +# include cpu_conf.h
  
...

  
 -if ((machines = testQemuAllocMachines(nmachines)) == NULL)
 +if ((caps-host.cpu = virCPUDefCopy(host_cpu)) == NULL ||
 +(machines = testQemuAllocMachines(nmachines)) == NULL)
  goto cleanup;

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

Re: [libvirt] [PATCH 2/6] Tests for CPU selection in qemu driver

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact1.xml
 @@ -0,0 +1,28 @@
 +domain type='qemu'
 +  nameQEMUGuest1/name
 +  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid

 +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-exact2.xml
 @@ -0,0 +1,35 @@
 +domain type='qemu'
 +  nameQEMUGuest1/name
 +  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid

Is reusing the same UUID going to bite us later, especially when running
tests in parallel?

 +++ b/tests/qemuxml2argvtest.c
 @@ -346,6 +346,15 @@ mymain(int argc, char **argv)
  DO_TEST_FULL(restore-v2, QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC, exec:cat);
  DO_TEST_FULL(migrate, QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP, 
 tcp:10.0.0.1:5000);
  
 +DO_TEST(cpu-topology1, QEMUD_CMD_FLAG_SMP_TOPOLOGY);
 +DO_TEST(cpu-topology2, QEMUD_CMD_FLAG_SMP_TOPOLOGY);
 +DO_TEST(cpu-topology3, 0);
 +DO_TEST(cpu-minimum1, 0);
 +DO_TEST(cpu-minimum2, 0);
 +DO_TEST(cpu-exact1, 0);
 +DO_TEST(cpu-exact2, 0);
 +DO_TEST(cpu-strict1, 0);

I didn't spot anything blatantly unusual, although I'm not exactly sure
what I would be looking for.  Then again, I am assuming that since
everything passes when the entire series is applied, it certainly isn't
breaking anything to add new tests.  So,

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

Re: [libvirt] [PATCH 3/6] Deal with CPU models in []

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 Qemu committed a patch which list some CPU names in [] when asked for
 supported CPUs (qemu -cpu ?). Yet, it needs such CPUs to be passed
 without those square braces. When probing for supported CPU models, we
 can just strip the square braces and pretend we have never seen them.
 ---
  src/qemu/qemu_conf.c |   17 +
  1 files changed, 13 insertions(+), 4 deletions(-)
 
 diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
 index 0cbedf2..8577ff1 100644
 --- a/src/qemu/qemu_conf.c
 +++ b/src/qemu/qemu_conf.c
 @@ -628,7 +628,9 @@ typedef int
 const char ***retcpus);
  
  /* Format:
 - * arch model
 + *  arch model
 + * recent qemu encloses some model names in []:

This comment can go out of date.  Is it better to write something a bit
more time neutral, as in:

qemu version x.y.z encloses some model names in []:

 + *  arch [model]
   */
  static int
  qemudParseX86Models(const char *output,
 @@ -661,15 +663,22 @@ qemudParseX86Models(const char *output,
  continue;
  
  if (retcpus) {
 +unsigned int len;
 +
  if (VIR_REALLOC_N(cpus, count + 1)  0)
  goto error;
  
  if (next)
 -cpus[count] = strndup(p, next - p - 1);
 +len = next - p - 1;
  else
 -cpus[count] = strdup(p);
 +len = strlen(p);
 +
 +if (len  2  *p == '['  p[len - 1] == ']') {
 +p++;
 +len -= 2;
 +}
  
 -if (!cpus[count])
 +if (!(cpus[count] = strndup(p, len)))
  goto error;

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

Re: [libvirt] [PATCH 4/6] Move MIN macro to util.h so that others can use it

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 ---
  src/util/util.c |4 
  src/util/util.h |4 
  2 files changed, 4 insertions(+), 4 deletions(-)
 
 +++ b/src/util/util.h
 @@ -32,6 +32,10 @@
  # include sys/select.h
  # include sys/types.h
  
 +# ifndef MIN
 +#  define MIN(a, b) ((a)  (b) ? (a) : (b))
 +# endif

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

Re: [libvirt] [PATCH 5/6] Support removing features when converting data to CPU

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 So far, when CPUID data were converted into CPU model and features, the
 features can only be added to the model. As a result, when a guest asked
 for something like qemu64,-svm it would get a qemu32 plus a bunch of
 additional features instead.
 
 This patch adds support for removing feature from the base model.
 Selection algorithm remains the same: the best CPU model is the model
 which requires lowest number of features to be added/removed from it.

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

Re: [libvirt] [PATCH 6/6] Use configured CPU model if possible

2010-04-16 Thread Eric Blake
On 04/16/2010 11:01 AM, Jiri Denemark wrote:
 Adds ability to provide a preferred CPU model for CPUID data decoding.
 Such model would be considered as the best possible model (if it's
 supported by hypervisor) regardless on number of features which have to
 be added or removed for describing required CPU.

ACK.

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



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

Re: [libvirt] [RFC PATCH 3/5] Qemu remote protocol.

2010-04-16 Thread Chris Lalancette
On 04/16/2010 07:31 AM, Daniel P. Berrange wrote:
 --- a/daemon/libvirtd.h
 +++ b/daemon/libvirtd.h
 @@ -45,6 +45,7 @@
  # include rpc/types.h
  # include rpc/xdr.h
  # include remote_protocol.h
 +# include qemu_protocol.h
 
 I'm thinking this is possibly redundant - I feel it should be possible
 to just include it in either the remote.c or dispatch.c file where
 it is needed. Indeed the same probably applies for remote_protocol.h
 too

Unfortunately, with the way things stand now you have to include 
remote_protocol.h here.  libvirtd.h itself depends on the REMOTE_MESSAGE_MAX
and REMOTE_MESSAGE_HEADER_XDR_LEN defines, and dispatch.h includes libvirtd.h
to get access to the remote_error and remote_message_header structures.  I
could move just qemu_protocol.h out of here and into remote.c, but it seems
like remote_protocol.h and qemu_protocol.h remain logically together, so I
left this as-is for now.

I've incorporated the rest of your comments from this mail.

-- 
Chris Lalancette

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


Re: [libvirt] [RFC PATCH 2/5] Add namespace callback hooks to domain_conf.

2010-04-16 Thread Chris Lalancette
On 04/16/2010 07:20 AM, Daniel P. Berrange wrote:
 +
  /* Guest VM main configuration */
  typedef struct _virDomainDef virDomainDef;
  typedef virDomainDef *virDomainDefPtr;
 @@ -863,6 +876,9 @@ struct _virDomainDef {
  virSecurityLabelDef seclabel;
  virDomainWatchdogDefPtr watchdog;
  virCPUDefPtr cpu;
 +
 +void *namespaceData;
 +struct xmlNamespace ns;
  };
 
 As mentioned in the other patch reply, I think it'd be preferable to
 keep a struct with the parser config in virCapsPtr, so we don't need
 to add to this struct, nor pass it into all the parse/format methods.

I actually started out with this in the virCaps structure, but there was one
problem with that; at virDomainDefFree time, the caps pointer is *not* passed
in (nor is it stored in the virDomainDef structure), so you can't call the
namespace-specific free function.  So it was a choice between modifying all of
the callers of virDomainDefFree to pass in the virCaps structure, or modifying 
all
of the callers of the virDomainDefParse* to pass in the struct xmlNamespace 
callback
structure.  I chose the latter because logically the namespaceData does belong 
in
the virDomainDef structure, since it is part of the XML.

-- 
Chris Lalancette

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