c401cc
From 801bda8e304ca35628ec6bc2cb367f9537a6cd31 Mon Sep 17 00:00:00 2001
c401cc
Message-Id: <801bda8e304ca35628ec6bc2cb367f9537a6cd31@dist-git>
c401cc
From: Doug Goldstein <cardoe@cardoe.com>
c401cc
Date: Wed, 26 Feb 2014 14:54:07 +0100
c401cc
Subject: [PATCH] Allow <source> for type=block to have no dev
c401cc
c401cc
https://bugzilla.redhat.com/show_bug.cgi?id=1032370
c401cc
c401cc
Currently the XML parser already allows the following syntax:
c401cc
  <disk type='block' device='cdrom'>
c401cc
    <source startupPolicy='optional'/>
c401cc
    <target dev='hda' bus='ide'/>
c401cc
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
c401cc
  </disk>
c401cc
c401cc
But it if the dev value is NULL then it would not have the leading
c401cc
"
c401cc
c401cc
(cherry picked from commit 4b5652d0dcb2d53fd4240f589a63aaa434650fe0)
c401cc
c401cc
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c401cc
---
c401cc
 docs/schemas/domaincommon.rng | 8 +++++---
c401cc
 src/conf/domain_conf.c        | 4 ++--
c401cc
 2 files changed, 7 insertions(+), 5 deletions(-)
c401cc
c401cc
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
c401cc
index 551e82b..a8f1d71 100644
c401cc
--- a/docs/schemas/domaincommon.rng
c401cc
+++ b/docs/schemas/domaincommon.rng
c401cc
@@ -1161,9 +1161,11 @@
c401cc
           <interleave>
c401cc
             <optional>
c401cc
               <element name="source">
c401cc
-                <attribute name="dev">
c401cc
-                  <ref name="absFilePath"/>
c401cc
-                </attribute>
c401cc
+                <optional>
c401cc
+                  <attribute name="dev">
c401cc
+                    <ref name="absFilePath"/>
c401cc
+                  </attribute>
c401cc
+                </optional>
c401cc
                 <optional>
c401cc
                   <ref name="startupPolicy"/>
c401cc
                 </optional>
c401cc
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
c401cc
index b612f3a..7e43232 100644
c401cc
--- a/src/conf/domain_conf.c
c401cc
+++ b/src/conf/domain_conf.c
c401cc
@@ -14467,8 +14467,8 @@ virDomainDiskSourceDefFormat(virBufferPtr buf,
c401cc
             }
c401cc
             break;
c401cc
         case VIR_DOMAIN_DISK_TYPE_BLOCK:
c401cc
-            virBufferEscapeString(buf, "      
c401cc
-                                  def->src);
c401cc
+            virBufferAddLit(buf, "      
c401cc
+            virBufferEscapeString(buf, " dev='%s'", def->src);
c401cc
             if (def->startupPolicy)
c401cc
                 virBufferEscapeString(buf, " startupPolicy='%s'",
c401cc
                                       startupPolicy);
c401cc
-- 
c401cc
1.9.0
c401cc