]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
smbios: support system family
authorEric Blake <eblake@redhat.com>
Thu, 2 Dec 2010 00:07:41 +0000 (17:07 -0700)
committerEric Blake <eblake@redhat.com>
Tue, 7 Dec 2010 15:49:45 +0000 (08:49 -0700)
* docs/schemas/domain.rng (sysinfo-system-name): Also allow
family.
* src/util/sysinfo.h (struct _virSysinfoDef): Add system_family.
* src/conf/domain_conf.c (virSysinfoParseXML)
(virDomainSysinfoDefFormat): Support it.
* src/util/sysinfo.c (virSysinfoDefFree, virSysinfoRead): Likewise.
* src/qemu/qemu_conf.c (qemuBuildSmbiosSystemStr): Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.xml: Adjust test.
* tests/qemuxml2argvdata/qemuxml2argv-smbios.args: Likewise.

docs/schemas/domain.rng
src/conf/domain_conf.c
src/qemu/qemu_conf.c
src/util/sysinfo.c
src/util/sysinfo.h
tests/qemuxml2argvdata/qemuxml2argv-smbios.args
tests/qemuxml2argvdata/qemuxml2argv-smbios.xml

index 08ebefbec1fc6119ddef4656def54bbe25b6ee8d..3dd7aa354bf52923fd3dcf09bcfa1d5bd12da9e3 100644 (file)
       <value>serial</value>
       <value>uuid</value>
       <value>sku</value>
+      <value>family</value>
     </choice>
   </define>
 
index 9516427f4390088622c3c63aca6b74c058c60f1c..3dfd4eeb88d3667bed33f1b84d8c5e418392ab49 100644 (file)
@@ -3625,6 +3625,8 @@ virSysinfoParseXML(const xmlNodePtr node,
         virXPathString("string(system/entry[@name='uuid'])", ctxt);
     def->system_sku =
         virXPathString("string(system/entry[@name='sku'])", ctxt);
+    def->system_family =
+        virXPathString("string(system/entry[@name='family'])", ctxt);
 
 cleanup:
     VIR_FREE(type);
@@ -6425,7 +6427,8 @@ virDomainSysinfoDefFormat(virBufferPtr buf,
     }
     if ((def->system_manufacturer != NULL) || (def->system_product != NULL) ||
         (def->system_version != NULL) || (def->system_serial != NULL) ||
-        (def->system_uuid != NULL) || (def->system_sku != NULL)) {
+        (def->system_uuid != NULL) || (def->system_sku != NULL) ||
+        (def->system_family != NULL)) {
         virBufferAddLit(buf, "    <system>\n");
         if (def->system_manufacturer != NULL)
             virBufferEscapeString(buf,
@@ -6451,6 +6454,10 @@ virDomainSysinfoDefFormat(virBufferPtr buf,
             virBufferEscapeString(buf,
                                   "      <entry name='sku'>%s</entry>\n",
                                   def->system_sku);
+        if (def->system_family != NULL)
+            virBufferEscapeString(buf,
+                                  "      <entry name='family'>%s</entry>\n",
+                                  def->system_family);
         virBufferAddLit(buf, "    </system>\n");
     }
 
index 69f3652a698e35e996ef883cd9f6f1d67dcb5b6a..ba34b649c9a658f7e24bf08e1135223d3e7f0962 100644 (file)
@@ -3651,7 +3651,8 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr def)
 
     if ((def->system_manufacturer == NULL) && (def->system_sku == NULL) &&
         (def->system_product == NULL) && (def->system_uuid == NULL) &&
-        (def->system_version == NULL) && (def->system_serial == NULL))
+        (def->system_version == NULL) && (def->system_serial == NULL) &&
+        (def->system_family == NULL))
         return(NULL);
 
     virBufferAddLit(&buf, "type=1");
@@ -3675,6 +3676,9 @@ static char *qemuBuildSmbiosSystemStr(virSysinfoDefPtr def)
     /* 1:SKU Number */
     if (def->system_sku)
         virBufferVSprintf(&buf, ",sku=%s", def->system_sku);
+    /* 1:Family */
+    if (def->system_family)
+        virBufferVSprintf(&buf, ",family=%s", def->system_family);
 
     if (virBufferError(&buf)) {
         virReportOOMError();
index 8ad98fe20c226cec6fd6914a5d93341e8eca29e1..cf417736b1b14f570c3cd13ecfb238fd80ea349f 100644 (file)
@@ -68,6 +68,7 @@ void virSysinfoDefFree(virSysinfoDefPtr def)
     VIR_FREE(def->system_serial);
     VIR_FREE(def->system_uuid);
     VIR_FREE(def->system_sku);
+    VIR_FREE(def->system_family);
     VIR_FREE(def);
 }
 
@@ -217,6 +218,12 @@ virSysinfoRead(void) {
         if ((eol) && ((ret->system_sku = strndup(cur, eol - cur)) == NULL))
                 goto no_memory;
     }
+    if ((cur = strstr(base, "Family: ")) != NULL) {
+        cur += 8;
+        eol = strchr(cur, '\n');
+        if ((eol) && ((ret->system_family = strndup(cur, eol - cur)) == NULL))
+                goto no_memory;
+    }
 
 cleanup:
     VIR_FREE(outbuf);
index 611d54e79dbb388f7647c1f48e909decd241ff49..1af7ef6f73671d3d7f4008f3ae915ad746c1dad3 100644 (file)
@@ -49,6 +49,7 @@ struct _virSysinfoDef {
     char *system_serial;
     char *system_uuid;
     char *system_sku;
+    char *system_family;
 };
 
 virSysinfoDefPtr virSysinfoRead(void);
index bd3ede4310b8387997a4bd92741961fe5298fea0..b5e4783229bbe6418d81ad7a2e42ee73935b8d82 100644 (file)
@@ -1 +1 @@
-LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -smbios type=0,vendor=QEmu/KVM,version=0.13 -smbios type=1,manufacturer=Fedora,product=Virt-Manager,version=0.8.2-3.fc14,serial=32dfcb37-5af1-552b-357c-be8c3aa38310,uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M pc -m 214 -smp 1 -smbios type=0,vendor=QEmu/KVM,version=0.13 -smbios type=1,manufacturer=Fedora,product=Virt-Manager,version=0.8.2-3.fc14,serial=32dfcb37-5af1-552b-357c-be8c3aa38310,uuid=c7a5fdbd-edaf-9455-926a-d65c16db1809,sku=1234567890,family=Red Hat -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
index 66cbbb08ea5a7082eed5377c9062c0d77435bb83..45b6dbae60941d0fa17432df570df46cc460c55b 100644 (file)
@@ -15,6 +15,8 @@
       <entry name="version">0.8.2-3.fc14</entry>
       <entry name="serial">32dfcb37-5af1-552b-357c-be8c3aa38310</entry>
       <entry name="uuid">c7a5fdbd-edaf-9455-926a-d65c16db1809</entry>
+      <entry name="sku">1234567890</entry>
+      <entry name="family">Red Hat</entry>
     </system>
   </sysinfo>
   <os>