From: Carlos Bilbao <cbilbao@digitalocean.com>
To: virtualization@lists.linux-foundation.org, mst@redhat.com,
jasowang@redhat.com
Cc: kvm@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [RFC] vDPA: Trying to make sense of config data
Date: Thu, 22 Aug 2024 13:21:13 -0500 [thread overview]
Message-ID: <4f4572c8-1d8c-4ec6-96a1-fb74848475af@digitalocean.com> (raw)
Hello folks,
I'm using the code below to retrieve configuration data for my vDPA file
via ioctl. I get as output:
Configuration data (24 bytes):
5a c3 5f 68 48 a9 01 00 08 00 dc 05 00 00 00 00
00 00 00 00 00 00 00 00
ASCII representation:
Z._hH...................
Could a good Samaritan point me in the right direction for the docs I need
to understand these values and convert them to a human-readable format?
hank you in advance!
Regards,
Carlos
---
void check_config(int fd) {
uint32_t size;
struct vhost_vdpa_config *config;
uint8_t *buf;
if (ioctl(fd, VHOST_VDPA_GET_CONFIG_SIZE, &size) < 0) {
perror("ioctl failed");
return;
}
config = malloc(sizeof(struct vhost_vdpa_config) + size);
if (!config) {
perror("malloc failed");
return;
}
memset(config, 0, sizeof(struct vhost_vdpa_config) + size);
config->len = size;
config->off = 0;
buf = config->buf;
if (ioctl(fd, VHOST_VDPA_GET_CONFIG, config) < 0) {
perror("ioctl failed");
} else {
printf("Configuration data (%u bytes):\n", size);
/* Print the data in a human-readable format */
for (unsigned int i = 0; i < size; i++) {
if (i % 16 == 0 && i != 0) printf("\n");
printf("%02x ", buf[i]);
}
printf("\n");
printf("ASCII representation:\n");
for (unsigned int i = 0; i < size; i++) {
if (buf[i] >= 32 && buf[i] <= 126) {
printf("%c", buf[i]);
} else {
printf(".");
}
}
printf("\n");
}
free(config);
}
next reply other threads:[~2024-08-22 18:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 18:21 Carlos Bilbao [this message]
2024-08-23 14:51 ` Carlos Bilbao
2024-08-27 18:16 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4f4572c8-1d8c-4ec6-96a1-fb74848475af@digitalocean.com \
--to=cbilbao@digitalocean.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®