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: Add disk bus attribute for Xen driver

2008-05-07 Thread Daniel Veillard
On Wed, May 07, 2008 at 01:17:46AM +0100, Daniel P. Berrange 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. 

  +1, this helps migrating from one hypervisor to another (or detecting if
the migration would be harder),

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


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

2008-05-06 Thread Daniel P. Berrange
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. 

NB, if setting up ide / scsi disks with HVM, XenD also sets up a parvirt
disk, but we don't attempt to express this duplication as its an underlying
impl detail.

Regards,
Daniel.

Index: src/xend_internal.c
===
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.183
diff -u -p -r1.183 xend_internal.c
--- src/xend_internal.c 30 Apr 2008 12:30:55 -  1.183
+++ src/xend_internal.c 7 May 2008 00:14:23 -
@@ -1759,6 +1759,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
 const char *src = NULL;
 const char *dst = NULL;
 const char *mode = NULL;
+const char *bus = NULL;
 
 /* Again dealing with (vbd...) vs (tap ...) differences */
 if (sexpr_lookup(node, device/vbd)) {
@@ -1878,7 +1879,16 @@ xend_parse_sexp_desc(virConnectPtr conn,
 /* This case is the cdrom device only */
 virBufferAddLit(buf, disk device='cdrom'\n);
 }
-virBufferVSprintf(buf,   target dev='%s'/\n, dst);
+
+if (STRPREFIX(dst, xvd) || !hvm) {
+bus = xen;
+} else if (STRPREFIX(dst, sd)) {
+bus = scsi;
+} else {
+bus = ide;
+}
+virBufferVSprintf(buf,   target dev='%s' bus='%s'/\n,
+  dst, bus);
 
 
 /* XXX should we force mode == r, if cdrom==1, or assume
@@ -1967,14 +1977,14 @@ xend_parse_sexp_desc(virConnectPtr conn,
 if ((tmp != NULL)  (tmp[0] != 0)) {
 virBufferAddLit(buf, disk type='file' device='floppy'\n);
 virBufferVSprintf(buf,   source file='%s'/\n, tmp);
-virBufferAddLit(buf,   target dev='fda'/\n);
+virBufferAddLit(buf,   target dev='fda' bus='fdc'/\n);
 virBufferAddLit(buf, /disk\n);
 }
 tmp = sexpr_node(root, domain/image/hvm/fdb);
 if ((tmp != NULL)  (tmp[0] != 0)) {
 virBufferAddLit(buf, disk type='file' device='floppy'\n);
 virBufferVSprintf(buf,   source file='%s'/\n, tmp);
-virBufferAddLit(buf,   target dev='fdb'/\n);
+virBufferAddLit(buf,   target dev='fdb' bus='fdc'/\n);
 virBufferAddLit(buf, /disk\n);
 }
 
@@ -1985,7 +1995,7 @@ xend_parse_sexp_desc(virConnectPtr conn,
 virBufferAddLit(buf, disk type='file' 
device='cdrom'\n);
 virBufferAddLit(buf,   driver name='file'/\n);
 virBufferVSprintf(buf,   source file='%s'/\n, tmp);
-virBufferAddLit(buf,   target dev='hdc'/\n);
+virBufferAddLit(buf,   target dev='hdc' bus='ide'/\n);
 virBufferAddLit(buf,   readonly/\n);
 virBufferAddLit(buf, /disk\n);
 }
Index: src/xm_internal.c
===
RCS file: /data/cvs/libvirt/src/xm_internal.c,v
retrieving revision 1.74
diff -u -p -r1.74 xm_internal.c
--- src/xm_internal.c   30 Apr 2008 12:30:55 -  1.74
+++ src/xm_internal.c   7 May 2008 00:14:26 -
@@ -733,6 +733,7 @@ char *xenXMDomainFormatXML(virConnectPtr
 char *head;
 char *offset;
 char *tmp, *tmp1;
+const char *bus;
 
 if ((list-type != VIR_CONF_STRING) || (list-str == NULL))
 goto skipdisk;
@@ -805,6 +806,14 @@ char *xenXMDomainFormatXML(virConnectPtr
 tmp[0] = '\0';
 }
 
+if (STRPREFIX(dev, xvd) || !hvm) {
+bus = xen;
+} else if (STRPREFIX(dev, sd)) {
+bus = scsi;
+} else {
+bus = ide;
+}
+
 virBufferVSprintf(buf, disk type='%s' device='%s'\n,
   block ? block : file,
   cdrom ? cdrom : disk);
@@ -814,7 +823,7 @@ char *xenXMDomainFormatXML(virConnectPtr
 virBufferVSprintf(buf,   driver name='%s'/\n, 
drvName);
 if (src[0])
 virBufferVSprintf(buf,   source %s='%s'/\n, block ? 
dev : file, src);
-virBufferVSprintf(buf,   target dev='%s'/\n, dev);
+virBufferVSprintf(buf,   target dev='%s' bus='%s'/\n, 
dev, bus);
 if (!strcmp(head, r) ||
 !strcmp(head, ro))
 virBufferAddLit(buf,