Re: [libvirt] Here they

2010-10-04 Thread Justin Clift

On 10/04/2010 05:15 PM, arnaud.champ...@devatom.fr wrote:

Hi,

I think I can use the git to put sources. Daniel says that I have to put
some licences mentions on code these kind of thing, I have also to clean
up some code.


No worries.  Daniel speaks French, so that might be useful to know if
you are struggling with English at time. :)


 I have made an excel file to see what is done.

That's very good.  When you have the source code placed in git, we can
convert this to HTML and put it on the libvirt website so people know
where it is up to. :)


 I will try to make first check in in git this week.

Cool. :)

Regards and best wishes,

Justin Clift



Best regards,

ARnaud



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


Re: [libvirt] [PATCH v3 04/13] XML parsing for memory tunables

2010-10-04 Thread Nikunj A. Dadhania
On Mon, 4 Oct 2010 12:16:42 +0530, Balbir Singh bal...@linux.vnet.ibm.com 
wrote:
 * Nikunj A. Dadhania nik...@linux.vnet.ibm.com [2010-09-28 15:26:30]:
snip
  +/* Extract other memory tunables */
  +if (virXPathULong(string(./memtune/hard_limit), ctxt, 
  +  def-mem.hard_limit)  0) 
  +def-mem.hard_limit = 0;
  +
  +if (virXPathULong(string(./memtune/soft_limit[1]), ctxt, 
  +  def-mem.soft_limit)  0)
  +def-mem.soft_limit = 0;
  +
  +if (virXPathULong(string(./memtune/min_guarantee[1]), ctxt, 
  +  def-mem.min_guarantee)  0)
  +def-mem.min_guarantee = 0;
  +
  +if (virXPathULong(string(./memtune/swap_hard_limit[1]), ctxt, 
  +  def-mem.swap_hard_limit)  0)
  +def-mem.swap_hard_limit = 0;
  +
 
 Quick question, does 0 represent invalid values? 
If configuration file does not provide any value, we set this to 0, we
do not call the lower layer calls in this case.

 I'd presume you'd
 want to use something like -1. We support unsigned long long for the
 values to be set (64 bit signed), unlimited translates to 2^63 - 1, is
 ULong sufficient to represent that value?
The unit here is KB, so we can have till 2^42 bytes. So to answer you
question, no it does not represent 64 bit signed. I guess this should not be
an issue to support if needed.

I understand that in case of cgroup unlimited is (-1), but again that
would be cgroup specific at this level. I need to think of some way to address
this independent of the lower layer.

  +unsigned long hard_limit;
  +unsigned long soft_limit;
  +unsigned long min_guarantee;
  +unsigned long swap_hard_limit;
 
 The hard_limit, soft_limit, swap_hard_limit are s64 and the value is
 in bytes. What is the unit supported in this implementation?
KB

Thanks for reviewing.

Regard
Nikunj

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


Re: [libvirt] Valid characters in domain names?

2010-10-04 Thread Daniel Veillard
On Sun, Oct 03, 2010 at 11:51:12PM +1100, Justin Clift wrote:
 On 10/03/2010 08:33 PM, Richard W.M. Jones wrote:
 snip
 Indeed.  I'm sure we need a whitelist, not a blacklist as suggested by
 the other comment.  All domains I'd ever want to create would match
 the regexp
 
 ^[[:alpha:]][-_[:alnum:]]*$
 
 This might break existing users however.
 
 Wonder if there are characters supported by some hypervisors, but not
 others?

  I remember we had troubles with Xen, a long time ago, yes
So unfortunately this is really hypervsor specific... Maybe we could
have a generic checking routine but only providing a warning when
the name isn't a simple name the XML way. One of the problem of the
checking too is that most of the hypervisor APIs don't say a word about
encoding, so you're not manipulating characters but 0 terminated byte
strings. From there even your simple regexp goes havoc because what is
an alphanumeric character, requires character analysis and you need the
encoding for this. At least at libvirt API things are rather clear,
in XML data there is no ambiguity possible, and outside we expect
strings to be UTF-8.
  Actually I think that for ESX since all exchanges with the hypervisor
are XML based there isn't that ambiguity about encoding at least.

   ie maybe Xen supports '/', '*', '+' in guest names, but ESX doesn't
 
 That could lead to some interesting guest import problems. :(

  goes beyond that, someone using any non-ascii name will hit hypervisor
specific behaviour, ISO-Latin, asian language ... and we habe no control
over this except for some checking and the possibility of a warning.

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] Test results

2010-10-04 Thread Richard W.M. Jones
On Mon, Oct 04, 2010 at 09:35:35PM +1100, Justin Clift wrote:
 On 10/04/2010 09:26 PM, Richard W.M. Jones wrote:
 I tried creating several KVM domains with non-alnum names to see what
 actually happens.
 
 You forgot to mention which version of libvirt and KVM you're testing
 against?

Indeed I did forget.  It is:

libvirt-0.8.3-2.fc14.x86_64
qemu-0.13.0-0.7.rc1.fc14.x86_64

Pretty much the latest or almost the latest in Fedora 14.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.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: [libvirt] [PATCH] nwfilter: fix memory leaks

2010-10-04 Thread Stefan Berger

 On 10/04/2010 05:23 AM, Matthias Bolte wrote:

2010/10/2 Stefan Bergerstef...@linux.vnet.ibm.com:

  Fixing memory leak shown by valgrind and freeing buffer in two more places.

Signed-off-by: Stefan Bergerstef...@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
@@ -1508,7 +1508,11 @@ _iptablesCreateRuleInstance(int directio
 }

 if (virBufferUse(prefix)) {
-virBufferVSprintf(prefix, %s, virBufferContentAndReset(buf));
+char *s = virBufferContentAndReset(buf);
+
+virBufferVSprintf(prefix, %s, s);

You could simplify this to use virBufferAdd(prefix, s, -1) instead of
virBufferVSprintf.


Right, I changed that.

+
+VIR_FREE(s);

 final =prefix;

@@ -1531,11 +1535,13 @@ _iptablesCreateRuleInstance(int directio

  err_exit:
 virBufferFreeAndReset(buf);
+virBufferFreeAndReset(prefix);

 return -1;

  exit_no_error:
 virBufferFreeAndReset(buf);
+virBufferFreeAndReset(prefix);

 return 0;
  }


ACK.

Matthias

Pushed.
   Stefan

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


Re: [libvirt] Test results

2010-10-04 Thread Stefan Berger

 On 10/04/2010 07:44 AM, Richard W.M. Jones wrote:

I think realistically libvirt should prevent domains with / anywhere
in the name from being defined.

   at least for QEmu, yes

Also, Justin Clift raised with me the issue of what happens if someone
creates a domain called 'autostart/foo.xml' or 'networks/foo.xml' or
'networks/autostart/foo.xml'.  The configuration files for these would
work and overwrite special paths under /etc/libvirt/qemu.



It looks like a domain (and likely anything else that has a 'name') 
whose name contains a ';' or spaces is unaccessible from virsh unless 
one finds out the uuid ,which only root can do(?). Probably this is only 
a problem when using virsh, but maybe the user should be given the 
choice to delete the VM (in that special case) or at least also display 
its uuid upon 'virsh define/create' so he has a chance to actually 
use/delete it.


   Stefan


Rich.



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


Re: [libvirt] virt-install feature request

2010-10-04 Thread Cole Robinson

FYI, virt-install/virt-manager are discussed primarily on
virt-tools-l...@redhat.com

On 10/01/2010 04:19 PM, Stanley, Jon [Tech] wrote:
 So virt-install is a really nice piece of software, but it's a bit too 
 complicated for our use case :).
 
 We would want some mode of it to simply generate XML and go home :).  The use 
 case is that we have a script which carries out a number of other actions in 
 addition to creating a guest, and creating a guest and putting an OS on it 
 are two separate steps.
 

Historically we've resisted adding such an option because most install
scenarios generate more than 1 XML configuration. For example, non-windows
CDROM installs generate 1 configuration for booting from CDROM media, and a
final configuration set to boot from disk. There is also the problem of URL
installs downloading temporary media like kernel/initrd. Basically anything
that has an actual install phase.

Nowadays though we have options like --import and --boot that don't really
install anything, so --xml-only would be more useful. We could also print a
descriptive error if the user tries to use the option with a URL or CDROM 
install.

Additionally we could add an option for virt-install to install an OS into an
existing VM. So your sequence of events could be

virt-install typical options --boot hd --xml-only  foo.xml
extra pre-install config
virt-install --reinstall-xml foo.xml --location http://example.com/distro

 It would also be nice to have some command line interface to modify a guest's 
 boot selection, for example, changing from PXE to local disk.  Even nicer 
 would be a concept of boot order - we have a setup where the first normal 
 boot order is PXE, and if that fails (which it should a majority of the time) 
 then go to local disk.
 

Libvirt supports setting a boot order, just specify multiple boot dev=/
elements in the desired order. Latest virt-install allows setting this with
the --boot option.

Also, a new tool is forthcoming that will provide the existing virt-install
options (where applicable) for use against an existing domain or XML input. So
to change the boot device of an existing domain to local disk, a possible
invocation might look like

virt-xml --domain $vmname --boot hd

The tool doesn't exist yet, but all the plumbing is their in virtinst for it
to be a pretty straightforward job. Of course, any assistance would be
appreciated :)

- Cole

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


Re: [libvirt] [PATCH v3 05/13] Implement cgroup memory controller tunables

2010-10-04 Thread Balbir Singh
* Nikunj A. Dadhania nik...@linux.vnet.ibm.com [2010-09-28 15:26:35]:

 From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com
 
 Provides interfaces for setting/getting memory tunables like hard_limit,
 soft_limit and swap_hard_limit
 
 Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com

The changes look good to me. unsigned long kb should cover all values
in bytes as well.

Acked-by: Balbir Singh bal...@linux.vnet.ibm.com
 

-- 
Three Cheers,
Balbir

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


Re: [libvirt] [PATCH v3 04/13] XML parsing for memory tunables

2010-10-04 Thread Balbir Singh
* Nikunj A. Dadhania nik...@linux.vnet.ibm.com [2010-09-28 15:26:30]:

 From: Nikunj A. Dadhania nik...@linux.vnet.ibm.com
 
 Adding parsing code for memory tunables in the domain xml file
 
 v2:
 + Fix typo min_guarantee
 
 Signed-off-by: Nikunj A. Dadhania nik...@linux.vnet.ibm.com
 ---
  src/conf/domain_conf.c |   50 
 +---
  src/conf/domain_conf.h |   12 ---
  src/esx/esx_vmx.c  |   30 +-
  src/lxc/lxc_controller.c   |2 +-
  src/lxc/lxc_driver.c   |   12 +--
  src/openvz/openvz_driver.c |8 ---
  src/qemu/qemu_conf.c   |8 ---
  src/qemu/qemu_driver.c |   18 
  src/test/test_driver.c |   12 +--
  src/uml/uml_conf.c |2 +-
  src/uml/uml_driver.c   |   14 ++--
  11 files changed, 104 insertions(+), 64 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index e05d5d7..0dd74e4 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -4231,19 +4231,38 @@ static virDomainDefPtr 
 virDomainDefParseXML(virCapsPtr caps,
  def-description = virXPathString(string(./description[1]), ctxt);
 
  /* Extract domain memory */
 -if (virXPathULong(string(./memory[1]), ctxt, def-maxmem)  0) {
 +if (virXPathULong(string(./memory[1]), ctxt, 
 +  def-mem.max_balloon)  0) {
  virDomainReportError(VIR_ERR_INTERNAL_ERROR,
   %s, _(missing memory element));
  goto error;
  }
 
 -if (virXPathULong(string(./currentMemory[1]), ctxt, def-memory)  0)
 -def-memory = def-maxmem;
 +if (virXPathULong(string(./currentMemory[1]), ctxt, 
 +  def-mem.cur_balloon)  0)
 +def-mem.cur_balloon = def-mem.max_balloon;
 
  node = virXPathNode(./memoryBacking/hugepages, ctxt);
  if (node)
 -def-hugepage_backed = 1;
 -
 +def-mem.hugepage_backed = 1;
 +
 +/* Extract other memory tunables */
 +if (virXPathULong(string(./memtune/hard_limit), ctxt, 
 +  def-mem.hard_limit)  0) 
 +def-mem.hard_limit = 0;
 +
 +if (virXPathULong(string(./memtune/soft_limit[1]), ctxt, 
 +  def-mem.soft_limit)  0)
 +def-mem.soft_limit = 0;
 +
 +if (virXPathULong(string(./memtune/min_guarantee[1]), ctxt, 
 +  def-mem.min_guarantee)  0)
 +def-mem.min_guarantee = 0;
 +
 +if (virXPathULong(string(./memtune/swap_hard_limit[1]), ctxt, 
 +  def-mem.swap_hard_limit)  0)
 +def-mem.swap_hard_limit = 0;
 +

Quick question, does 0 represent invalid values? I'd presume you'd
want to use something like -1. We support unsigned long long for the
values to be set (64 bit signed), unlimited translates to 2^63 - 1, is
ULong sufficient to represent that value?

  if (virXPathULong(string(./vcpu[1]), ctxt, def-vcpus)  0)
  def-vcpus = 1;
 
 @@ -6382,10 +6401,25 @@ char *virDomainDefFormat(virDomainDefPtr def,
  virBufferEscapeString(buf,   description%s/description\n,
def-description);
 
 -virBufferVSprintf(buf,   memory%lu/memory\n, def-maxmem);
 +virBufferVSprintf(buf,   memory%lu/memory\n, 
 def-mem.max_balloon);
  virBufferVSprintf(buf,   currentMemory%lu/currentMemory\n,
 -  def-memory);
 -if (def-hugepage_backed) {
 +  def-mem.cur_balloon);
 +virBufferVSprintf(buf,   memtune\n);
 +if (def-mem.hard_limit) {
 +virBufferVSprintf(buf, hard_limit%lu/hard_limit\n, 
 +  def-mem.hard_limit);
 +}
 +if (def-mem.soft_limit) {
 +virBufferVSprintf(buf, soft_limit%lu/soft_limit\n, 
 +  def-mem.soft_limit);
 +}
 +if (def-mem.swap_hard_limit) {
 +virBufferVSprintf(buf, 
 swap_hard_limit%lu/swap_hard_limit\n, 
 +  def-mem.swap_hard_limit);
 +}
 +virBufferVSprintf(buf,   /memtune\n);
 +
 +if (def-mem.hugepage_backed) {
  virBufferAddLit(buf,   memoryBacking\n);
  virBufferAddLit(buf, hugepages/\n);
  virBufferAddLit(buf,   /memoryBacking\n);
 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
 index 7195c04..2ecc2af 100644
 --- a/src/conf/domain_conf.h
 +++ b/src/conf/domain_conf.h
 @@ -864,9 +864,15 @@ struct _virDomainDef {
  char *name;
  char *description;
 
 -unsigned long memory;
 -unsigned long maxmem;
 -unsigned char hugepage_backed;
 +struct {
 +unsigned long max_balloon;
 +unsigned long cur_balloon;
 +unsigned long hugepage_backed;
 +unsigned long hard_limit;
 +unsigned long soft_limit;
 +unsigned long min_guarantee;
 +unsigned long swap_hard_limit;

The hard_limit, soft_limit, swap_hard_limit are s64 and the value is
in bytes. What is 

Re: [libvirt] Test results (was: Re: Valid characters in domain names?)

2010-10-04 Thread Richard W.M. Jones
A few more:

*** namequot;/name ***
 
virsh define - OK
virsh list - OK
virsh start - FAILED
virt-viewer - n/a
virt-df - see below
virsh destroy - n/a
virt-list-filesystems - OK

I'm fairly sure this is not a shell error:

  $ sudo virsh start \
  error: missing 

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

virt-df is fine, but virt-df --csv doesn't properly quote the output.

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

*** name;/name ***
 
virsh define - OK
virsh list - OK
virsh start - FAILED
virt-viewer - n/a
virt-df - OK
virsh destroy - n/a
virt-list-filesystems - OK

I'm fairly sure this is not a shell error:

  $ sudo virsh start \;
  error: command 'start' requires domain option
  $ sudo virsh start ';'
  error: command 'start' requires domain option

I thought it might be a problem with sudo, so I also tried:

  $ su
  # virsh start ';'
  error: command 'start' requires domain option

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

*** name\/name ***
 
virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

*** name|/name ***
 
virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.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: [libvirt] Test results (was: Re: Valid characters in domain names?)

2010-10-04 Thread Richard W.M. Jones
On Mon, Oct 04, 2010 at 01:07:40PM +0200, Daniel Veillard wrote:
   assuming a QEmu/KVM guest, right ?

Yes.

  virsh start failed with the error:
  
error: Failed to start domain ,
error: internal error process exited while connecting to monitor: Unknown 
  subargument  to -name
  
  This looks like a real bug.  The qemu driver should prevent domains
  from being created that contain characters that are special for the
  qemu command line.
 
   okay, we should make a bug

Already done: https://bugzilla.redhat.com/show_bug.cgi?id=639926

qemu: could not open disk image /: Is a directory
unexpected end of file when reading from daemon at 
  /usr/bin/virt-list-filesystems line 131.
  
  I think realistically libvirt should prevent domains with / anywhere
  in the name from being defined.
 
   at least for QEmu, yes

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

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.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: [libvirt] Test results (was: Re: Valid characters in domain names?)

2010-10-04 Thread Daniel Veillard
On Mon, Oct 04, 2010 at 11:26:32AM +0100, Richard W.M. Jones wrote:
 I tried creating several KVM domains with non-alnum names to see what
 actually happens.
 
 The names as shown here are XML-encoded, ie. they are how they appear
 in the libvirt domain XML.
 
 *** name#x00;/name ***
 
 libvirt prevents me from defining this domain, with the following error:
 
   error: Failed to define domain from /tmp/chars.xml
   error: at line 2: xmlParseCharRef: invalid xmlChar value 0
 
 Am I specifying the XML correctly?

  Forbidden character in XML, we just can't use this.
http://www.w3.org/TR/REC-xml/#NT-Char defines the allowed character
ranges, bizarre control characters from start of ASCII are forbidden
not just 0, surrogates and values usually used as Byte Order Mark are
also excluded. And this is a Good Thing (TM) :-)

 *** name#/name ***
 
 virsh define - OK
 virsh list - OK
 virsh start - OK
 virt-viewer - OK
 virt-df - OK
 virsh destroy - OK
 virt-list-filesystems - OK

  assuming a QEmu/KVM guest, right ?

 Conclusion: RHBZ#639601 and RHBZ#639602 are just user error.  The
 reporter is typing something like:
 
   virt-list-filesystems #
 
 but the shell takes the # character as a comment.  If instead you do:
 
   virt-list-filesystems '#'
 
 or
 
   virt-list-filesystems \#
 
 then it works fine.
 
 *** name,/name ***
 
 virsh define - OK
 virsh list - OK
 virsh start - FAILED
 virt-viewer - n/a
 virt-df - OK
 virsh destroy - n/a
 virt-list-filesystems - OK
 
 virsh start failed with the error:
 
   error: Failed to start domain ,
   error: internal error process exited while connecting to monitor: Unknown 
 subargument  to -name
 
 This looks like a real bug.  The qemu driver should prevent domains
 from being created that contain characters that are special for the
 qemu command line.

  okay, we should make a bug

 *** namegt;/name ***
 
 virsh define - OK
 virsh list - OK
 virsh start - OK
 virt-viewer - OK
 virt-df - OK
 virsh destroy - OK
 virt-list-filesystems - OK

  I'm rather surprized this didn't break qemu execution, interesting...

 *** name変な/name ***
 
 virsh define - OK
 virsh list - see below
 virsh start - OK
 virt-viewer - OK
 virt-df - OK
 virsh destroy - OK
 virt-list-filesystems - OK
 
 'virsh list' command is fine, except the 'State' columns don't line up
 because these two characters are wide chars.  You see something like
 this:
 
   - Win7x32  shut off
   - [][]   shut off

 minor really, I would count this as a pass,

 *** name//name ***
 
 virsh define - OK
 virsh list - OK
 virsh start - see below
 virt-viewer - OK
 virt-df - FAILED
 virsh destroy - OK
 virt-list-filesystems - FAILED
 
 The domain starts OK, but the log file is created as
 /var/log/libvirt/qemu/.log.  This is a bug, although sort of to be
 expected.
 
 virt-df and virt-list-filesystems both failed.  This was because these
 programs use a heuristic to determine if the parameter passed is a
 libvirt domain name or a local disk image file.  Because / looks (a
 bit) like a local file, it tries to open it as such and fails.  The
 error message is:
 
   qemu: could not open disk image /: Is a directory
   unexpected end of file when reading from daemon at 
 /usr/bin/virt-list-filesystems line 131.
 
 I think realistically libvirt should prevent domains with / anywhere
 in the name from being defined.

  at least for QEmu, yes

 *** name:/name ***
 
 virsh define - OK
 virsh list - OK
 virsh start - OK
 virt-viewer - OK
 virt-df - OK
 virsh destroy - OK
 virt-list-filesystems - OK
 

  Thanks for doing this, we actually did better than I expected :-)

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] Test results (was: Re: Valid characters in domain names?)

2010-10-04 Thread Richard W.M. Jones
*** namea/b/name ***

virsh define - FAILED

error: Failed to define domain from /tmp/chars.xml
error: cannot create config file '/etc/libvirt/qemu/a/b.xml': No such file or 
directory

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming blog: http://rwmj.wordpress.com
Fedora now supports 80 OCaml packages (the OPEN alternative to F#)
http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora

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


[libvirt] Test results (was: Re: Valid characters in domain names?)

2010-10-04 Thread Richard W.M. Jones
I tried creating several KVM domains with non-alnum names to see what
actually happens.

The names as shown here are XML-encoded, ie. they are how they appear
in the libvirt domain XML.

*** name#x00;/name ***

libvirt prevents me from defining this domain, with the following error:

  error: Failed to define domain from /tmp/chars.xml
  error: at line 2: xmlParseCharRef: invalid xmlChar value 0

Am I specifying the XML correctly?

*** name#/name ***

virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

Conclusion: RHBZ#639601 and RHBZ#639602 are just user error.  The
reporter is typing something like:

  virt-list-filesystems #

but the shell takes the # character as a comment.  If instead you do:

  virt-list-filesystems '#'

or

  virt-list-filesystems \#

then it works fine.

*** name,/name ***

virsh define - OK
virsh list - OK
virsh start - FAILED
virt-viewer - n/a
virt-df - OK
virsh destroy - n/a
virt-list-filesystems - OK

virsh start failed with the error:

  error: Failed to start domain ,
  error: internal error process exited while connecting to monitor: Unknown 
subargument  to -name

This looks like a real bug.  The qemu driver should prevent domains
from being created that contain characters that are special for the
qemu command line.

*** namegt;/name ***

virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

*** name変な/name ***

virsh define - OK
virsh list - see below
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

'virsh list' command is fine, except the 'State' columns don't line up
because these two characters are wide chars.  You see something like
this:

  - Win7x32  shut off
  - [][]   shut off

*** name//name ***

virsh define - OK
virsh list - OK
virsh start - see below
virt-viewer - OK
virt-df - FAILED
virsh destroy - OK
virt-list-filesystems - FAILED

The domain starts OK, but the log file is created as
/var/log/libvirt/qemu/.log.  This is a bug, although sort of to be
expected.

virt-df and virt-list-filesystems both failed.  This was because these
programs use a heuristic to determine if the parameter passed is a
libvirt domain name or a local disk image file.  Because / looks (a
bit) like a local file, it tries to open it as such and fails.  The
error message is:

  qemu: could not open disk image /: Is a directory
  unexpected end of file when reading from daemon at 
/usr/bin/virt-list-filesystems line 131.

I think realistically libvirt should prevent domains with / anywhere
in the name from being defined.

*** name:/name ***

virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

  * * *

I will file bugs for the above issues.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/

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

Re: [libvirt] Test results

2010-10-04 Thread Justin Clift

On 10/04/2010 09:26 PM, Richard W.M. Jones wrote:

I tried creating several KVM domains with non-alnum names to see what
actually happens.


You forgot to mention which version of libvirt and KVM you're testing
against?

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


Re: [libvirt] Test results (was: Re: Valid characters in domain names?)

2010-10-04 Thread Richard W.M. Jones

There are also some obvious ones I missed before:

*** name-/name ***

virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

Note to start it you need:

  sudo virsh -- start -

For virt-df you need:

  sudo virt-df -- -

and similarly for other virt tools.

The qemu command line is:

  /usr/bin/qemu-kvm -S -M fedora-13 -enable-kvm -m 256 -smp 
1,sockets=1,cores=1,threads=1 -name - -uuid [...]

which I was a bit surprised by.  I guess qemu's command line parsing
is quite ad hoc.

*** namenbsp;/name ***

error: Failed to define domain from /tmp/chars.xml
error: at line 2: Entity 'nbsp' not defined

*** name#xa0;/name ***

Note that U+00A0 is Unicode non-breaking space.

virsh define - OK(!)
virsh list - OK(!)
virsh start - OK(!)
virt-viewer - OK(!)
virt-df - OK(!)
virsh destroy - OK(!)
virt-list-filesystems - OK(!)

This is very surprising, but it all does work.

  $ sudo virsh destroy ' '
  Domain   destroyed
  $ sudo virt-df ' '
  Filesystem   1K-blocks   Used  Available  Use%
   :/dev/sda1 31725396  296912%

Let's go a step further down this whitespace road:

*** name /name ***

virsh define - OK(!)
virsh list - OK(!)
virsh start - FAILED
virt-viewer - n/a
virt-df - OK(!)
virsh destroy - n/a
virt-list-filesystems - OK(!)

  $ sudo virsh start ' '
  error: command 'start' requires domain option
  $ sudo virt-df ' '
  Filesystem   1K-blocks   Used  Available  Use%
   :/dev/sda1  31725396  296912%

*** name#x7f;/name ***

virsh define - OK
virsh list - OK
virsh start - OK
virt-viewer - OK
virt-df - OK
virsh destroy - OK
virt-list-filesystems - OK

This one is tricky to test.  You can't type or copy this character.
However if you create a file containing this character then you can
do:

  $ sudo virsh start $(cat /tmp/del)
  Domain started

etc and I was able to verify that all the commands above work fine.

I haven't filed any more bugs for these ones.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html

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


Re: [libvirt] [PATCH 2/4] xen: Fix logic bug in xenDaemon*DeviceFlags

2010-10-04 Thread Jiri Denemark
  ---
src/xen/xend_internal.c |   15 +--
1 files changed, 9 insertions(+), 6 deletions(-)
 
  diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
  index 1318bd4..4fba6af 100644
  --- a/src/xen/xend_internal.c
  +++ b/src/xen/xend_internal.c
  @@ -3904,8 +3904,9 @@ xenDaemonAttachDeviceFlags(virDomainPtr domain, const 
  char *xml,
/* Xen only supports modifying both live and persistent config if
 * xendConfigVersion= 3
 */
  -if (flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
  -  VIR_DOMAIN_DEVICE_MODIFY_CONFIG)) {
  +if (priv-xendConfigVersion= 3
  +(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
  +   VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, %s,
 _(Xend only supports modifying both live and 
   persistent config));
 
 The comment says:
 
 _LIVE|_CONFIG is supported only if version=3

 logically, this tells me nothing about version  3, nor about setting 
 one but not both flags.

Not really, the comment say that version = 3 means only _LIVE|_CONFIG is
supported, nothing else.

 Meanwhile, the code says:
 
 if version =3, _LIVE|_CONFIG is the only supported combo

Which is exactly what the comment says IMHO.

 Are we sure this is the right change?  What happens with version  3?

With a slightly more context the code looks as follows:

/* Only live config can be changed if xendConfigVersion  3 */
if (priv-xendConfigVersion  3 
(flags != VIR_DOMAIN_DEVICE_MODIFY_CURRENT 
 flags != VIR_DOMAIN_DEVICE_MODIFY_LIVE)) {
virXendError(VIR_ERR_OPERATION_INVALID, %s,
 _(Xend version does not support modifying 
   persistent config));
return -1;
}
/* Xen only supports modifying both live and persistent config if
 * xendConfigVersion = 3
 */
if (priv-xendConfigVersion = 3 
(flags != (VIR_DOMAIN_DEVICE_MODIFY_LIVE |
   VIR_DOMAIN_DEVICE_MODIFY_CONFIG))) {
virXendError(VIR_ERR_OPERATION_INVALID, %s,
 _(Xend only supports modifying both live and 
   persistent config));
return -1;
}

That is, version  3 is already taken care of in the previous condition. The
only issue is that the code ignores _CURRENT for version = 3, it should
rather allow _CONFIG  (_LIVE || _CURRENT). Otherwise, it seems correct to
me.

 It seems like we need a 12-way table (in fact, this is pretty much what 
 I ended up resorting to with my vcpus stuff).  Here's my shot at it, 
 from reading the comments (but not actually testing it); once we fix 
 this attempt to an actual table, then I can answer whether the code 
 matches the table.
 
_LIVE _CONFIG  _LIVE|_CONFIG
 xen 2,running good  unsupported  unsupported
 xen 2,inactiveerror good error or silently good
 xen 3,running good  good good
 xen 3,inactiveerror good error or silently good

Yeah, this is probably a good idea however we shouldn't forget about _CURRENT
which is an equivalent of either _CONFIG or _LIVE depending on current state
of the guest.

Jirka

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


Re: [libvirt] Valid characters in domain names?

2010-10-04 Thread Justin Clift

On 10/05/2010 03:03 AM, Paolo Bonzini wrote:

On 10/03/2010 11:33 AM, Richard W.M. Jones wrote:

Indeed. I'm sure we need a whitelist, not a blacklist as suggested by
the other comment. All domains I'd ever want to create would match
the regexp

^[[:alpha:]][-_[:alnum:]]*$

This might break existing users however.


A period in a name is definitely useful. Also, I think there is no need
to differentiate between the first and the other characters, except
perhaps to prohibit a name starting with -.


Heh.  Two periods in a name could lead to fun.  Stuff like:

  name=../../../etc/shadow

Well, you know what I mean. :)

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


Re: [libvirt] Valid characters in domain names?

2010-10-04 Thread Paolo Bonzini

On 10/04/2010 06:31 PM, Justin Clift wrote:


Heh.  Two periods in a name could lead to fun.  Stuff like:

   name=../../../etc/shadow

Well, you know what I mean. :)


Not if you prohibit / though...

Paolo

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


Re: [libvirt] [PATCH] configure: disable network and storage-fs drivers on mac os x

2010-10-04 Thread Eric Blake

On 10/04/2010 06:57 AM, Justin Clift wrote:

+with_linux=no
+with_osx=no
  case $host in
*-*-linux*)
  # match linux here so the *) case will match anything non-linux
+with_linux=yes
  ;;
*)
+case $host in
+  *-*-darwin*)
+with_osx=yes
+;;
+esac

   if test x$with_lxc != xyes

Hmm; the nested case $host seems odd to me.  Maybe a better layout is:

with_linux=no with_osx=no
case $host in
  *-*-linux*) with_linux=yes ;;
  *-*-darwin*) with_osx=yes ;;
esac
if $with_linux = no; then
  if test x$with_lxc != xyes
...
fi


That is, use only a single host-detection case statement, and rely on 
the results of that for future checks, rather than mixing host-detection 
and actions based on host-detection into a nested case statement.


And yes, I trimmed out some of the redundant  from the shell code in 
the example above (the shell word after case does not need  unless it 
contains shell metacharacters to be taken literally, because it is not 
subject to field splitting; and $with_linux is exactly 'yes' or 'no' at 
the point where it is checked, so it is a safe expansion without quotes; 
whereas $with_lxc is user-provided and might begin with - or contain 
whitespace).



  AC_ARG_WITH([network],
AC_HELP_STRING([--with-network], [with virtual network driver 
@:@default=yes@:@]),[],[with_network=yes])
-if test $with_libvirtd = no ; then
+
+dnl theres no use compiling the network driver without the libvirt


s/theres/there's/


+dnl daemon, nor compiling it for MacOS X, where it breaks the compile
+
+if test $with_libvirtd = no || test $with_osx = yes; then
with_network=no
  fi


Mostly looks okay, but probably worth a v2 to make sure the 
$host-detection case statement rewrite is still good.


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

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


Re: [libvirt] [PATCH] configure: disable network and storage-fs drivers on mac os x

2010-10-04 Thread Justin Clift

On 10/05/2010 04:07 AM, Eric Blake wrote:
snip

Hmm; the nested case $host seems odd to me. Maybe a better layout is:

with_linux=no with_osx=no
case $host in
*-*-linux*) with_linux=yes ;;
*-*-darwin*) with_osx=yes ;;
esac
if $with_linux = no; then
if test x$with_lxc != xyes
...
fi


Ahhh, that's a much better idea.  Will do. :)



AC_ARG_WITH([network],
AC_HELP_STRING([--with-network], [with virtual network driver
@:@default=yes@:@]),[],[with_network=yes])
-if test $with_libvirtd = no ; then
+
+dnl theres no use compiling the network driver without the libvirt


s/theres/there's/


Oops.  Thanks. :)



+dnl daemon, nor compiling it for MacOS X, where it breaks the compile
+
+if test $with_libvirtd = no || test $with_osx = yes; then
with_network=no
fi


Mostly looks okay, but probably worth a v2 to make sure the
$host-detection case statement rewrite is still good.


No worries.  It'll be a tomorrow job though. :)

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


[libvirt] [PATCH] configure: disable network and storage-fs drivers on mac os x

2010-10-04 Thread Justin Clift
Disabling these two drivers on MacOS X, where they are known to
not work, allows libvirt (including the daemon) to compile without
any further changes.
---
Whooo, we now run on MacOS X too.

Anyone with a BSD around, that wants to check there, in case we get lucky? :)
 configure.ac |   39 ---
 1 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6c4e828..2dbfc72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,12 +182,24 @@ if test $prefix = /usr  test $sysconfdir = 
'${prefix}/etc' ; then
 sysconfdir='/etc'
 fi
 
-dnl lxc and qemu drivers require linux headers
+dnl Make some notes about which OS we're compiling for, as the lxc and qemu
+dnl drivers require linux headers, while storage_mpath and nwfilter are also
+dnl linux specific.  The network and storage_fs drivers are known to not
+dnl work on MacOS X presently, so we also make a note if compiling for that
+
+with_linux=no
+with_osx=no
 case $host in
   *-*-linux*)
 # match linux here so the *) case will match anything non-linux
+with_linux=yes
 ;;
   *)
+case $host in
+  *-*-darwin*)
+with_osx=yes
+;;
+esac
 if test x$with_lxc != xyes
 then
 with_lxc=no
@@ -198,6 +210,7 @@ case $host in
 fi
 ;;
 esac
+AM_CONDITIONAL([WITH_LINUX], [test $with_linux = yes])
 
 dnl Allow to build without Xen, QEMU/KVM, test or remote driver
 AC_ARG_WITH([xen],
@@ -1306,12 +1319,18 @@ fi
 AC_SUBST([READLINE_CFLAGS])
 AC_SUBST([VIRSH_LIBS])
 
+dnl check if the network driver should be compiled
 
 AC_ARG_WITH([network],
   AC_HELP_STRING([--with-network], [with virtual network driver 
@:@default=yes@:@]),[],[with_network=yes])
-if test $with_libvirtd = no ; then
+
+dnl theres no use compiling the network driver without the libvirt
+dnl daemon, nor compiling it for MacOS X, where it breaks the compile
+
+if test $with_libvirtd = no || test $with_osx = yes; then
   with_network=no
 fi
+
 if test $with_network = yes ; then
   AC_DEFINE_UNQUOTED([WITH_NETWORK], 1, [whether network driver is enabled])
 fi
@@ -1389,6 +1408,11 @@ if test $with_storage_dir = yes ; then
 fi
 AM_CONDITIONAL([WITH_STORAGE_DIR], [test $with_storage_dir = yes])
 
+dnl storage-fs does not work on MacOS X
+
+if test $with_osx = yes; then
+  with_storage_fs=no
+fi
 
 if test $with_storage_fs = yes || test $with_storage_fs = check; then
   AC_PATH_PROG([MOUNT], [mount], [], [$PATH:/sbin:/usr/sbin])
@@ -1503,14 +1527,6 @@ if test $with_storage_scsi = check; then
 fi
 AM_CONDITIONAL([WITH_STORAGE_SCSI], [test $with_storage_scsi = yes])
 
-with_linux=no
-case $host in
-  *-*-linux*)
-with_linux=yes
-;;
-esac
-AM_CONDITIONAL([WITH_LINUX], [test $with_linux = yes])
-
 if test $with_storage_mpath = check  test $with_linux = yes; then
with_storage_mpath=yes
 
@@ -2030,6 +2046,8 @@ then
 fi
 AM_CONDITIONAL([WITH_NODE_DEVICES], [test $with_nodedev = yes])
 
+dnl nwfilter should only be compiled for linux, and only if the
+dnl libvirt daemon is also being compiled
 
 with_nwfilter=yes
 if test $with_libvirtd = no || test $with_linux != yes; then
@@ -2040,7 +2058,6 @@ if test $with_nwfilter = yes ; then
 fi
 AM_CONDITIONAL([WITH_NWFILTER], [test $with_nwfilter = yes])
 
-
 AC_ARG_WITH([qemu-user],
   AC_HELP_STRING([--with-qemu-user], [username to run QEMU system instance as 
@:@default=root@:@]),
   [QEMU_USER=${withval}],
-- 
1.7.3

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


Re: [libvirt] RFC: automatic setting of ip_forwarding (or not)

2010-10-04 Thread Laine Stump

 On 10/01/2010 04:44 PM, Zdenek Styblik wrote:

Uh huh, hi?

On 10/01/2010 08:46 PM, Laine Stump wrote:
[...]

to /etc/sysctl.conf and calling sysctl -a -p. This gives us the same
behavior as currently, but with the advantages that a) our change to the
config is documented in /etc/sysctl.conf and b) virtual networked guests
won't suddenly have their network fail when some other process runs
sysconfig -a -p.


You've got me a bit confused here, because what exactly is supposed #
sysctl -a -p; do? I mean, what kind of magic?


Sorry about that - remove the -a from that command.

No magic. As the manpage says, sysctl -p  reads the provided file (or 
/etc/sysctl.conf if no file is provided) and sets all the kernel 
parameters listed there to the values given. As you know, 
/etc/sysctl.conf is used, at least on RHEL and Fedora, to permanently 
set kernel parameter values to something other than the defaults 
hardcoded into the kernel and loadable kernel modules. (actually they 
can be modified to something else either by individually setting them 
with sysctl -w or by writing directly to the /proc entry, but this will 
be overridden the next time sysctl -p is run).



On both RHEL and Fedora, both the network and NetworkManager services 
(and others, eg see the bug reports a bit further down in this reply) 
run sysctl with -p to reload all non-kernel-default settings when they 
are started, and Fedora puts net.ipv4.ip_forward=0 into 
/etc/sysctl.conf at install time. So at boot time, both of those 
services run sysctl -p which sets ip_forward to 0, then libvirtd 
starts, which sets it to 1. At this point, libvirt virtual networks are 
running (as expected), but also there may be some other unwanted routing 
going on (which the admin won't expect). If the network or 
NetworkManager service is later manually restarted (or some other 
parameter is added to sysctl.conf and it's reloaded with sysctl -p as 
many HOWTO documents suggest when changing a kernel parameter), 
libvirt's virtual networks suddenly/unexpectedly stop working.




I've tried this and if I turn on net.ipv4.ip_forward to '1' and run #
sysctl -a -p; it stays on, unless defined as 0 in /etc/sysctl.conf (and
sysctl run only with -p, not -a AND -p).


Right, my mistake.



  And if it's defined as 0 there,
then there must be reason for being so.



Exactly one of my points. libvirt really wants (no, *needs*) this to be 
on for virtual networks, but it's very likely there was a reason for it 
being turned off, so the admin should at the very least be alerted that 
it's being turned on, or the fact that it's off should be logged in some 
way to assure it gets the admin's attention so they can make the proper 
judgement call.




Also, why on Earth would you
have every sysctl parameter in /etc/sysctl.conf unless you're not happy
with default ones?



Nobody is talking about putting any value there other than 
net.ipv4.ip_forward (which, on RHEL and Fedora is already put there by 
the installer), and that only to assure that it's set to the value that 
libvirtd needs for its virtual networks to work properly. (Possibly my 
erroneous addition of -a threw you off there).




Imho this file is for fine tuning, thus ~ include
things what I don't like or want changed, but not every possible kernel
option which I might or might not want to change. Because then there is
no surprise for such odd behavior.

Also, the outlined problem here sounds more like left hand doesn't know
what's doing right hand or I just didn't get your point.



Again you are correct. currently libvirt is turning it on without 
documenting that fact in the (as far as I know) standard accepted place 
of doing so - /etc/sysctl.conf.




I'm also
missing the previous discussion about the problem, if there was any. I
mean, your e-mail comes out of the blue sky without any previous reference.


Two Active bug reports that I'm aware of offhand (one for RHEL and one 
for Fedora):


  https://bugzilla.redhat.com/show_bug.cgi?id=612865
  https://bugzilla.redhat.com/show_bug.cgi?id=612867

There are also related bugs for older Fedora releases:

  https://bugzilla.redhat.com/show_bug.cgi?id=240922
  https://bugzilla.redhat.com/show_bug.cgi?id=426792
  https://bugzilla.redhat.com/show_bug.cgi?id=467687
  https://bugzilla.redhat.com/show_bug.cgi?id=514228

The first two prompted a short discussion on an internal Red Hat call, 
first a brief mention of it a month or two ago, and again in a similar 
call last week, where the main point of the conversation was 1) this is 
a problem, 2) we should fix it, 3) here's a list of some ideas, 4) we 
need to post these ideas on libvir-list to start a conversation in the 
libvirt community about the best course of action.


I'm not sure how else we could have proceeded that would have made it 
less of a surprise to you. (Of course now that I've hopefully better 
articulated myself, you may be less surprised :-)




I hope this doesn't sound too much jerk-ish, 

Re: [libvirt] [PATCH 08/12] vcpu: support maxvcpu in domain_conf

2010-10-04 Thread Eric Blake

On 10/01/2010 09:01 AM, Daniel Veillard wrote:

On Wed, Sep 29, 2010 at 06:02:12PM -0600, Eric Blake wrote:

* src/conf/domain_conf.h (_virDomainDef): Adjust vcpus to unsigned
short, to match virDomainGetInfo limit.  Add maxvcpus member.

[...]


Two tightly-related changes.  One: virDomainGetInfo implicitly limits
vcpus to a 16-bit number; so there's no need to pretend otherwise
through the rest of the code.


  well, yes and no, in a few years we may look ridiculous, but it would
  be good to have the new APIs cleared up from that limitation.


So, should I keep the change to 16-bit in my v2 series, or should I keep 
things at 32-bit and add code that makes virDomainGetInfo fail on 16-bit 
overflow?  Right now, it's easier to keep things at 16-bit throughout. 
Also, note that the new APIs (virDomainGetVcpusFlags and 
virDomainSetVcpusFlags) can go up to 31 bits.  Get must return -1 on 
failure, so a full 32-bits cannot be returned; so even though Set passes 
an unsigned value, we should not accept 0x8000, even if we decide 
someday that we want to support 0x1 vcpus.


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

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


Re: [libvirt] [PATCH 08/12] vcpu: support maxvcpu in domain_conf

2010-10-04 Thread Eric Blake

On 10/01/2010 09:01 AM, Daniel Veillard wrote:

-if (virXPathULong(string(./vcpu[1]), ctxt,def-vcpus)  0)
-def-vcpus = 1;
+if (virXPathULong(string(./vcpu[1]), ctxt,count)  0)
+def-maxvcpus = 1;
+else {
+def-maxvcpus = count;
+if (def-maxvcpus != count || count == 0) {
+virDomainReportError(VIR_ERR_INTERNAL_ERROR,
+ _(invalid maxvcpus %lu), count);
+goto error;
+}
+}


   Hum, virXPathULong will return -2 for an non ULong format, and we
discard the error by just setting up maxvcpus = 1 silently but on the
other hand we make a fuss about 0 being provided :-)
   If we start raising an error on invalid values maybe it should be
done for both (-2 need to be checked)


Which is better? Relying on the .rng file for error checking (in which 
case, XML has already been validated, so not only do we know 
virXPathULong would never return -2, but we also know that current='0' 
would fail validation, so v2 should drop the redundant check for 0), or 
repeat all error checking in the C code (in which case adding a check 
for virXPathULong == -2 is a good thing for v2)?


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

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


[libvirt] [PATCH] Add the device alias element to the domain.rng schema

2010-10-04 Thread Matthias Bolte
Every device element that can contain an address element
can also contain an alias element, but the domain.rng didn't
reflect this. Therefore, running virt-xml-validate on the
virsh dumpxml output of an active domain failed. It doesn't
fail for inactive domains, because in that case dumpxml
doesn't include the alias elements.

Add the device alias element to the domain.rng schema and
add a new test case to cover this.

Indirectly reported by Jon Stanley.
---
 docs/schemas/domain.rng   |   42 +++
 tests/domainschemadata/device-aliases.xml |   79 +
 2 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 tests/domainschemadata/device-aliases.xml

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 2e0457b..8fdf864 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -503,6 +503,9 @@
   ref name=encryption/
 /optional
 optional
+  ref name=alias/
+/optional
+optional
   ref name=address/
 /optional
   /define
@@ -697,6 +700,9 @@
 /attribute
   /optional
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -762,6 +768,9 @@
 /group
   /choice
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -924,6 +933,9 @@
 /element
   /optional
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
   optional
@@ -1157,6 +1169,9 @@
 /element
   /optional
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -1240,6 +1255,9 @@
 ref name=qemucdevTgtDef/
   /optional
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /interleave
@@ -1345,6 +1363,9 @@
 /choice
   /attribute
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -1369,6 +1390,9 @@
 /attribute
   /optional
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -1383,6 +1407,9 @@
 /choice
   /attribute
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -1426,6 +1453,9 @@
   ref name=virtioTarget/
 /choice
 optional
+  ref name=alias/
+/optional
+optional
   ref name=address/
 /optional
   /interleave
@@ -1449,6 +1479,9 @@
 /attribute
   /optional
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -1492,6 +1525,9 @@
 /element
   /group
   optional
+ref name=alias/
+  /optional
+  optional
 ref name=address/
   /optional
 /element
@@ -1728,6 +1764,12 @@
 /element
   /define
 
+  define name=alias
+element name=alias
+  attribute name=name/
+/element
+  /define
+
   define name=filterref-node-attributes
 attribute name=filter
   data type=NCName/
diff --git a/tests/domainschemadata/device-aliases.xml 
b/tests/domainschemadata/device-aliases.xml
new file mode 100644
index 000..6b0299e
--- /dev/null
+++ b/tests/domainschemadata/device-aliases.xml
@@ -0,0 +1,79 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu1/vcpu
+  os
+type arch='x86_64' machine='pc-0.12'hvm/type
+boot dev='cdrom'/
+  /os
+  features
+acpi/
+apic/
+pae/
+  /features
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/qemu/emulator
+disk type='file' device='disk'
+  driver name='qemu' type='raw'/
+  source file='/var/lib/libvirt/images/QEMUGuest1.img'/
+  target dev='hda' bus='ide'/
+  alias name='ide0-0-0'/
+  address type='drive' controller='0' bus='0' unit='0'/
+/disk
+disk type='file' device='cdrom'
+  driver name='qemu' type='raw'/
+  source file='/var/lib/libvirt/images/foobar.iso'/
+  target dev='hdc' bus='ide'/
+  readonly/
+  alias name='ide0-1-0'/
+  address type='drive' controller='0' bus='1' unit='0'/
+/disk
+filesystem type='file'
+  source file='/var/lib/libvirt/images/foobar.iso'/
+  target dir='/var/lib/libvirt/images'/
+  alias name='filesystem0'/
+/filesystem
+controller type='ide' index='0'
+  alias name='ide0'/
+  address type='pci' domain='0x' bus='0x00' slot='0x01' 

[libvirt] [PATCHv2] configure: disable network and storage-fs drivers on mac os x

2010-10-04 Thread Justin Clift
Disabling these two drivers on MacOS X, where they are known to
not work, allows libvirt (including the daemon) to compile without
any further changes.
---
This 2nd version of the patch incorporates Erics suggestion for a better case
statement approach, and fixes a typo in a comment.

Apart from that, this is the final patch needed to compile out of the box
on MacOS X.  (further work should be done at some point to fix the ssh
connectivity problem to PolicyKit enabled servers though)

Anyone with a BSD around, that wants to check there, in case we get lucky? :)
 configure.ac |   51 +++
 1 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6c4e828..bd92b65 100644
--- a/configure.ac
+++ b/configure.ac
@@ -182,22 +182,29 @@ if test $prefix = /usr  test $sysconfdir = 
'${prefix}/etc' ; then
 sysconfdir='/etc'
 fi
 
-dnl lxc and qemu drivers require linux headers
-case $host in
-  *-*-linux*)
-# match linux here so the *) case will match anything non-linux
-;;
-  *)
-if test x$with_lxc != xyes
+dnl Make some notes about which OS we're compiling for, as the lxc and qemu
+dnl drivers require linux headers, while storage_mpath and nwfilter are also
+dnl linux specific.  The network and storage_fs drivers are known to not
+dnl work on MacOS X presently, so we also make a note if compiling for that
+
+with_linux=no with_osx=no
+case $host in
+  *-*-linux*) with_linux=yes ;;
+  *-*-darwin*) with_osx=yes ;;
+esac
+
+if test $with_linux = no; then
+if test x$with_lxc != xyes
 then
 with_lxc=no
 fi
-if test x$with_qemu != xyes
+if test x$with_qemu != xyes
 then
 with_qemu=no
 fi
-;;
-esac
+fi
+
+AM_CONDITIONAL([WITH_LINUX], [test $with_linux = yes])
 
 dnl Allow to build without Xen, QEMU/KVM, test or remote driver
 AC_ARG_WITH([xen],
@@ -1306,12 +1313,18 @@ fi
 AC_SUBST([READLINE_CFLAGS])
 AC_SUBST([VIRSH_LIBS])
 
+dnl check if the network driver should be compiled
 
 AC_ARG_WITH([network],
   AC_HELP_STRING([--with-network], [with virtual network driver 
@:@default=yes@:@]),[],[with_network=yes])
-if test $with_libvirtd = no ; then
+
+dnl there's no use compiling the network driver without the libvirt
+dnl daemon, nor compiling it for MacOS X, where it breaks the compile
+
+if test $with_libvirtd = no || test $with_osx = yes; then
   with_network=no
 fi
+
 if test $with_network = yes ; then
   AC_DEFINE_UNQUOTED([WITH_NETWORK], 1, [whether network driver is enabled])
 fi
@@ -1389,6 +1402,11 @@ if test $with_storage_dir = yes ; then
 fi
 AM_CONDITIONAL([WITH_STORAGE_DIR], [test $with_storage_dir = yes])
 
+dnl storage-fs does not work on MacOS X
+
+if test $with_osx = yes; then
+  with_storage_fs=no
+fi
 
 if test $with_storage_fs = yes || test $with_storage_fs = check; then
   AC_PATH_PROG([MOUNT], [mount], [], [$PATH:/sbin:/usr/sbin])
@@ -1503,14 +1521,6 @@ if test $with_storage_scsi = check; then
 fi
 AM_CONDITIONAL([WITH_STORAGE_SCSI], [test $with_storage_scsi = yes])
 
-with_linux=no
-case $host in
-  *-*-linux*)
-with_linux=yes
-;;
-esac
-AM_CONDITIONAL([WITH_LINUX], [test $with_linux = yes])
-
 if test $with_storage_mpath = check  test $with_linux = yes; then
with_storage_mpath=yes
 
@@ -2030,6 +2040,8 @@ then
 fi
 AM_CONDITIONAL([WITH_NODE_DEVICES], [test $with_nodedev = yes])
 
+dnl nwfilter should only be compiled for linux, and only if the
+dnl libvirt daemon is also being compiled
 
 with_nwfilter=yes
 if test $with_libvirtd = no || test $with_linux != yes; then
@@ -2040,7 +2052,6 @@ if test $with_nwfilter = yes ; then
 fi
 AM_CONDITIONAL([WITH_NWFILTER], [test $with_nwfilter = yes])
 
-
 AC_ARG_WITH([qemu-user],
   AC_HELP_STRING([--with-qemu-user], [username to run QEMU system instance as 
@:@default=root@:@]),
   [QEMU_USER=${withval}],
-- 
1.7.3

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


Re: [libvirt] OSX 10.6 build failures

2010-10-04 Thread Justin Clift

On 10/01/2010 03:26 AM, Eric Blake wrote:

On 09/14/2010 05:42 PM, Justin Clift wrote:

b) pkg-config

The next thing to barf was autoconf, complaining about AC_MSG_ERROR
not being a defined macro.

Googling with some persistence showed this is caused by pkg-config
not being installed. Fixed that.

Will submit a patch for that too. Probably pkg-config --version
based, copying the approach used for the other autogen.sh checks.


Revisiting this, does it suffice to add pkg-config into the $buildreq
table of bootstrap.conf?


That seems to be an improvement.  Without pkg-config installed, running
autogen.sh gives this failure:


$ ./autogen.sh
snip
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
configure: error: cannot run /bin/sh build-aux/config.sub
$


With it added, we get:


$ ./autogen.sh
running bootstrap...
Error: 'CONFIG-pkg-config' not found

ProgramMin_version
--
autoconf   2.59
automake   1.9.6
autopoint  -
gettext-
git1.5.5
gzip   -
libtool-
perl   5.5
pkg-config -
tar-
--
Failed to bootstrap gnulib, please investigate.
$


As a clarity of error message idea, do you reckon it's workable
for the error message to list the status of each item?

Something like:


$ ./autogen.sh
running bootstrap...
Error: 'CONFIG-pkg-config' not found

ProgramMin_versionStatus
-
autoconf   2.59   OK - 2.61 found
automake   1.9.6  OK - 1.10 found
autopoint  -  OK
gettext-  OK
git1.5.5  OK - 1.73 found
gzip   -  OK
libtool-  OK
perl   5.5OK - 5.10 found
pkg-config -  MISSING
tar-  OK
-
Failed to bootstrap gnulib, please investigate.
$


It just seems like it would convey the problem (and implied solution) in 
a clearer fashion.


As a thought, after installing pkg-config back onto the system, the
above error about CONFIG-pkg-config not being found still happens,
so something isn't right. :/

Any ideas?

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