]> Git Repo - qemu.git/commitdiff
qga-win: prevent crash when executing fsinfo command
authorSameeh Jubran <[email protected]>
Tue, 23 Oct 2018 11:23:13 +0000 (13:23 +0200)
committerMichael Roth <[email protected]>
Wed, 31 Oct 2018 14:04:20 +0000 (09:04 -0500)
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 <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
Signed-off-by: Tomáš Golembiovský <[email protected]>
Signed-off-by: Michael Roth <[email protected]>
qga/commands-win32.c

index 347577f2a4ba7f9b19f26f9416029f6c0d2b8430..f0e6f6128b862742872b0a6b03109824d7b3f899 100644 (file)
@@ -499,6 +499,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");
@@ -570,7 +575,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;
This page took 0.027528 seconds and 4 git commands to generate.