thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qdev-Do-not-let-the-user-try-to-device_add-when-it.2.patch.patch

0a122b
From 48aa83a2a3e42665e3e3e390909ebc147e234f73 Mon Sep 17 00:00:00 2001
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Fri, 17 Jan 2014 17:07:57 +0100
0a122b
Subject: [PATCH 07/11] qdev: Do not let the user try to device_add when it cannot work
0a122b
MIME-Version: 1.0
0a122b
Content-Type: text/plain; charset=UTF-8
0a122b
Content-Transfer-Encoding: 8bit
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1389978479-30595-8-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 56788
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 7/9] qdev: Do not let the user try to device_add when it cannot work
0a122b
Bugzilla: 669524
0a122b
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
0a122b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
0a122b
Such devices have always been unavailable and omitted from the list of
0a122b
available devices shown by device_add help.  Until commit 18b6dad
0a122b
silently broke the former, setting up nasty traps for unwary users,
0a122b
like this one:
0a122b
0a122b
    $ qemu-system-x86_64 -nodefaults -monitor stdio -display none
0a122b
    QEMU 1.6.50 monitor - type 'help' for more information
0a122b
    (qemu) device_add apic
0a122b
    Segmentation fault (core dumped)
0a122b
0a122b
I call that a regression.  Fix it.
0a122b
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
Reviewed-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
Signed-off-by: Andreas Färber <afaerber@suse.de>
0a122b
(cherry picked from commit 7ea5e78f3d8d64e99c4017ea211b7518f2629756)
0a122b
---
0a122b
 qdev-monitor.c | 5 +++++
0a122b
 1 file changed, 5 insertions(+)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 qdev-monitor.c |    5 +++++
0a122b
 1 files changed, 5 insertions(+), 0 deletions(-)
0a122b
0a122b
diff --git a/qdev-monitor.c b/qdev-monitor.c
0a122b
index eb05b4c..da7fe0d 100644
0a122b
--- a/qdev-monitor.c
0a122b
+++ b/qdev-monitor.c
0a122b
@@ -490,6 +490,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
0a122b
     }
0a122b
 
0a122b
     dc = DEVICE_CLASS(oc);
0a122b
+    if (dc->cannot_instantiate_with_device_add_yet) {
0a122b
+        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
0a122b
+                      "pluggable device type");
0a122b
+        return NULL;
0a122b
+    }
0a122b
 
0a122b
     /* find bus */
0a122b
     path = qemu_opt_get(opts, "bus");
0a122b
-- 
0a122b
1.7.1
0a122b