~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to .pc/ubuntu/CVE-2013-4377.patch/tests/qdev-monitor-test.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-02-04 12:13:08 UTC
  • mfrom: (10.1.45 sid)
  • Revision ID: package-import@ubuntu.com-20140204121308-1xq92lrfs75agw2g
Tags: 1.7.0+dfsg-3ubuntu1~ppa1
* Merge 1.7.0+dfsg-3 from debian.  Remaining changes:
  - debian/patches/ubuntu:
    * expose-vmx_qemu64cpu.patch
    * linaro (omap3) and arm64 patches
    * ubuntu/target-ppc-add-stubs-for-kvm-breakpoints: fix FTBFS
      on ppc
    * ubuntu/CVE-2013-4377.patch: fix denial of service via virtio
  - debian/qemu-system-x86.modprobe: set kvm_intel nested=1 options
  - debian/control:
    * add arm64 to Architectures
    * add qemu-common and qemu-system-aarch64 packages
  - debian/qemu-system-common.install: add debian/tmp/usr/lib
  - debian/qemu-system-common.preinst: add kvm group
  - debian/qemu-system-common.postinst: remove acl placed by udev,
    and add udevadm trigger.
  - qemu-system-x86.links: add eepro100.rom, remove pxe-virtio,
    pxe-e1000 and pxe-rtl8139.
  - add qemu-system-x86.qemu-kvm.upstart and .default
  - qemu-user-static.postinst-in: remove arm64 binfmt
  - debian/rules:
    * allow parallel build
    * add aarch64 to system_targets and sys_systems
    * add qemu-kvm-spice links
    * install qemu-system-x86.modprobe
  - add debian/qemu-system-common.links for OVMF.fd link
* Remove kvm-img, kvm-nbd, kvm-ifup and kvm-ifdown symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * qdev-monitor.c test cases
 
3
 *
 
4
 * Copyright (C) 2013 Red Hat Inc.
 
5
 *
 
6
 * Authors:
 
7
 *  Stefan Hajnoczi <stefanha@redhat.com>
 
8
 *
 
9
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
 
10
 * See the COPYING.LIB file in the top-level directory.
 
11
 */
 
12
 
 
13
#include <string.h>
 
14
#include <glib.h>
 
15
#include "libqtest.h"
 
16
#include "qapi/qmp/qjson.h"
 
17
 
 
18
static void test_device_add(void)
 
19
{
 
20
    QDict *response;
 
21
    QDict *error;
 
22
 
 
23
    qtest_start("-drive if=none,id=drive0");
 
24
 
 
25
    /* Make device_add fail.  If this leaks the virtio-blk-pci device then a
 
26
     * reference to drive0 will also be held (via qdev properties).
 
27
     */
 
28
    response = qmp("{\"execute\": \"device_add\","
 
29
                   " \"arguments\": {"
 
30
                   "   \"driver\": \"virtio-blk-pci\","
 
31
                   "   \"drive\": \"drive0\""
 
32
                   "}}");
 
33
    g_assert(response);
 
34
    error = qdict_get_qdict(response, "error");
 
35
    g_assert(!strcmp(qdict_get_try_str(error, "class") ?: "",
 
36
                     "GenericError"));
 
37
    g_assert(!strcmp(qdict_get_try_str(error, "desc") ?: "",
 
38
                     "Device initialization failed."));
 
39
    QDECREF(response);
 
40
 
 
41
    /* Delete the drive */
 
42
    response = qmp("{\"execute\": \"human-monitor-command\","
 
43
                   " \"arguments\": {"
 
44
                   "   \"command-line\": \"drive_del drive0\""
 
45
                   "}}");
 
46
    g_assert(response);
 
47
    g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "(null)", ""));
 
48
    QDECREF(response);
 
49
 
 
50
    /* Try to re-add the drive.  This fails with duplicate IDs if a leaked
 
51
     * virtio-blk-pci exists that holds a reference to the old drive0.
 
52
     */
 
53
    response = qmp("{\"execute\": \"human-monitor-command\","
 
54
                   " \"arguments\": {"
 
55
                   "   \"command-line\": \"drive_add pci-addr=auto if=none,id=drive0\""
 
56
                   "}}");
 
57
    g_assert(response);
 
58
    g_assert(!strcmp(qdict_get_try_str(response, "return") ?: "",
 
59
                     "OK\r\n"));
 
60
    QDECREF(response);
 
61
 
 
62
    qtest_end();
 
63
}
 
64
 
 
65
int main(int argc, char **argv)
 
66
{
 
67
    const char *arch = qtest_get_arch();
 
68
 
 
69
    /* Check architecture */
 
70
    if (strcmp(arch, "i386") && strcmp(arch, "x86_64")) {
 
71
        g_test_message("Skipping test for non-x86\n");
 
72
        return 0;
 
73
    }
 
74
 
 
75
    /* Run the tests */
 
76
    g_test_init(&argc, &argv, NULL);
 
77
 
 
78
    qtest_add_func("/qmp/device_add", test_device_add);
 
79
 
 
80
    return g_test_run();
 
81
}