Re: [PATCH 1/7] conf: move DevicePCIAddress functions to separate file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08/16/2012 12:12 PM, Laine Stump wrote:
> On 08/16/2012 11:41 AM, Shradha Shah wrote:
>> Move the functions the parse/format, and validate PCI addresses to
>> their own file so they can be conveniently used in other places
>> besides device_conf.c
>>
>> Refactoring existing code without causing any functional changes to
>> prepare for new code.
>>
>> This patch makes the code reusable.
>>
>> Signed-off-by: Shradha Shah <sshah@xxxxxxxxxxxxxx>
> ACK. You've taken care of all my nits from the previous version.
>

Actually, make check was failing on a bunch of cases. But it turned out
to just be that the <address> line was indented 4 extra spaces instead
of two. I'll squash in this change when I push:

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index ca600c5..aefffec 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -120,7 +120,7 @@ virDevicePCIAddressFormat(virBufferPtr buf,
                           virDevicePCIAddress addr,
                           bool includeTypeInAddr)
 {
-    virBufferAsprintf(buf, "    <address %sdomain='0x%.4x' bus='0x%.2x' "
+    virBufferAsprintf(buf, "<address %sdomain='0x%.4x' bus='0x%.2x' "
                       "slot='0x%.2x' function='0x%.1x'/>\n",
                       includeTypeInAddr ? "type='pci' " : "",
                       addr.domain,
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 78d5685..ff225e6 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11435,18 +11435,19 @@ virDomainHostdevSourceFormat(virBufferPtr buf,
                              bool includeTypeInAddr)
 {
     virBufferAddLit(buf, "<source>\n");
+    virBufferAdjustIndent(buf, 2);
     switch (def->source.subsys.type)
     {
     case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
         if (def->source.subsys.u.usb.vendor) {
-            virBufferAsprintf(buf, "  <vendor id='0x%.4x'/>\n",
+            virBufferAsprintf(buf, "<vendor id='0x%.4x'/>\n",
                               def->source.subsys.u.usb.vendor);
-            virBufferAsprintf(buf, "  <product id='0x%.4x'/>\n",
+            virBufferAsprintf(buf, "<product id='0x%.4x'/>\n",
                               def->source.subsys.u.usb.product);
         }
         if (def->source.subsys.u.usb.bus ||
             def->source.subsys.u.usb.device) {
-            virBufferAsprintf(buf, "  <address %sbus='%d' device='%d'/>\n",
+            virBufferAsprintf(buf, "<address %sbus='%d' device='%d'/>\n",
                               includeTypeInAddr ? "type='usb' " : "",
                               def->source.subsys.u.usb.bus,
                               def->source.subsys.u.usb.device);
@@ -11463,14 +11464,14 @@ virDomainHostdevSourceFormat(virBufferPtr buf,
             (def->origstates.states.pci.unbind_from_stub ||
              def->origstates.states.pci.remove_slot ||
              def->origstates.states.pci.reprobe)) {
-            virBufferAddLit(buf, "  <origstates>\n");
+            virBufferAddLit(buf, "<origstates>\n");
             if (def->origstates.states.pci.unbind_from_stub)
-                virBufferAddLit(buf, "    <unbind/>\n");
+                virBufferAddLit(buf, "  <unbind/>\n");
             if (def->origstates.states.pci.remove_slot)
-                virBufferAddLit(buf, "    <removeslot/>\n");
+                virBufferAddLit(buf, "  <removeslot/>\n");
             if (def->origstates.states.pci.reprobe)
-                virBufferAddLit(buf, "    <reprobe/>\n");
-            virBufferAddLit(buf, "  </origstates>\n");
+                virBufferAddLit(buf, "  <reprobe/>\n");
+            virBufferAddLit(buf, "</origstates>\n");
         }
         break;
     default:
@@ -11480,6 +11481,7 @@ virDomainHostdevSourceFormat(virBufferPtr buf,
         return -1;
     }
 
+    virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</source>\n");
     return 0;
 }

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]