* [PATCH] hvmloader: support system enclosure asset tag (SMBIOS type 3)
@ 2017-08-21 8:16 VIVEK KUMAR CHAUBEY
2017-08-21 8:40 ` Jan Beulich
0 siblings, 1 reply; 2+ messages in thread
From: VIVEK KUMAR CHAUBEY @ 2017-08-21 8:16 UTC (permalink / raw)
To: xen-devel; +Cc: andrew.cooper3, Vivek Kumar Chaubey
From: Vivek Kumar Chaubey <vivekkumar.chaubey@citrix.com>
Allow setting System Enclosure Asset Tag for HVM guest. Guest OS can
check and perform desired operation like support installation.
Signed-off-by: Vivek Kumar Chaubey <vivekkumar.chaubey@citrix.com>
---
tools/firmware/hvmloader/smbios.c | 14 +++++++++++---
xen/include/public/hvm/hvm_xs_strings.h | 1 +
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c
index 210c7b0..805bf95 100644
--- a/tools/firmware/hvmloader/smbios.c
+++ b/tools/firmware/hvmloader/smbios.c
@@ -531,6 +531,7 @@ smbios_type_3_init(void *start)
const char *s;
void *pts;
uint32_t length;
+ uint32_t counter = 1;
pts = get_smbios_pt_struct(3, &length);
if ( (pts != NULL)&&(length > 0) )
@@ -546,7 +547,7 @@ smbios_type_3_init(void *start)
p->header.length = sizeof(struct smbios_type_3);
p->header.handle = SMBIOS_HANDLE_TYPE3;
- p->manufacturer_str = 1;
+ p->manufacturer_str = counter++;
p->type = 0x01; /* other */
p->version_str = 0;
p->serial_number_str = 0;
@@ -562,13 +563,20 @@ smbios_type_3_init(void *start)
strcpy((char *)start, s);
start += strlen(s) + 1;
- /* No internal defaults for this if the value is not set */
+ /* No internal defaults for followings if the value is not set */
s = xenstore_read(HVM_XS_ENCLOSURE_SERIAL_NUMBER, NULL);
if ( (s != NULL)&&(*s != '\0') )
{
strcpy((char *)start, s);
start += strlen(s) + 1;
- p->serial_number_str = 2;
+ p->serial_number_str = counter++;
+ }
+ s = xenstore_read(HVM_XS_ENCLOSURE_ASSET_TAG, NULL);
+ if ( (s != NULL)&&(*s != '\0') )
+ {
+ strcpy((char *)start, s);
+ start += strlen(s) + 1;
+ p->asset_tag_str = counter++;
}
*((uint8_t *)start) = 0;
diff --git a/xen/include/public/hvm/hvm_xs_strings.h b/xen/include/public/hvm/hvm_xs_strings.h
index 146b0b0..fea1dd4 100644
--- a/xen/include/public/hvm/hvm_xs_strings.h
+++ b/xen/include/public/hvm/hvm_xs_strings.h
@@ -71,6 +71,7 @@
#define HVM_XS_SYSTEM_SERIAL_NUMBER "bios-strings/system-serial-number"
#define HVM_XS_ENCLOSURE_MANUFACTURER "bios-strings/enclosure-manufacturer"
#define HVM_XS_ENCLOSURE_SERIAL_NUMBER "bios-strings/enclosure-serial-number"
+#define HVM_XS_ENCLOSURE_ASSET_TAG "bios-strings/enclosure-asset-tag"
#define HVM_XS_BATTERY_MANUFACTURER "bios-strings/battery-manufacturer"
#define HVM_XS_BATTERY_DEVICE_NAME "bios-strings/battery-device-name"
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hvmloader: support system enclosure asset tag (SMBIOS type 3)
2017-08-21 8:16 [PATCH] hvmloader: support system enclosure asset tag (SMBIOS type 3) VIVEK KUMAR CHAUBEY
@ 2017-08-21 8:40 ` Jan Beulich
0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2017-08-21 8:40 UTC (permalink / raw)
To: VIVEK KUMAR CHAUBEY; +Cc: andrew.cooper3, xen-devel, Vivek Kumar Chaubey
>>> On 21.08.17 at 10:16, <vivek.kumar.chaubey@gmail.com> wrote:
> --- a/tools/firmware/hvmloader/smbios.c
> +++ b/tools/firmware/hvmloader/smbios.c
> @@ -531,6 +531,7 @@ smbios_type_3_init(void *start)
> const char *s;
> void *pts;
> uint32_t length;
> + uint32_t counter = 1;
I think having the counter start at zero (using ++counter
everywhere below) would be more natural.
> @@ -562,13 +563,20 @@ smbios_type_3_init(void *start)
> strcpy((char *)start, s);
> start += strlen(s) + 1;
>
> - /* No internal defaults for this if the value is not set */
> + /* No internal defaults for followings if the value is not set */
s/followings/following ones/ ?
> s = xenstore_read(HVM_XS_ENCLOSURE_SERIAL_NUMBER, NULL);
> if ( (s != NULL)&&(*s != '\0') )
> {
> strcpy((char *)start, s);
> start += strlen(s) + 1;
> - p->serial_number_str = 2;
> + p->serial_number_str = counter++;
> + }
> + s = xenstore_read(HVM_XS_ENCLOSURE_ASSET_TAG, NULL);
> + if ( (s != NULL)&&(*s != '\0') )
Please don't copy style violations (here: missing blanks) or ...
> + {
> + strcpy((char *)start, s);
... things rendering the code fragile (here: pointless cast).
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-21 8:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-21 8:16 [PATCH] hvmloader: support system enclosure asset tag (SMBIOS type 3) VIVEK KUMAR CHAUBEY
2017-08-21 8:40 ` Jan Beulich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).