Skip to content

Commit

Permalink
qga-win: prevent crash when executing fsinfo command
Browse files Browse the repository at this point in the history
The fsinfo command is currently implemented for Windows only and it's disk
parameter can be enabled by adding the define "CONFIG_QGA_NTDDSCSI" to the qga
code. When enabled and executed the qemu-ga crashed with the following message:

------------------------------------------------
File qapi/qapi-visit-core.c, Line 49

Expression: !(v->type & VISITOR_OUTPUT) || *obj)
------------------------------------------------

After some digging, turns out that the GuestPCIAddress is null and the
qapi visitor doesn't like that, so we can always allocate it instead and
initiate all it's members to -1.

Signed-off-by: Sameeh Jubran <sjubran@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

(cherry picked from commit ecb8293d90eafde5b0423ef90aacfeff718ed913)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
  • Loading branch information
Sameeh Jubran authored and mdroth committed Sep 26, 2018
1 parent 3ac287f commit 89f145d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion qga/commands-win32.c
Expand Up @@ -486,6 +486,11 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)
char *buffer = NULL;
GuestPCIAddress *pci = NULL;
char *name = g_strdup(&guid[4]);
pci = g_malloc0(sizeof(*pci));
pci->domain = -1;
pci->slot = -1;
pci->function = -1;
pci->bus = -1;

if (!QueryDosDevice(name, dev_name, ARRAY_SIZE(dev_name))) {
error_setg_win32(errp, GetLastError(), "failed to get dos device name");
Expand Down Expand Up @@ -557,7 +562,6 @@ static GuestPCIAddress *get_pci_info(char *guid, Error **errp)

func = addr & 0x0000FFFF;
dev = (addr >> 16) & 0x0000FFFF;
pci = g_malloc0(sizeof(*pci));
pci->domain = dev;
pci->slot = slot;
pci->function = func;
Expand Down

0 comments on commit 89f145d

Please sign in to comment.