Re: [libvirt] [PATCHv2 2/5] smbios: support system family

2010-12-05 Thread Daniel Veillard
On Fri, Dec 03, 2010 at 02:56:15PM -0700, Eric Blake wrote:
> * 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.

  ACK, I wasn't sure it was really useful,

Daniel

-- 
Daniel Veillard  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
dan...@veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

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


[libvirt] [PATCHv2 2/5] smbios: support system family

2010-12-03 Thread Eric Blake
* 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 |1 +
 src/conf/domain_conf.c  |9 -
 src/qemu/qemu_conf.c|6 +-
 src/util/sysinfo.c  |7 +++
 src/util/sysinfo.h  |1 +
 tests/qemuxml2argvdata/qemuxml2argv-smbios.args |2 +-
 tests/qemuxml2argvdata/qemuxml2argv-smbios.xml  |2 ++
 7 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 08ebefb..3dd7aa3 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1875,6 +1875,7 @@
   serial
   uuid
   sku
+  family
 
   

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9516427..3dfd4ee 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3625,6 +3625,8 @@ virSysinfoParseXML(const xmlNodePtr node,
 virXPathString("string(system/ent...@name='uuid'])", ctxt);
 def->system_sku =
 virXPathString("string(system/ent...@name='sku'])", ctxt);
+def->system_family =
+virXPathString("string(system/ent...@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, "\n");
 if (def->system_manufacturer != NULL)
 virBufferEscapeString(buf,
@@ -6451,6 +6454,10 @@ virDomainSysinfoDefFormat(virBufferPtr buf,
 virBufferEscapeString(buf,
   "  %s\n",
   def->system_sku);
+if (def->system_family != NULL)
+virBufferEscapeString(buf,
+  "  %s\n",
+  def->system_family);
 virBufferAddLit(buf, "\n");
 }

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 8985241..9a9d924 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -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();
diff --git a/src/util/sysinfo.c b/src/util/sysinfo.c
index 8ad98fe..cf41773 100644
--- a/src/util/sysinfo.c
+++ b/src/util/sysinfo.c
@@ -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);
diff --git a/src/util/sysinfo.h b/src/util/sysinfo.h
index 611d54e..1af7ef6 100644
--- a/src/util/sysinfo.h
+++ b/src/util/sysinfo.h
@@ -49,6 +49,7 @@ struct _virSysinfoDef {
 char *system_serial;
 char *system_uuid;
 char *system_sku;
+char *system_family;
 };

 virSysinfoDefPtr virSysinfoRead(void);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args 
b/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
index bd3ede4..b5e4783 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-smbios.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv