commit eb3143154e4ecedf3a97445b3b90bd135a564431
Author: Jim Fehlig <jfehlig@novell.com>
Date:   Wed Jul 6 19:17:16 2011 -0600

    Do not drop kernel cmdline for xen pv domains
    
    Kernel cmdline args can be passed to xen pv domains even when a
    bootloader is specified.  The current config-to-sxpr mapping
    ignores cmdline when bootloader is present.
    
    Since the xend sub-driver is used with many xen toolstack versions,
    this patch takes conservative approach of adding an else block to
    existing !def->os.bootloader, and only appends sxpr if def->os.cmdline
    is non-NULL.
    
    V2: Fix existing testcase broken by this patch and add new testcases

Index: libvirt-0.7.6/docs/schemas/domain.rng
===================================================================
--- libvirt-0.7.6.orig/docs/schemas/domain.rng
+++ libvirt-0.7.6/docs/schemas/domain.rng
@@ -429,9 +429,11 @@
   </define>
   <define name="osbootkernel">
     <interleave>
-      <element name="kernel">
-        <ref name="absFilePath"/>
-      </element>
+      <optional>
+        <element name="kernel">
+          <ref name="absFilePath"/>
+        </element>
+      </optional>
       <optional>
         <element name="initrd">
           <ref name="absFilePath"/>
Index: libvirt-0.7.6/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.sexpr
===================================================================
--- /dev/null
+++ libvirt-0.7.6/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.sexpr
@@ -0,0 +1 @@
+(domain (domid 6)(name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d2171f48fb2e068e2386a5c413e')(bootloader '/usr/bin/pygrub')(bootloader_args '-q')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (args 'xenfb.video=8,1280,1024')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
Index: libvirt-0.7.6/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.xml
===================================================================
--- /dev/null
+++ libvirt-0.7.6/tests/sexpr2xmldata/sexpr2xml-pv-bootloader-cmdline.xml
@@ -0,0 +1,27 @@
+<domain type='xen' id='6'>
+  <name>pvtest</name>
+  <uuid>596a5d21-71f4-8fb2-e068-e2386a5c413e</uuid>
+  <memory>430080</memory>
+  <currentMemory>430080</currentMemory>
+  <vcpu>2</vcpu>
+  <bootloader>/usr/bin/pygrub</bootloader>
+  <bootloader_args>-q</bootloader_args>
+  <os>
+    <type>linux</type>
+    <cmdline>xenfb.video=8,1280,1024</cmdline>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <driver name='file'/>
+      <source file='/root/some.img'/>
+      <target dev='xvda' bus='xen'/>
+    </disk>
+    <console type='pty'>
+      <target port='0'/>
+    </console>
+  </devices>
+</domain>
Index: libvirt-0.7.6/tests/sexpr2xmltest.c
===================================================================
--- libvirt-0.7.6.orig/tests/sexpr2xmltest.c
+++ libvirt-0.7.6/tests/sexpr2xmltest.c
@@ -132,6 +132,7 @@ mymain(int argc, char **argv)
     DO_TEST("pv-vfb-type-crash", "pv-vfb-type-crash", 3);
     DO_TEST("fv-autoport", "fv-autoport", 3);
     DO_TEST("pv-bootloader", "pv-bootloader", 1);
+    DO_TEST("pv-bootloader-cmdline", "pv-bootloader-cmdline", 1);
 
     DO_TEST("disk-file", "disk-file", 2);
     DO_TEST("disk-block", "disk-block", 2);
Index: libvirt-0.7.6/tests/xml2sexprdata/xml2sexpr-disk-block-shareable.sexpr
===================================================================
--- libvirt-0.7.6.orig/tests/xml2sexprdata/xml2sexpr-disk-block-shareable.sexpr
+++ libvirt-0.7.6/tests/xml2sexprdata/xml2sexpr-disk-block-shareable.sexpr
@@ -1 +1 @@
-(vm (name 'pvtest')(memory 384)(maxmem 512)(vcpus 1)(uuid '49a0c6ff-c066-5392-6498-3632d093c2e7')(bootloader '/usr/bin/pygrub')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(device (tap (dev 'xvda')(uname 'tap:aio:/var/lib/xen/images/rhel5pv.img')(mode 'w!')))(device (vif (mac '00:16:3e:23:9e:eb')(bridge 'xenbr0')(script 'vif-bridge'))))
\ No newline at end of file
+(vm (name 'pvtest')(memory 384)(maxmem 512)(vcpus 1)(uuid '49a0c6ff-c066-5392-6498-3632d093c2e7')(bootloader '/usr/bin/pygrub')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (linux (args 'ro root=/dev/VolGroup00/LogVol00')))(device (tap (dev 'xvda')(uname 'tap:aio:/var/lib/xen/images/rhel5pv.img')(mode 'w!')))(device (vif (mac '00:16:3e:23:9e:eb')(bridge 'xenbr0')(script 'vif-bridge'))))
\ No newline at end of file
Index: libvirt-0.7.6/tests/xml2sexprdata/xml2sexpr-pv-bootloader-cmdline.sexpr
===================================================================
--- /dev/null
+++ libvirt-0.7.6/tests/xml2sexprdata/xml2sexpr-pv-bootloader-cmdline.sexpr
@@ -0,0 +1 @@
+(vm (name 'pvtest')(memory 420)(maxmem 420)(vcpus 2)(uuid '596a5d21-71f4-8fb2-e068-e2386a5c413e')(bootloader '/usr/bin/pygrub')(bootloader_args '-q')(on_poweroff 'destroy')(on_reboot 'destroy')(on_crash 'destroy')(image (linux (args 'xenfb.video=8,1280,1024')))(device (vbd (dev 'xvda')(uname 'file:/root/some.img')(mode 'w'))))
\ No newline at end of file
Index: libvirt-0.7.6/tests/xml2sexprdata/xml2sexpr-pv-bootloader-cmdline.xml
===================================================================
--- /dev/null
+++ libvirt-0.7.6/tests/xml2sexprdata/xml2sexpr-pv-bootloader-cmdline.xml
@@ -0,0 +1,22 @@
+<domain type='xen' id='15'>
+  <name>pvtest</name>
+  <uuid>596a5d2171f48fb2e068e2386a5c413e</uuid>
+  <bootloader>/usr/bin/pygrub</bootloader>
+  <bootloader_args>-q</bootloader_args>
+ <os>
+    <type>linux</type>
+    <cmdline>xenfb.video=8,1280,1024</cmdline>
+  </os>
+  <memory>430080</memory>
+  <vcpu>2</vcpu>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <source file='/root/some.img'/>
+      <target dev='xvda'/>
+    </disk>
+    <console tty='/dev/pts/4'/>
+  </devices>
+</domain>
Index: libvirt-0.7.6/tests/xml2sexprtest.c
===================================================================
--- libvirt-0.7.6.orig/tests/xml2sexprtest.c
+++ libvirt-0.7.6/tests/xml2sexprtest.c
@@ -113,6 +113,7 @@ mymain(int argc, char **argv)
     DO_TEST("pv-vfb-new", "pv-vfb-new", "pvtest", 3);
     DO_TEST("pv-vfb-new-auto", "pv-vfb-new-auto", "pvtest", 3);
     DO_TEST("pv-bootloader", "pv-bootloader", "pvtest", 1);
+    DO_TEST("pv-bootloader-cmdline", "pv-bootloader-cmdline", "pvtest", 1);
 
     DO_TEST("disk-file", "disk-file", "pvtest", 2);
     DO_TEST("disk-block", "disk-block", "pvtest", 2);
Index: libvirt-0.7.6/src/xen/xend_internal.c
===================================================================
--- libvirt-0.7.6.orig/src/xen/xend_internal.c
+++ libvirt-0.7.6/src/xen/xend_internal.c
@@ -6030,6 +6030,12 @@ xenDaemonFormatSxpr(virConnectPtr conn,
         }
 
         virBufferAddLit(&buf, "))");
+    } else {
+        /* PV domains accept kernel cmdline args */
+        if (def->os.cmdline) {
+            virBufferVSprintf(&buf, "(image (linux (args '%s')))",
+                              def->os.cmdline);
+        }
     }
 
     for (i = 0 ; i < def->ndisks ; i++)
