[Qemu-devel] [PATCH] monitor: vnc: Fix compilation error if CONFIG_VNC is disable
How to reproduce it? === ``` $ ./configure --disable-spice --disable-vte --disable-vnc \ --disable-vnc-jpeg --disable-vnc-png --disable-vnc-sasl $ make ... monitor/hmp-cmds.c: In function ‘hmp_change’: monitor/hmp-cmds.c:1985:17: error: unused variable ‘hmp_mon’ [-Werror=unused-variable] MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common); ``` Fix === Move `hmp_mon` variable within the `CONFIG_VNC` block Signed-off-by: Julio Montes --- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 9de35387c3..5ed564683e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1982,7 +1982,6 @@ static void hmp_change_read_arg(void *opaque, const char *password, void hmp_change(Monitor *mon, const QDict *qdict) { -MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common); const char *device = qdict_get_str(qdict, "device"); const char *target = qdict_get_str(qdict, "target"); const char *arg = qdict_get_try_str(qdict, "arg"); @@ -1991,6 +1990,7 @@ void hmp_change(Monitor *mon, const QDict *qdict) Error *err = NULL; #ifdef CONFIG_VNC +MonitorHMP *hmp_mon = container_of(mon, MonitorHMP, common); if (strcmp(device, "vnc") == 0) { if (read_only) { monitor_printf(mon, -- 2.17.2
[Qemu-devel] [PATCH] hw/i386: Fix linker error when ISAPC is disabled
In pc_init1(), ISA IDE is initialized without checking if ISAPC or IDE_ISA configs are enabled. This results in a link error when CONFIG_ISAPC is set to 'n' in the file default-configs/i386-softmmu.mak: hw/i386/pc_piix.o: In function `pc_init1': hw/i386/pc_piix.c:261: undefined reference to `isa_ide_init' hw/i386/pc_piix.c:261: undefined reference to `isa_ide_init' Place ide_isa code under #ifdef CONFIG_IDE_ISA to fix linker errors Signed-off-by: Julio Montes --- hw/i386/pc_piix.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c07c4a5b38..b93f9327be 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -61,9 +61,11 @@ #define MAX_IDE_BUS 2 +#ifdef CONFIG_IDE_ISA static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; +#endif /* PC hardware initialisation */ static void pc_init1(MachineState *machine, @@ -254,7 +256,10 @@ static void pc_init1(MachineState *machine, } idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); -} else { +pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); +} +#ifdef CONFIG_IDE_ISA +else { for(i = 0; i < MAX_IDE_BUS; i++) { ISADevice *dev; char busname[] = "ide.0"; @@ -268,9 +273,9 @@ static void pc_init1(MachineState *machine, busname[4] = '0' + i; idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); } +pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); } - -pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); +#endif if (pcmc->pci_enabled && machine_usb(machine)) { pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); -- 2.17.2
[Qemu-devel] [PATCH] hw/i386: Fix linker error when ISAPC is disabled
How about a new header file with all devices? (see below patch) --- Makefile.target | 5 + hw/i386/pc_piix.c | 11 --- include/qemu/osdep.h | 1 + scripts/create_config | 2 ++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile.target b/Makefile.target index a6919e0caf..65eda0994d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -45,6 +45,9 @@ include $(SRC_PATH)/tests/tcg/Makefile.include config-target.h: config-target.h-timestamp config-target.h-timestamp: config-target.mak +config-devices.h: config-devices.h-timestamp +config-devices.h-timestamp: config-devices.mak + ifdef CONFIG_TRACE_SYSTEMTAP stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp $(QEMU_PROG)-log.stp @@ -170,6 +173,8 @@ generated-files-y += hmp-commands.h hmp-commands-info.h endif # CONFIG_SOFTMMU +generated-files-y += config-devices.h + dummy := $(call unnest-vars,,obj-y) all-obj-y := $(obj-y) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c07c4a5b38..b93f9327be 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -61,9 +61,11 @@ #define MAX_IDE_BUS 2 +#ifdef CONFIG_IDE_ISA static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; +#endif /* PC hardware initialisation */ static void pc_init1(MachineState *machine, @@ -254,7 +256,10 @@ static void pc_init1(MachineState *machine, } idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); -} else { +pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); +} +#ifdef CONFIG_IDE_ISA +else { for(i = 0; i < MAX_IDE_BUS; i++) { ISADevice *dev; char busname[] = "ide.0"; @@ -268,9 +273,9 @@ static void pc_init1(MachineState *machine, busname[4] = '0' + i; idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); } +pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); } - -pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); +#endif if (pcmc->pci_enabled && machine_usb(machine)) { pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index af2b91f0b8..83b49a1e63 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -30,6 +30,7 @@ #include "config-host.h" #ifdef NEED_CPU_H #include "config-target.h" +#include "config-devices.h" #else #include "exec/poison.h" #endif diff --git a/scripts/create_config b/scripts/create_config index d727e5e36e..00e86c82b0 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -58,6 +58,8 @@ case $line in name=${line%=*} echo "#define $name 1" ;; + CONFIG_*=n) # configuration +;; CONFIG_*=*) # configuration name=${line%=*} value=${line#*=} -- 2.17.2
[Qemu-devel] [PATCH v2 2/2] hw/i386: Fix linker error when ISAPC is disabled
v2: include config-devices.h to use CONFIG_IDE_ISA --- In pc_init1(), ISA IDE is initialized without checking if ISAPC or IDE_ISA configs are enabled. This results in a link error when CONFIG_ISAPC is set to 'n' in the file default-configs/i386-softmmu.mak: hw/i386/pc_piix.o: In function `pc_init1': hw/i386/pc_piix.c:261: undefined reference to `isa_ide_init' hw/i386/pc_piix.c:261: undefined reference to `isa_ide_init' Place ide_isa code under #ifdef CONFIG_IDE_ISA to fix linker errors Signed-off-by: Julio Montes --- hw/i386/pc_piix.c| 11 --- include/qemu/osdep.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index f29de58636..c7d4645a3f 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -61,9 +61,11 @@ #define MAX_IDE_BUS 2 +#ifdef CONFIG_IDE_ISA static const int ide_iobase[MAX_IDE_BUS] = { 0x1f0, 0x170 }; static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 }; static const int ide_irq[MAX_IDE_BUS] = { 14, 15 }; +#endif /* PC hardware initialisation */ static void pc_init1(MachineState *machine, @@ -254,7 +256,10 @@ static void pc_init1(MachineState *machine, } idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0"); idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1"); -} else { +pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); +} +#ifdef CONFIG_IDE_ISA +else { for(i = 0; i < MAX_IDE_BUS; i++) { ISADevice *dev; char busname[] = "ide.0"; @@ -268,9 +273,9 @@ static void pc_init1(MachineState *machine, busname[4] = '0' + i; idebus[i] = qdev_get_child_bus(DEVICE(dev), busname); } +pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); } - -pc_cmos_init(pcms, idebus[0], idebus[1], rtc_state); +#endif if (pcmc->pci_enabled && machine_usb(machine)) { pci_create_simple(pci_bus, piix3_devfn + 2, "piix3-usb-uhci"); diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index af2b91f0b8..f1c682e52c 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -29,6 +29,7 @@ #include "config-host.h" #ifdef NEED_CPU_H +#include "config-devices.h" #include "config-target.h" #else #include "exec/poison.h" -- 2.17.2
[Qemu-devel] [PATCH v2 1/2] Makefile: generate header file with the list of devices enabled
v2: generate config-devices.h which contains the list of devices enabled --- config-devices.h is an auto-generated header file that will use config-devices.mak to define the list of devices enabled. Configs that are set to 'n' are ignored. Signed-off-by: Julio Montes --- Makefile.target| 5 + scripts/clean-includes | 2 +- scripts/create_config | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile.target b/Makefile.target index a6919e0caf..65eda0994d 100644 --- a/Makefile.target +++ b/Makefile.target @@ -45,6 +45,9 @@ include $(SRC_PATH)/tests/tcg/Makefile.include config-target.h: config-target.h-timestamp config-target.h-timestamp: config-target.mak +config-devices.h: config-devices.h-timestamp +config-devices.h-timestamp: config-devices.mak + ifdef CONFIG_TRACE_SYSTEMTAP stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp $(QEMU_PROG)-log.stp @@ -170,6 +173,8 @@ generated-files-y += hmp-commands.h hmp-commands-info.h endif # CONFIG_SOFTMMU +generated-files-y += config-devices.h + dummy := $(call unnest-vars,,obj-y) all-obj-y := $(obj-y) diff --git a/scripts/clean-includes b/scripts/clean-includes index dd938daa3e..fb05a639d5 100755 --- a/scripts/clean-includes +++ b/scripts/clean-includes @@ -161,7 +161,7 @@ for f in "$@"; do # Remove includes that osdep.h already provides perl -n -i -e 'print if !/\s*#\s*include\s*(["<][^>"]*[">])/ || ! (grep { $_ eq $1 } qw ( - "config-host.h" "config-target.h" "qemu/compiler.h" + "config-host.h" "config-target.h" "config-devices.h" "qemu/compiler.h" diff --git a/scripts/create_config b/scripts/create_config index d727e5e36e..00e86c82b0 100755 --- a/scripts/create_config +++ b/scripts/create_config @@ -58,6 +58,8 @@ case $line in name=${line%=*} echo "#define $name 1" ;; + CONFIG_*=n) # configuration +;; CONFIG_*=*) # configuration name=${line%=*} value=${line#*=} -- 2.17.2
[Qemu-devel] [RFC] memory-backend-file/nvdimm: support read-only files as memory-backends
Currently is not possible to use a file that is part of a read-only filesystem as memory backend for nvdimm devices, even if this is not modified in the guest. In order to improve the security of Virtual Machines that share and do not modify the memory-backend-file, QEMU should support read-only memory-backeds. Use case: * Kata Containers use a memory-backed-file as read-only rootfs, and this file is used to start all the virtual machines in the node. It would be really bad if somehow a malicious container modified it. Signed-off-by: Julio Montes --- exec.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/exec.c b/exec.c index 50ea9c5aaa..1eb170b55a 100644 --- a/exec.c +++ b/exec.c @@ -1852,6 +1852,12 @@ static int file_ram_open(const char *path, break; } g_free(filename); +} else if (errno == EROFS) { +fd = open(path, O_RDONLY); +if (fd >= 0) { +/* @path names an existing read-only file, use it */ +break; +} } if (errno != EEXIST && errno != EINTR) { error_setg_errno(errp, errno, -- 2.17.2
[Qemu-devel] [PATCH] hw/i386: turn off vmport if CONFIG_VMPORT is disabled
vmport device is not included when CONFIG_VMPORT is disabled, hence QEMU fails with the following error: `Unknown device 'vmport' for bus 'ISA': unknown.` Signed-off-by: Julio Montes --- hw/i386/pc.c | 5 + 1 file changed, 5 insertions(+) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c33ce47578..549c437050 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -83,6 +83,7 @@ #include "hw/mem/memory-device.h" #include "sysemu/replay.h" #include "qapi/qmp/qerror.h" +#include "config-devices.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -2793,7 +2794,11 @@ static void pc_machine_initfn(Object *obj) pcms->max_ram_below_4g = 0; /* use default */ pcms->smm = ON_OFF_AUTO_AUTO; +#ifdef CONFIG_VMPORT pcms->vmport = ON_OFF_AUTO_AUTO; +#else +pcms->vmport = ON_OFF_AUTO_OFF; +#endif /* CONFIG_VMPORT */ /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build; pcms->smbus_enabled = true; -- 2.17.2
[Qemu-devel] [PATCH v2] hw/i386: turn off vmport if CONFIG_VMPORT is disabled
vmport device is not included when CONFIG_VMPORT is disabled, hence QEMU fails with the following error: `Unknown device 'vmport' for bus 'ISA': unknown.` v2: imply VMPORT (Paolo Bonzini ) Signed-off-by: Julio Montes --- hw/i386/Kconfig | 4 ++-- hw/i386/pc.c| 5 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 4ddf2a9c55..b9c96ac361 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -51,6 +51,7 @@ config PC_ACPI config I440FX bool imply E1000_PCI +imply VMPORT select PC_PCI select PC_ACPI select ACPI_SMBUS @@ -58,7 +59,6 @@ config I440FX select IDE_PIIX select DIMM select SMBIOS -select VMPORT select VMMOUSE select FW_CFG_DMA @@ -77,6 +77,7 @@ config Q35 imply VTD imply AMD_IOMMU imply E1000E_PCI_EXPRESS +imply VMPORT select PC_PCI select PC_ACPI select PCI_EXPRESS_Q35 @@ -84,7 +85,6 @@ config Q35 select AHCI_ICH9 select DIMM select SMBIOS -select VMPORT select VMMOUSE select FW_CFG_DMA diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c33ce47578..549c437050 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -83,6 +83,7 @@ #include "hw/mem/memory-device.h" #include "sysemu/replay.h" #include "qapi/qmp/qerror.h" +#include "config-devices.h" /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -2793,7 +2794,11 @@ static void pc_machine_initfn(Object *obj) pcms->max_ram_below_4g = 0; /* use default */ pcms->smm = ON_OFF_AUTO_AUTO; +#ifdef CONFIG_VMPORT pcms->vmport = ON_OFF_AUTO_AUTO; +#else +pcms->vmport = ON_OFF_AUTO_OFF; +#endif /* CONFIG_VMPORT */ /* acpi build is enabled by default if machine supports it */ pcms->acpi_build_enabled = PC_MACHINE_GET_CLASS(pcms)->has_acpi_build; pcms->smbus_enabled = true; -- 2.17.2