[libvirt] Re: [Libvir] [PATCH] lxc: loop in tty forwarding process

2008-05-08 Thread Daniel Veillard
On Wed, May 07, 2008 at 12:47:40PM -0700, Dave Leskovec wrote:
 Daniel Veillard wrote:
  On Tue, May 06, 2008 at 12:51:08AM -0700, Dave Leskovec wrote:
 [...]
  -close(vm-parentTty);
  +//close(vm-parentTty);
   close(vm-containerTtyFd);
  
if we really don't need this anymore just remove it, if you have doubts 
  then
  maybe this should be clarified. In any case let's stick to old style 
  comments
  /* ... */
  
 
 That shouldn't be commented out.  I've restored it in the attached updated 
 patch.

  Sounds fine then +1, just push it :-)

Daniel

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

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


Re: [libvirt] [PATCH] Implement autostart commands for xen

2008-05-08 Thread S.Sakamoto
 The attached patch implements the domain autostart commands for
 xen. The xen sexpr (since at least 3.0.4 = 1.5 years) has a 
 on_xend_start field which can be used to autostart a domain.
 
It is a good patch for me.
It moved without a problem when I tested it.

By the way, I have a question.
What is getAutostart used by?
getAutostart seems to be used from no virsh command.


Thanks,
Shigeki Sakamoto.

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


Re: [libvirt] [PATCH] Implement autostart commands for xen

2008-05-08 Thread Atsushi SAKAI
Hi, Cole

Cole Robinson [EMAIL PROTECTED] wrote:

 1) This works on a running guest, but will only show the
sexpr changes after the guest is restarted. Just curious
if there is any better way to do this?

This is current Xen behavior.
If you need to work as you hope, you should change Xend.

Your code seems good to me.

Thanks
Atsushi SAKAI




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


Re: [libvirt] [PATCH] Implement autostart commands for xen

2008-05-08 Thread Daniel P. Berrange
On Thu, May 08, 2008 at 06:42:13PM +0900, S.Sakamoto wrote:
  The attached patch implements the domain autostart commands for
  xen. The xen sexpr (since at least 3.0.4 = 1.5 years) has a 
  on_xend_start field which can be used to autostart a domain.
  
 It is a good patch for me.
 It moved without a problem when I tested it.
 
 By the way, I have a question.
 What is getAutostart used by?
 getAutostart seems to be used from no virsh command.

Well virt-manager will call it and display the autostart status. I
don't know what virsh doesn't use it. It should really show the autostart
status when display a 'virsh domiinfo'

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

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


Re: [libvirt] [PATCH] Implement autostart commands for xen

2008-05-08 Thread Daniel P. Berrange

On Wed, May 07, 2008 at 04:21:25PM -0400, Cole Robinson wrote:
 +int
 +xenDaemonDomainGetAutostart(virDomainPtr domain,
 +int *autostart)
 +{
 +struct sexpr *root;
 +const char *tmp;
 +
 +if ((domain == NULL) || (domain-conn == NULL) || (domain-name == 
 NULL)) {
 +virXendError((domain ? domain-conn : NULL), VIR_ERR_INVALID_ARG,
 + __FUNCTION__);
 +return (-1);
 +}

Since this only works in Xen 3.0.4 or later can you add in:

/* xm_internal.c (the support for defined domains from /etc/xen
 * config files used by old Xen) will handle this.
 */
if (priv-xendConfigVersion  3)
return(-1);

This ensures that users will get a 'operation not supported' error for older
XenD - at least until we implement the alternate /etc/xen/auto symlink scheme
for xm_internal.c driver.


 +xenDaemonDomainSetAutostart(virDomainPtr domain,
 +int autostart)
 +{
 +struct sexpr *root, *autonode;
 +const char *autostr;
 +char buf[4096];
 +int ret = -1;
 +
 +if ((domain == NULL) || (domain-conn == NULL) || (domain-name == 
 NULL)) {
 +virXendError((domain ? domain-conn : NULL), VIR_ERR_INTERNAL_ERROR,
 + __FUNCTION__);
 +return (-1);
 +}

Same here - add a xendConfigVersion check.

 +root = sexpr_get(domain-conn, /xend/domain/%s?detail=1, domain-name);
 +if (root == NULL) {
 +virXendError (domain-conn, VIR_ERR_XEN_CALL,
 +  _(xenDaemonSetAutostart failed to find this domain));
 +return (-1);
 +}
 +
 +autostr = sexpr_node(root, domain/on_xend_start);
 +if (autostr) {
 +if (!STREQ(autostr, ignore)  !STREQ(autostr, start)) {
 +virXendError(domain-conn, VIR_ERR_INTERNAL_ERROR,
 + _(unexpected value from on_xend_start));
 +goto error;
 +}
 +
 +// Change the autostart value in place, then define the new sexpr
 +autonode = sexpr_lookup(root, domain/on_xend_start);
 +free(autonode-u.s.car-u.value);
 +autonode-u.s.car-u.value = (autostart ? strdup(start)
 +: strdup(ignore));
 +if (!(autonode-u.s.car-u.value)) {
 +virXendError(domain-conn, VIR_ERR_INTERNAL_ERROR,
 + _(no memory));
 +goto error;
 +}
 +
 +if (sexpr2string(root, buf, 4096) == 0) {

Use sizeof(buf) here instead of duplicating 4096 constant.

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

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


Re: [libvirt] Re-write the domain XML reference docs

2008-05-08 Thread Daniel Veillard
On Wed, May 07, 2008 at 01:01:11AM +0100, Daniel P. Berrange wrote:
 The current domain XML format documentation reference on the website is
 very out of date and not well structured since we organically added random
 bits to it as we wrote drivers. This patch is starting from a clean slate.
 I've removed all existing content and have written a clear  concise
 reference for (all?) XML elements we support in the domain XML format. 
 This is following the style I've used for the storage and network XML
 format docs.
 
 Basically I've grouped the difference elements into logically related sets
 and then described each one, giving examples and details of all attributes
 they support. This also covers the new serial/paralle device syntax I
 added recently. 
 
 The example configs for Xen, QEMU, etc domains are all in the driver 
 specific docs already, and linked at the bottom of this page.
 
 The patch isn't particularly nice to review, so I'd recommend applying it
 and looking at the resulting 'formatdomain.html' page in your web browser

  Yup, just did that, and it looks really nice now. For some reason
the page.xsl part of the patch failed to apply to CVS head though.
i will try to update the Relax-NG file, but it will need to be reengineered
I'm afraid. I previously tried to switch based on the top domain/@type 
attribute value, to differentiate the syntax between hypervisors but since
we are keeping things more and more unified now, it's probably not worth it.

  +1

Daniel

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

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


Re: [libvirt] [PATCH] add const to file-scoped statics

2008-05-08 Thread Daniel P. Berrange
On Thu, May 08, 2008 at 04:40:11PM +0200, Jim Meyering wrote:
 
 From fed1a1abfd2b9ece7bd8e44aae13de91eaad4f5d Mon Sep 17 00:00:00 2001
 From: Jim Meyering [EMAIL PROTECTED]
 Date: Wed, 7 May 2008 23:12:13 +0200
 Subject: [PATCH] add const to file-scoped statics
 
 These were relatively new additions to the list from here:
 nm src/*.o|grep ' D '.

ACK

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

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


[libvirt] [PATCH] sytnax-check: add a check for risky ctype macro use

2008-05-08 Thread Jim Meyering
A follow-up to the patch that introduced to_uchar.
This rule will ensure no new offenders sneak back in.

From d141d07c7e21cc228fe46d90f21dd86685d7e424 Mon Sep 17 00:00:00 2001
From: Jim Meyering [EMAIL PROTECTED]
Date: Thu, 8 May 2008 16:18:13 +0200
Subject: [PATCH] sytnax-check: add a check for risky ctype macro use

* Makefile.maint (sc_risky_ctype_macros): New rule.
---
 Makefile.maint |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/Makefile.maint b/Makefile.maint
index ddf42bc..bab8e1d 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -302,6 +302,15 @@ sc_TAB_in_indentation:
  { echo '$(ME): found TAB(s) use for indentation; use spaces'  \
12; exit 1; } || :

+ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
+|isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
+
+sc_risky_ctype_macros:
+   @grep -E '\b($(ctype_re)) *\(' /dev/null\
+$$($(VC_LIST_EXCEPT)) | grep -v to_uchar \
+ { echo '$(ME): found ctype macro use without to_uchar'\
+   12; exit 1; } || :
+
 # Match lines like the following, but where there is only one space
 # between the options and the description:
 #   -D, --all-repeated[=delimit-method]  print all duplicate lines\n
--
1.5.5.1.148.gbc1be

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


[libvirt] [PATCH] avoid one more ctype vs. sign-extension problem

2008-05-08 Thread Jim Meyering
This change demonstrates that the new syntax-check rule's
regexp can be improved.  It missed the unsafe tolower use,
since there was already a to_uchar use on that line.

From 5fc8de9825215e28773f2230ac6c1e1b3d724602 Mon Sep 17 00:00:00 2001
From: Jim Meyering [EMAIL PROTECTED]
Date: Thu, 8 May 2008 16:11:55 +0200
Subject: [PATCH] avoid one more ctype vs. sign-extension problem

* src/util.c (TOLOWER): Also convert tolower argument.
---
 src/util.c |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/util.c b/src/util.c
index 8f3cef9..4cef6d2 100644
--- a/src/util.c
+++ b/src/util.c
@@ -57,7 +57,8 @@

 #define MAX_ERROR_LEN   1024

-#define TOLOWER(Ch) (isupper (to_uchar(Ch)) ? tolower (Ch) : (Ch))
+#define TOLOWER(Ch) (isupper (to_uchar(Ch)) \
+? tolower (to_uchar (Ch)) : (to_uchar (Ch)))

 #define virLog(msg...) fprintf(stderr, msg)

--
1.5.5.1.148.g4c99ee

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


Re: [libvirt] [PATCH] avoid one more ctype vs. sign-extension problem

2008-05-08 Thread Daniel P. Berrange
On Thu, May 08, 2008 at 04:44:38PM +0200, Jim Meyering wrote:
 This change demonstrates that the new syntax-check rule's
 regexp can be improved.  It missed the unsafe tolower use,
 since there was already a to_uchar use on that line.

ACK

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

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


Re: [libvirt] PATCH: Add disk bus attribute for Xen driver

2008-05-08 Thread Jim Meyering
Daniel P. Berrange [EMAIL PROTECTED] wrote:
 To complement soren's patch adding a bus attribute to the QEMU driver,
 here is a minimal patch adding bus attribute to the Xen drivers. It merely
 adds it on when generating the XML. It isn't making any attempt to interpret
 it when creating a VM, since Xen does everything based off the disk node
 name anyway its (currently) redundant.

 The bus types supported  are 'xen' for paravirt disks, or 'ide' and 'scsi'
 for HVM guests.
...
 Index: src/xend_internal.c
...
 +if (STRPREFIX(dst, xvd) || !hvm) {
 +bus = xen;
 +} else if (STRPREFIX(dst, sd)) {
 +bus = scsi;
 +} else {
 +bus = ide;
 +}
...
 Index: src/xm_internal.c
 ===
...
 +if (STRPREFIX(dev, xvd) || !hvm) {
 +bus = xen;
 +} else if (STRPREFIX(dev, sd)) {
 +bus = scsi;
 +} else {
 +bus = ide;
 +}
 +

ACK
Looks good. (though maybe avoid that duplication)

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


Re: [libvirt] [PATCH] Implement autostart commands for xen

2008-05-08 Thread Cole Robinson
Cole Robinson wrote:
 The attached patch implements the domain autostart commands for
 xen. The xen sexpr (since at least 3.0.4 = 1.5 years) has a 
 on_xend_start field which can be used to autostart a domain.
 

Updated patch with fixes Dan recommended.

Thanks,
Cole

diff --git a/src/xen_unified.c b/src/xen_unified.c
index 91502dc..cf0a68d 100644
--- a/src/xen_unified.c
+++ b/src/xen_unified.c
@@ -1128,6 +1128,34 @@ xenUnifiedDomainDetachDevice (virDomainPtr dom, const 
char *xml)
 return -1;
 }
 
+static int
+xenUnifiedDomainGetAutostart (virDomainPtr dom, int *autostart)
+{
+GET_PRIVATE(dom-conn);
+int i;
+
+for (i = 0; i  XEN_UNIFIED_NR_DRIVERS; ++i)
+if (priv-opened[i]  drivers[i]-domainGetAutostart 
+drivers[i]-domainGetAutostart (dom, autostart) == 0)
+return 0;
+
+return -1;
+}
+
+static int
+xenUnifiedDomainSetAutostart (virDomainPtr dom, int autostart)
+{
+GET_PRIVATE(dom-conn);
+int i;
+
+for (i = 0; i  XEN_UNIFIED_NR_DRIVERS; ++i)
+if (priv-opened[i]  drivers[i]-domainSetAutostart 
+drivers[i]-domainSetAutostart (dom, autostart) == 0)
+return 0;
+
+return -1;
+}
+
 static char *
 xenUnifiedDomainGetSchedulerType (virDomainPtr dom, int *nparams)
 {
@@ -1291,6 +1319,8 @@ static virDriver xenUnifiedDriver = {
 .domainUndefine= xenUnifiedDomainUndefine,
 .domainAttachDevice= xenUnifiedDomainAttachDevice,
 .domainDetachDevice= xenUnifiedDomainDetachDevice,
+.domainGetAutostart = xenUnifiedDomainGetAutostart,
+.domainSetAutostart = xenUnifiedDomainSetAutostart,
 .domainGetSchedulerType= xenUnifiedDomainGetSchedulerType,
 .domainGetSchedulerParameters  = 
xenUnifiedDomainGetSchedulerParameters,
 .domainSetSchedulerParameters  = 
xenUnifiedDomainSetSchedulerParameters,
diff --git a/src/xend_internal.c b/src/xend_internal.c
index 6d64509..90d3f4f 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -115,8 +115,8 @@ struct xenUnifiedDriver xenDaemonDriver = {
 xenDaemonDomainUndefine, /* domainUndefine */
 xenDaemonAttachDevice, /* domainAttachDevice */
 xenDaemonDetachDevice, /* domainDetachDevice */
-NULL, /* domainGetAutostart */
-NULL, /* domainSetAutostart */
+xenDaemonDomainGetAutostart, /* domainGetAutostart */
+xenDaemonDomainSetAutostart, /* domainSetAutostart */
 xenDaemonGetSchedulerType, /* domainGetSchedulerType */
 xenDaemonGetSchedulerParameters, /* domainGetSchedulerParameters */
 xenDaemonSetSchedulerParameters, /* domainSetSchedulerParameters */
@@ -3728,6 +3728,115 @@ xenDaemonDetachDevice(virDomainPtr domain, const char 
*xml)
 type, class, dev, ref, force, 0, rm_cfg, 1, NULL));
 }
 
+int
+xenDaemonDomainGetAutostart(virDomainPtr domain,
+int *autostart)
+{
+struct sexpr *root;
+const char *tmp;
+xenUnifiedPrivatePtr priv;
+
+if ((domain == NULL) || (domain-conn == NULL) || (domain-name == NULL)) {
+virXendError((domain ? domain-conn : NULL), VIR_ERR_INVALID_ARG,
+ __FUNCTION__);
+return (-1);
+}
+
+/* xm_internal.c (the support for defined domains from /etc/xen
+ * config files used by old Xen) will handle this.
+ */
+priv = (xenUnifiedPrivatePtr) domain-conn-privateData;
+if (priv-xendConfigVersion  3)
+return(-1);
+
+root = sexpr_get(domain-conn, /xend/domain/%s?detail=1, domain-name);
+if (root == NULL) {
+virXendError (domain-conn, VIR_ERR_XEN_CALL,
+  _(xenDaemonGetAutostart failed to find this domain));
+return (-1);
+}
+
+*autostart = 0;
+
+tmp = sexpr_node(root, domain/on_xend_start);
+if (tmp  STREQ(tmp, start)) {
+*autostart = 1;
+}
+
+sexpr_free(root);
+return 0;
+}
+
+int
+xenDaemonDomainSetAutostart(virDomainPtr domain,
+int autostart)
+{
+struct sexpr *root, *autonode;
+const char *autostr;
+char buf[4096];
+int ret = -1;
+xenUnifiedPrivatePtr priv;
+
+if ((domain == NULL) || (domain-conn == NULL) || (domain-name == NULL)) {
+virXendError((domain ? domain-conn : NULL), VIR_ERR_INTERNAL_ERROR,
+ __FUNCTION__);
+return (-1);
+}
+
+/* xm_internal.c (the support for defined domains from /etc/xen
+ * config files used by old Xen) will handle this.
+ */
+priv = (xenUnifiedPrivatePtr) domain-conn-privateData;
+if (priv-xendConfigVersion  3)
+return(-1);
+
+root = sexpr_get(domain-conn, /xend/domain/%s?detail=1, domain-name);
+if (root == NULL) {
+virXendError (domain-conn, VIR_ERR_XEN_CALL,
+  _(xenDaemonSetAutostart failed to find this domain));
+return (-1);
+}
+
+autostr = sexpr_node(root, domain/on_xend_start);
+if (autostr) {
+if 

[libvirt] Question about more finer access control permission on libvirt

2008-05-08 Thread Atsushi SAKAI
Hi, Dan

I have a question of libvirt with Polkit.
Currently, the libvirt w/ Polkit has 2 access control permissions.
(Read Only and Read Write)

Have you planned to expand the access control more finer?
In my use case, Policy should define by domain, operation, operator.
Of course, operator is already considered on current libvirt w/ Polkit.
So at this point, it needs to add domain and operation policy.

The use case is for many(about 100 or more) domain operation.

I just want to know 
how to minimize granting access control permission of each user
on libvirt in future.

Any comment appreciated.

Thanks
Atsushi SAKAI




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