* [PULL 1/8] hw/s390x: Attach the sclpconsole to /machine/sclp/s390-sclp-event-facility
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
@ 2024-05-10 6:39 ` Thomas Huth
2024-05-10 6:39 ` [PULL 2/8] s390x: Introduce a SCLPDevice pointer under the machine Thomas Huth
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:39 UTC (permalink / raw)
To: qemu-devel, Richard Henderson
Cc: Eric Farman, Cédric Le Goater, David Hildenbrand,
Philippe Mathieu-Daudé
The sclpconsole currently does not have a proper parent in the QOM
tree, so it shows up under /machine/unattached - which is somewhat
ugly. We should rather attach it to /machine/sclp/s390-sclp-event-facility
where the other devices of type TYPE_SCLP_EVENT already reside.
Message-ID: <20240430190843.453903-1-thuth@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/s390x/s390-virtio-ccw.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 4dcc213820..726c2ab436 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -239,11 +239,13 @@ static void s390_create_virtio_net(BusState *bus, const char *name)
static void s390_create_sclpconsole(const char *type, Chardev *chardev)
{
+ BusState *ev_fac_bus = sclp_get_event_facility_bus();
DeviceState *dev;
dev = qdev_new(type);
+ object_property_add_child(OBJECT(ev_fac_bus->parent), type, OBJECT(dev));
qdev_prop_set_chr(dev, "chardev", chardev);
- qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal);
+ qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
}
static void ccw_init(MachineState *machine)
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 2/8] s390x: Introduce a SCLPDevice pointer under the machine
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
2024-05-10 6:39 ` [PULL 1/8] hw/s390x: Attach the sclpconsole to /machine/sclp/s390-sclp-event-facility Thomas Huth
@ 2024-05-10 6:39 ` Thomas Huth
2024-05-10 6:39 ` [PULL 3/8] s390x/event-facility: Simplify sclp_get_event_facility_bus() Thomas Huth
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:39 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Cédric Le Goater
From: Cédric Le Goater <clg@redhat.com>
Initialize directly SCLPDevice from the machine init handler and
remove s390_sclp_init(). We will use the SCLPDevice pointer later to
create the consoles.
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Message-ID: <20240502131533.377719-2-clg@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
include/hw/s390x/s390-virtio-ccw.h | 3 +++
include/hw/s390x/sclp.h | 2 --
hw/s390x/s390-virtio-ccw.c | 6 +++++-
hw/s390x/sclp.c | 10 ----------
4 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-virtio-ccw.h
index c1d46e78af..7605d06bff 100644
--- a/include/hw/s390x/s390-virtio-ccw.h
+++ b/include/hw/s390x/s390-virtio-ccw.h
@@ -13,6 +13,7 @@
#include "hw/boards.h"
#include "qom/object.h"
+#include "hw/s390x/sclp.h"
#define TYPE_S390_CCW_MACHINE "s390-ccw-machine"
@@ -28,6 +29,8 @@ struct S390CcwMachineState {
bool dea_key_wrap;
bool pv;
uint8_t loadparm[8];
+
+ SCLPDevice *sclp;
};
#define S390_PTF_REASON_NONE (0x00 << 8)
diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h
index b405a387b6..d32f6180e0 100644
--- a/include/hw/s390x/sclp.h
+++ b/include/hw/s390x/sclp.h
@@ -221,8 +221,6 @@ static inline int sccb_data_len(SCCB *sccb)
return be16_to_cpu(sccb->h.length) - sizeof(sccb->h);
}
-
-void s390_sclp_init(void);
void sclp_service_interrupt(uint32_t sccb);
void raise_irq_cpu_hotplug(void);
int sclp_service_call(S390CPU *cpu, uint64_t sccb, uint32_t code);
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 726c2ab436..159f67d05c 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -251,11 +251,15 @@ static void s390_create_sclpconsole(const char *type, Chardev *chardev)
static void ccw_init(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ S390CcwMachineState *ms = S390_CCW_MACHINE(machine);
int ret;
VirtualCssBus *css_bus;
DeviceState *dev;
- s390_sclp_init();
+ ms->sclp = SCLP(object_new(TYPE_SCLP));
+ object_property_add_child(OBJECT(machine), TYPE_SCLP, OBJECT(ms->sclp));
+ qdev_realize_and_unref(DEVICE(ms->sclp), NULL, &error_fatal);
+
/* init memory + setup max page size. Required for the CPU model */
s390_memory_init(machine->ram);
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index 893e71a41b..d236dbaf0b 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -378,16 +378,6 @@ void sclp_service_interrupt(uint32_t sccb)
}
/* qemu object creation and initialization functions */
-
-void s390_sclp_init(void)
-{
- Object *new = object_new(TYPE_SCLP);
-
- object_property_add_child(qdev_get_machine(), TYPE_SCLP, new);
- object_unref(new);
- qdev_realize(DEVICE(new), NULL, &error_fatal);
-}
-
static void sclp_realize(DeviceState *dev, Error **errp)
{
MachineState *machine = MACHINE(qdev_get_machine());
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 3/8] s390x/event-facility: Simplify sclp_get_event_facility_bus()
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
2024-05-10 6:39 ` [PULL 1/8] hw/s390x: Attach the sclpconsole to /machine/sclp/s390-sclp-event-facility Thomas Huth
2024-05-10 6:39 ` [PULL 2/8] s390x: Introduce a SCLPDevice pointer under the machine Thomas Huth
@ 2024-05-10 6:39 ` Thomas Huth
2024-05-10 6:39 ` [PULL 4/8] s390x/sclp: Simplify get_sclp_device() Thomas Huth
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:39 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Cédric Le Goater
From: Cédric Le Goater <clg@redhat.com>
sclp_get_event_facility_bus() scans the whole machine to find a
TYPE_SCLP_EVENTS_BUS object. The SCLPDevice instance is now available
under the machine state, use it to simplify the lookup and adjust the
creation of the consoles.
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Message-ID: <20240502131533.377719-3-clg@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
include/hw/s390x/event-facility.h | 2 +-
hw/s390x/event-facility.c | 13 ++-----------
hw/s390x/s390-virtio-ccw.c | 12 +++++++-----
3 files changed, 10 insertions(+), 17 deletions(-)
diff --git a/include/hw/s390x/event-facility.h b/include/hw/s390x/event-facility.h
index 3ffd575d8f..ff874e792d 100644
--- a/include/hw/s390x/event-facility.h
+++ b/include/hw/s390x/event-facility.h
@@ -203,6 +203,6 @@ struct SCLPEventFacilityClass {
bool (*event_pending)(SCLPEventFacility *ef);
};
-BusState *sclp_get_event_facility_bus(void);
+BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef);
#endif
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index f9829de953..06c1da0ece 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -523,16 +523,7 @@ static void register_types(void)
type_init(register_types)
-BusState *sclp_get_event_facility_bus(void)
+BusState *sclp_get_event_facility_bus(SCLPEventFacility *ef)
{
- Object *busobj;
- SCLPEventsBus *sbus;
-
- busobj = object_resolve_path_type("", TYPE_SCLP_EVENTS_BUS, NULL);
- sbus = OBJECT_CHECK(SCLPEventsBus, busobj, TYPE_SCLP_EVENTS_BUS);
- if (!sbus) {
- return NULL;
- }
-
- return &sbus->qbus;
+ return BUS(&ef->sbus);
}
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 159f67d05c..2afaf45ce6 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -237,13 +237,15 @@ static void s390_create_virtio_net(BusState *bus, const char *name)
}
}
-static void s390_create_sclpconsole(const char *type, Chardev *chardev)
+static void s390_create_sclpconsole(SCLPDevice *sclp,
+ const char *type, Chardev *chardev)
{
- BusState *ev_fac_bus = sclp_get_event_facility_bus();
+ SCLPEventFacility *ef = sclp->event_facility;
+ BusState *ev_fac_bus = sclp_get_event_facility_bus(ef);
DeviceState *dev;
dev = qdev_new(type);
- object_property_add_child(OBJECT(ev_fac_bus->parent), type, OBJECT(dev));
+ object_property_add_child(OBJECT(ef), type, OBJECT(dev));
qdev_prop_set_chr(dev, "chardev", chardev);
qdev_realize_and_unref(dev, ev_fac_bus, &error_fatal);
}
@@ -308,10 +310,10 @@ static void ccw_init(MachineState *machine)
/* init consoles */
if (serial_hd(0)) {
- s390_create_sclpconsole("sclpconsole", serial_hd(0));
+ s390_create_sclpconsole(ms->sclp, "sclpconsole", serial_hd(0));
}
if (serial_hd(1)) {
- s390_create_sclpconsole("sclplmconsole", serial_hd(1));
+ s390_create_sclpconsole(ms->sclp, "sclplmconsole", serial_hd(1));
}
/* init the TOD clock */
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 4/8] s390x/sclp: Simplify get_sclp_device()
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
` (2 preceding siblings ...)
2024-05-10 6:39 ` [PULL 3/8] s390x/event-facility: Simplify sclp_get_event_facility_bus() Thomas Huth
@ 2024-05-10 6:39 ` Thomas Huth
2024-05-10 6:39 ` [PULL 5/8] target/s390x: report deprecated-props in cpu-model-expansion reply Thomas Huth
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:39 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Cédric Le Goater
From: Cédric Le Goater <clg@redhat.com>
get_sclp_device() scans the whole machine to find a TYPE_SCLP object.
Now that the SCLPDevice instance is available under the machine state,
use it to simplify the lookup. While at it, remove the inline to let
the compiler decide on how to optimize.
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Message-ID: <20240502131533.377719-4-clg@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/s390x/sclp.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index d236dbaf0b..e725dcd5fd 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -21,13 +21,14 @@
#include "hw/s390x/s390-pci-bus.h"
#include "hw/s390x/ipl.h"
#include "hw/s390x/cpu-topology.h"
+#include "hw/s390x/s390-virtio-ccw.h"
-static inline SCLPDevice *get_sclp_device(void)
+static SCLPDevice *get_sclp_device(void)
{
static SCLPDevice *sclp;
if (!sclp) {
- sclp = SCLP(object_resolve_path_type("", TYPE_SCLP, NULL));
+ sclp = S390_CCW_MACHINE(qdev_get_machine())->sclp;
}
return sclp;
}
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 5/8] target/s390x: report deprecated-props in cpu-model-expansion reply
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
` (3 preceding siblings ...)
2024-05-10 6:39 ` [PULL 4/8] s390x/sclp: Simplify get_sclp_device() Thomas Huth
@ 2024-05-10 6:39 ` Thomas Huth
2024-05-10 6:39 ` [PULL 6/8] target/s390x: flag te and cte as deprecated Thomas Huth
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:39 UTC (permalink / raw)
To: qemu-devel, Richard Henderson
Cc: Collin Walling, Markus Armbruster, David Hildenbrand
From: Collin Walling <walling@linux.ibm.com>
Retain a list of deprecated features disjoint from any particular
CPU model. A query-cpu-model-expansion reply will now provide a list of
properties (i.e. features) that are flagged as deprecated. Example:
{
"return": {
"model": {
"name": "z14.2-base",
"deprecated-props": [
"bpb",
"csske"
],
"props": {
"pfmfi": false,
"exrl": true,
...a lot more props...
"skey": false,
"vxpdeh2": false
}
}
}
}
It is recommended that s390 guests operate with these features
explicitly disabled to ensure compatibility with future hardware.
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20240429191059.11806-2-walling@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
qapi/machine-target.json | 7 ++++++-
target/s390x/cpu_features.h | 1 +
target/s390x/cpu_features.c | 14 ++++++++++++++
target/s390x/cpu_models_sysemu.c | 8 ++++++++
4 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/qapi/machine-target.json b/qapi/machine-target.json
index 29e695aa06..2942853092 100644
--- a/qapi/machine-target.json
+++ b/qapi/machine-target.json
@@ -20,11 +20,16 @@
#
# @props: a dictionary of QOM properties to be applied
#
+# @deprecated-props: a list of properties that are flagged as deprecated
+# by the CPU vendor. These props are a subset of the full model's
+# definition list of properties. (since 9.1)
+#
# Since: 2.8
##
{ 'struct': 'CpuModelInfo',
'data': { 'name': 'str',
- '*props': 'any' } }
+ '*props': 'any',
+ '*deprecated-props': ['str'] } }
##
# @CpuModelExpansionType:
diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h
index a9bd68a2e1..661a8cd6db 100644
--- a/target/s390x/cpu_features.h
+++ b/target/s390x/cpu_features.h
@@ -69,6 +69,7 @@ void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
uint8_t *data);
void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
void (*fn)(const char *name, void *opaque));
+void s390_get_deprecated_features(S390FeatBitmap features);
/* Definition of a CPU feature group */
typedef struct {
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
index d28eb65845..efafc9711c 100644
--- a/target/s390x/cpu_features.c
+++ b/target/s390x/cpu_features.c
@@ -212,6 +212,20 @@ void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
};
}
+void s390_get_deprecated_features(S390FeatBitmap features)
+{
+ static const int feats[] = {
+ /* CSSKE is deprecated on newer generations */
+ S390_FEAT_CONDITIONAL_SSKE,
+ S390_FEAT_BPB,
+ };
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(feats); i++) {
+ set_bit(feats[i], features);
+ }
+}
+
#define FEAT_GROUP_INIT(_name, _group, _desc) \
{ \
.name = _name, \
diff --git a/target/s390x/cpu_models_sysemu.c b/target/s390x/cpu_models_sysemu.c
index 15be729c3d..977fbc6522 100644
--- a/target/s390x/cpu_models_sysemu.c
+++ b/target/s390x/cpu_models_sysemu.c
@@ -206,6 +206,14 @@ static void cpu_info_from_model(CpuModelInfo *info, const S390CPUModel *model,
} else {
info->props = QOBJECT(qdict);
}
+
+ /* features flagged as deprecated */
+ bitmap_zero(bitmap, S390_FEAT_MAX);
+ s390_get_deprecated_features(bitmap);
+
+ bitmap_and(bitmap, bitmap, model->def->full_feat, S390_FEAT_MAX);
+ s390_feat_bitmap_to_ascii(bitmap, &info->deprecated_props, list_add_feat);
+ info->has_deprecated_props = !!info->deprecated_props;
}
CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 6/8] target/s390x: flag te and cte as deprecated
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
` (4 preceding siblings ...)
2024-05-10 6:39 ` [PULL 5/8] target/s390x: report deprecated-props in cpu-model-expansion reply Thomas Huth
@ 2024-05-10 6:39 ` Thomas Huth
2024-05-10 6:40 ` [PULL 7/8] qemu-options: Deprecate "-runas" and introduce "-run-with user=..." instead Thomas Huth
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:39 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Collin Walling, David Hildenbrand
From: Collin Walling <walling@linux.ibm.com>
Add the CONSTRAINT_TRANSACTIONAL_EXE (cte) and TRANSACTIONAL_EXE (te)
to the list of deprecated features.
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Message-ID: <20240429191059.11806-3-walling@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
target/s390x/cpu_features.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c
index efafc9711c..cb4e2b8920 100644
--- a/target/s390x/cpu_features.c
+++ b/target/s390x/cpu_features.c
@@ -218,6 +218,9 @@ void s390_get_deprecated_features(S390FeatBitmap features)
/* CSSKE is deprecated on newer generations */
S390_FEAT_CONDITIONAL_SSKE,
S390_FEAT_BPB,
+ /* Deprecated on z16 */
+ S390_FEAT_CONSTRAINT_TRANSACTIONAL_EXE,
+ S390_FEAT_TRANSACTIONAL_EXE
};
int i;
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 7/8] qemu-options: Deprecate "-runas" and introduce "-run-with user=..." instead
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
` (5 preceding siblings ...)
2024-05-10 6:39 ` [PULL 6/8] target/s390x: flag te and cte as deprecated Thomas Huth
@ 2024-05-10 6:40 ` Thomas Huth
2024-05-10 6:40 ` [PULL 8/8] tests/qtest: Add some test cases support on LoongArch Thomas Huth
2024-05-10 9:17 ` [PULL 0/8] s390x and misc patches Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:40 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Philippe Mathieu-Daudé
The old "-runas" option has the disadvantage that it is not visible
in the QAPI schema, so it is not available via the normal introspection
mechanisms. We've recently introduced the "-run-with" option for exactly
this purpose, which is meant to handle the options that affect the
runtime behavior. Thus let's introduce a "user=..." parameter here now
and deprecate the old "-runas" option.
Message-ID: <20240506112058.51446-1-thuth@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
docs/about/deprecated.rst | 6 ++++++
system/vl.c | 15 +++++++++++++++
qemu-options.hx | 15 +++++++++++----
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index e22acb17f2..6f709746db 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -61,6 +61,12 @@ configurations (e.g. -smp drawers=1,books=1,clusters=1 for x86 PC machine) is
marked deprecated since 9.0, users have to ensure that all the topology members
described with -smp are supported by the target machine.
+``-runas`` (since 9.1)
+----------------------
+
+Use ``-run-with user=..`` instead.
+
+
User-mode emulator command line arguments
-----------------------------------------
diff --git a/system/vl.c b/system/vl.c
index 7756eac81e..b031427440 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -773,6 +773,10 @@ static QemuOptsList qemu_run_with_opts = {
.name = "chroot",
.type = QEMU_OPT_STRING,
},
+ {
+ .name = "user",
+ .type = QEMU_OPT_STRING,
+ },
{ /* end of list */ }
},
};
@@ -3586,6 +3590,7 @@ void qemu_init(int argc, char **argv)
break;
#if defined(CONFIG_POSIX)
case QEMU_OPTION_runas:
+ warn_report("-runas is deprecated, use '-run-with user=...' instead");
if (!os_set_runas(optarg)) {
error_report("User \"%s\" doesn't exist"
" (and is not <uid>:<gid>)",
@@ -3612,6 +3617,16 @@ void qemu_init(int argc, char **argv)
if (str) {
os_set_chroot(str);
}
+ str = qemu_opt_get(opts, "user");
+ if (str) {
+ if (!os_set_runas(str)) {
+ error_report("User \"%s\" doesn't exist"
+ " (and is not <uid>:<gid>)",
+ optarg);
+ exit(1);
+ }
+ }
+
break;
}
#endif /* CONFIG_POSIX */
diff --git a/qemu-options.hx b/qemu-options.hx
index cf61f6b863..f5c01eeeb4 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -4824,7 +4824,8 @@ DEF("runas", HAS_ARG, QEMU_OPTION_runas, \
SRST
``-runas user``
Immediately before starting guest execution, drop root privileges,
- switching to the specified user.
+ switching to the specified user. This option is deprecated, use
+ ``-run-with user=...`` instead.
ERST
DEF("prom-env", HAS_ARG, QEMU_OPTION_prom_env,
@@ -4990,13 +4991,15 @@ DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL)
#ifdef CONFIG_POSIX
DEF("run-with", HAS_ARG, QEMU_OPTION_run_with,
- "-run-with [async-teardown=on|off][,chroot=dir]\n"
+ "-run-with [async-teardown=on|off][,chroot=dir][user=username|uid:gid]\n"
" Set miscellaneous QEMU process lifecycle options:\n"
" async-teardown=on enables asynchronous teardown (Linux only)\n"
- " chroot=dir chroot to dir just before starting the VM\n",
+ " chroot=dir chroot to dir just before starting the VM\n"
+ " user=username switch to the specified user before starting the VM\n"
+ " user=uid:gid ditto, but use specified user-ID and group-ID instead\n",
QEMU_ARCH_ALL)
SRST
-``-run-with [async-teardown=on|off][,chroot=dir]``
+``-run-with [async-teardown=on|off][,chroot=dir][user=username|uid:gid]``
Set QEMU process lifecycle options.
``async-teardown=on`` enables asynchronous teardown. A new process called
@@ -5013,6 +5016,10 @@ SRST
``chroot=dir`` can be used for doing a chroot to the specified directory
immediately before starting the guest execution. This is especially useful
in combination with -runas.
+
+ ``user=username`` or ``user=uid:gid`` can be used to drop root privileges
+ by switching to the specified user (via username) or user and group
+ (via uid:gid) immediately before starting guest execution.
ERST
#endif
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PULL 8/8] tests/qtest: Add some test cases support on LoongArch
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
` (6 preceding siblings ...)
2024-05-10 6:40 ` [PULL 7/8] qemu-options: Deprecate "-runas" and introduce "-run-with user=..." instead Thomas Huth
@ 2024-05-10 6:40 ` Thomas Huth
2024-05-10 9:17 ` [PULL 0/8] s390x and misc patches Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Thomas Huth @ 2024-05-10 6:40 UTC (permalink / raw)
To: qemu-devel, Richard Henderson; +Cc: Bibo Mao
From: Bibo Mao <maobibo@loongson.cn>
Add boot-serial-test and filter test cases support on LoongArch system.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Message-ID: <20240509084745.2514607-1-maobibo@loongson.cn>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tests/qtest/boot-serial-test.c | 10 ++++++++++
tests/qtest/meson.build | 3 +++
2 files changed, 13 insertions(+)
diff --git a/tests/qtest/boot-serial-test.c b/tests/qtest/boot-serial-test.c
index e3b7d65fe5..df389adeeb 100644
--- a/tests/qtest/boot-serial-test.c
+++ b/tests/qtest/boot-serial-test.c
@@ -26,6 +26,14 @@ static const uint8_t bios_avr[] = {
0x80, 0x93, 0xc6, 0x00, /* sts 0x00C6, r24 ; Output 'T' */
};
+static const uint8_t bios_loongarch64[] = {
+ 0x0c, 0xc0, 0x3f, 0x14, /* lu12i.w $t0, 0x1fe00 */
+ 0x8c, 0x81, 0x87, 0x03, /* ori $t0, $t0, 0x1e0 */
+ 0x0d, 0x50, 0x81, 0x03, /* li.w $t1, 'T' */
+ 0x8d, 0x01, 0x00, 0x29, /* st.b $t1, $t0, 0 */
+ 0xff, 0xf3, 0xff, 0x53, /* b -16 # loop */
+};
+
static const uint8_t kernel_mcf5208[] = {
0x41, 0xf9, 0xfc, 0x06, 0x00, 0x00, /* lea 0xfc060000,%a0 */
0x10, 0x3c, 0x00, 0x54, /* move.b #'T',%d0 */
@@ -167,6 +175,8 @@ static const testdef_t tests[] = {
{ "sparc", "SS-600MP", "", "TMS390Z55" },
{ "sparc64", "sun4u", "", "UltraSPARC" },
{ "s390x", "s390-ccw-virtio", "", "device" },
+ { "loongarch64", "virt", "-cpu max", "TT", sizeof(bios_loongarch64),
+ NULL, bios_loongarch64 },
{ "m68k", "mcf5208evb", "", "TT", sizeof(kernel_mcf5208), kernel_mcf5208 },
{ "m68k", "next-cube", "", "TT", sizeof(bios_nextcube), 0, bios_nextcube },
{ "microblaze", "petalogix-s3adsp1800", "", "TT",
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index 6f2f594ace..86293051dc 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -139,6 +139,9 @@ qtests_hppa = ['boot-serial-test'] + \
qtests_filter + \
(config_all_devices.has_key('CONFIG_VGA') ? ['display-vga-test'] : [])
+qtests_loongarch64 = qtests_filter + \
+ ['boot-serial-test']
+
qtests_m68k = ['boot-serial-test'] + \
qtests_filter
--
2.45.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PULL 0/8] s390x and misc patches
2024-05-10 6:39 [PULL 0/8] s390x and misc patches Thomas Huth
` (7 preceding siblings ...)
2024-05-10 6:40 ` [PULL 8/8] tests/qtest: Add some test cases support on LoongArch Thomas Huth
@ 2024-05-10 9:17 ` Richard Henderson
8 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2024-05-10 9:17 UTC (permalink / raw)
To: Thomas Huth, qemu-devel
On 5/10/24 08:39, Thomas Huth wrote:
> The following changes since commit 36fa7c686e9eac490002ffc439c4affaa352c17c:
>
> gitlab: Update msys2-64bit runner tags (2024-05-09 05:46:21 +0200)
>
> are available in the Git repository at:
>
> https://gitlab.com/thuth/qemu.git tags/pull-request-2024-05-10
>
> for you to fetch changes up to 0d497106a71a3b17b0228cb87922ef794296cb24:
>
> tests/qtest: Add some test cases support on LoongArch (2024-05-10 08:34:29 +0200)
>
> ----------------------------------------------------------------
> * Attach s390x sclpconsole to a proper parent in the QOM tree
> * SCLP related clean-ups
> * Report deprecated-props in cpu-model-expansion reply on s390x
> * Deprecate "-runas" and introduce "-run-with user=..." instead
> * Add some more qtest cases on LoongArch
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/9.1 as appropriate.
r~
^ permalink raw reply [flat|nested] 10+ messages in thread