[PATCH] daemon: Fix a comment typo in libvirtd.conf.in
by Jim Fehlig
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
Pushing under the trivial rule.
src/remote/libvirtd.conf.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/remote/libvirtd.conf.in b/src/remote/libvirtd.conf.in
index ae6207bf54..ad049f636b 100644
--- a/src/remote/libvirtd.conf.in
+++ b/src/remote/libvirtd.conf.in
@@ -173,7 +173,7 @@
#
# If libvirt was compiled with support for 'polkit', then
# the systemd .socket files will use SocketMode=0666 which
-# allows any user to connect and 'auth_iunix_rw' will default
+# allows any user to connect and 'auth_unix_rw' will default
# to 'polkit'. If you disable use of 'polkit' here, then it
# is essential to change the systemd SocketMode parameter
# back to 0600, to avoid an insecure configuration.
--
2.28.0
4 years, 3 months
[libvirt PATCH 00/21] Remove VIR_{ALLOC, ALLOC_N, REALLOC_N}_QUIET macros.
by Tim Wiederhake
See also
https://www.redhat.com/archives/libvir-list/2020-September/msg00540.html
and
https://www.redhat.com/archives/libvir-list/2020-September/msg00610.html
Tim Wiederhake (21):
tests: Use glib memory functions in virpcimock.c
rpc: Use glib memory functions in virNetMessageSaveError
util: Use glib memory functions in virBitmapNewQuiet
util: Use glib memory functions in virErrorCopyNew
util: Use glib memory functions in virLastErrorObject
util: Use glib memory functions in virSaveLastError
util: Use glib memory functions in virLogFilterNew
util: Use glib memory functions in virThreadCreateFull
util: Remove VIR_ALLOC_QUIET
tests: Use glib memory function in testConfRoundTrip
util: Use glib memory functions in virDevMapperGetTargetsImpl
util: Use glib memory functions in virJSONValueGetArrayAsBitmap
util: Remove VIR_ALLOC_N_QUIET
qemu: Use glib memory functions in qemuDomainMasterKeyReadFile
qemu: Use glib memory functions in qemuDomainLogContextRead
qemu: Use glib memory functions in qemuProcessReadLog
tests: Use glib memory functions in add_fd
tests: Use glib memory functions in pci_driver_new
tools: Use glib memory functions in vshCompleterFilter
util: Use glib memory functions in virFileGetXAttrQuiet
util: Remove VIR_REALLOC_N_QUIET
src/qemu/qemu_domain.c | 4 ++--
src/qemu/qemu_process.c | 2 +-
src/rpc/virnetmessage.c | 4 ++--
src/util/viralloc.h | 44 -----------------------------------------
src/util/virbitmap.c | 10 ++--------
src/util/virdevmapper.c | 4 +---
src/util/virerror.c | 30 ++++++++++++++--------------
src/util/virfile.c | 15 +++++---------
src/util/virjson.c | 4 ++--
src/util/virlog.c | 24 ++++++++--------------
src/util/virthread.c | 5 +----
tests/virconftest.c | 29 ++++++++++-----------------
tests/virpcimock.c | 24 ++++++++--------------
tools/vsh.c | 10 ++++------
14 files changed, 61 insertions(+), 148 deletions(-)
--
2.26.2
4 years, 3 months
[PATCH] cphp: remove deprecated cpu-add command(s)
by Igor Mammedov
theses were deprecatedince since 4.0, remove both HMP and QMP variants.
Users should use device_add commnad instead. To get list of
possible CPUs and options, use 'info hotpluggable-cpus' HMP
or query-hotpluggable-cpus QMP command.
Signed-off-by: Igor Mammedov <imammedo(a)redhat.com>
---
include/hw/boards.h | 1 -
include/hw/i386/pc.h | 1 -
include/monitor/hmp.h | 1 -
docs/system/deprecated.rst | 25 +++++----
hmp-commands.hx | 15 ------
hw/core/machine-hmp-cmds.c | 12 -----
hw/core/machine-qmp-cmds.c | 12 -----
hw/i386/pc.c | 27 ----------
hw/i386/pc_piix.c | 1 -
hw/s390x/s390-virtio-ccw.c | 12 -----
qapi/machine.json | 24 ---------
tests/qtest/cpu-plug-test.c | 100 ++++--------------------------------
tests/qtest/test-hmp.c | 1 -
13 files changed, 21 insertions(+), 211 deletions(-)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index bc5b82ad20..2163843bdb 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -173,7 +173,6 @@ struct MachineClass {
void (*init)(MachineState *state);
void (*reset)(MachineState *state);
void (*wakeup)(MachineState *state);
- void (*hot_add_cpu)(MachineState *state, const int64_t id, Error **errp);
int (*kvm_type)(MachineState *machine, const char *arg);
void (*smp_parse)(MachineState *ms, QemuOpts *opts);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index fe52e165b2..ca8ff6cd27 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -137,7 +137,6 @@ extern int fd_bootchk;
void pc_acpi_smi_interrupt(void *opaque, int irq, int level);
-void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp);
void pc_smp_parse(MachineState *ms, QemuOpts *opts);
void pc_guest_info_init(PCMachineState *pcms);
diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h
index c986cfd28b..642e9e91f9 100644
--- a/include/monitor/hmp.h
+++ b/include/monitor/hmp.h
@@ -89,7 +89,6 @@ void hmp_chardev_add(Monitor *mon, const QDict *qdict);
void hmp_chardev_change(Monitor *mon, const QDict *qdict);
void hmp_chardev_remove(Monitor *mon, const QDict *qdict);
void hmp_chardev_send_break(Monitor *mon, const QDict *qdict);
-void hmp_cpu_add(Monitor *mon, const QDict *qdict);
void hmp_object_add(Monitor *mon, const QDict *qdict);
void hmp_object_del(Monitor *mon, const QDict *qdict);
void hmp_info_memdev(Monitor *mon, const QDict *qdict);
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index 851dbdeb8a..122717cfee 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -284,13 +284,6 @@ The ``query-cpus`` command is replaced by the ``query-cpus-fast`` command.
The ``arch`` output member of the ``query-cpus-fast`` command is
replaced by the ``target`` output member.
-``cpu-add`` (since 4.0)
-'''''''''''''''''''''''
-
-Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See
-documentation of ``query-hotpluggable-cpus`` for additional
-details.
-
``query-events`` (since 4.0)
''''''''''''''''''''''''''''
@@ -306,12 +299,6 @@ the 'wait' field, which is only applicable to sockets in server mode
Human Monitor Protocol (HMP) commands
-------------------------------------
-``cpu-add`` (since 4.0)
-'''''''''''''''''''''''
-
-Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See
-documentation of ``query-hotpluggable-cpus`` for additional details.
-
``acl_show``, ``acl_reset``, ``acl_policy``, ``acl_add``, ``acl_remove`` (since 4.0.0)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@@ -514,6 +501,12 @@ QEMU Machine Protocol (QMP) commands
The "autoload" parameter has been ignored since 2.12.0. All bitmaps
are automatically loaded from qcow2 images.
+``cpu-add`` (removed in 5.2)
+''''''''''''''''''''''''''''
+
+Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See
+documentation of ``query-hotpluggable-cpus`` for additional details.
+
Human Monitor Protocol (HMP) commands
-------------------------------------
@@ -523,6 +516,12 @@ The ``hub_id`` parameter of ``hostfwd_add`` / ``hostfwd_remove`` (removed in 5.0
The ``[hub_id name]`` parameter tuple of the 'hostfwd_add' and
'hostfwd_remove' HMP commands has been replaced by ``netdev_id``.
+``cpu-add`` (removed in 5.2)
+''''''''''''''''''''''''''''
+
+Use ``device_add`` for hotplugging vCPUs instead of ``cpu-add``. See
+documentation of ``query-hotpluggable-cpus`` for additional details.
+
Guest Emulator ISAs
-------------------
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 60f395c276..d1e3e0e1c6 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1761,21 +1761,6 @@ SRST
Executes a qemu-io command on the given block device.
ERST
- {
- .name = "cpu-add",
- .args_type = "id:i",
- .params = "id",
- .help = "add cpu (deprecated, use device_add instead)",
- .cmd = hmp_cpu_add,
- },
-
-SRST
-``cpu-add`` *id*
- Add CPU with id *id*. This command is deprecated, please
- +use ``device_add`` instead. For details, refer to
- 'docs/cpu-hotplug.rst'.
-ERST
-
{
.name = "qom-list",
.args_type = "path:s?",
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 39999c47c5..f4092b98cc 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -46,18 +46,6 @@ void hmp_info_cpus(Monitor *mon, const QDict *qdict)
qapi_free_CpuInfoFastList(cpu_list);
}
-void hmp_cpu_add(Monitor *mon, const QDict *qdict)
-{
- int cpuid;
- Error *err = NULL;
-
- error_report("cpu_add is deprecated, please use device_add instead");
-
- cpuid = qdict_get_int(qdict, "id");
- qmp_cpu_add(cpuid, &err);
- hmp_handle_error(mon, err);
-}
-
void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
{
Error *err = NULL;
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 21551221ad..5362c80a18 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -284,18 +284,6 @@ HotpluggableCPUList *qmp_query_hotpluggable_cpus(Error **errp)
return machine_query_hotpluggable_cpus(ms);
}
-void qmp_cpu_add(int64_t id, Error **errp)
-{
- MachineClass *mc;
-
- mc = MACHINE_GET_CLASS(current_machine);
- if (mc->hot_add_cpu) {
- mc->hot_add_cpu(current_machine, id, errp);
- } else {
- error_setg(errp, "Not supported");
- }
-}
-
void qmp_set_numa_node(NumaOptions *cmd, Error **errp)
{
if (!runstate_check(RUN_STATE_PRECONFIG)) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index d11daacc23..d071da787b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -777,32 +777,6 @@ void pc_smp_parse(MachineState *ms, QemuOpts *opts)
}
}
-void pc_hot_add_cpu(MachineState *ms, const int64_t id, Error **errp)
-{
- X86MachineState *x86ms = X86_MACHINE(ms);
- int64_t apic_id = x86_cpu_apic_id_from_index(x86ms, id);
- Error *local_err = NULL;
-
- if (id < 0) {
- error_setg(errp, "Invalid CPU id: %" PRIi64, id);
- return;
- }
-
- if (apic_id >= ACPI_CPU_HOTPLUG_ID_LIMIT) {
- error_setg(errp, "Unable to add CPU: %" PRIi64
- ", resulting APIC ID (%" PRIi64 ") is too large",
- id, apic_id);
- return;
- }
-
-
- x86_cpu_new(X86_MACHINE(ms), apic_id, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
-}
-
static void rtc_set_cpus_count(ISADevice *rtc, uint16_t cpus_count)
{
if (cpus_count > 0xff) {
@@ -1966,7 +1940,6 @@ static void pc_machine_class_init(ObjectClass *oc, void *data)
mc->auto_enable_numa_with_memdev = true;
mc->has_hotpluggable_cpus = true;
mc->default_boot_order = "cad";
- mc->hot_add_cpu = pc_hot_add_cpu;
mc->smp_parse = pc_smp_parse;
mc->block_default_type = IF_IDE;
mc->max_cpus = 255;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 32b1453e6a..a5d1a0693d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -752,7 +752,6 @@ static void pc_i440fx_1_4_machine_options(MachineClass *m)
{
pc_i440fx_1_5_machine_options(m);
m->hw_version = "1.4.0";
- m->hot_add_cpu = NULL;
compat_props_add(m->compat_props, pc_compat_1_4, pc_compat_1_4_len);
}
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 3106bbea33..28266a3a35 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -553,17 +553,6 @@ static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
return NULL;
}
-static void s390_hot_add_cpu(MachineState *machine,
- const int64_t id, Error **errp)
-{
- ObjectClass *oc;
-
- g_assert(machine->possible_cpus->cpus[0].cpu);
- oc = OBJECT_CLASS(CPU_GET_CLASS(machine->possible_cpus->cpus[0].cpu));
-
- s390x_new_cpu(object_class_get_name(oc), id, errp);
-}
-
static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
{
CPUState *cs = qemu_get_cpu(cpu_index);
@@ -604,7 +593,6 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
s390mc->hpage_1m_allowed = true;
mc->init = ccw_init;
mc->reset = s390_machine_reset;
- mc->hot_add_cpu = s390_hot_add_cpu;
mc->block_default_type = IF_VIRTIO;
mc->no_cdrom = 1;
mc->no_floppy = 1;
diff --git a/qapi/machine.json b/qapi/machine.json
index 0ac1880e4a..d8ed096e9a 100644
--- a/qapi/machine.json
+++ b/qapi/machine.json
@@ -307,30 +307,6 @@
##
{ 'command': 'query-cpus-fast', 'returns': [ 'CpuInfoFast' ] }
-##
-# @cpu-add:
-#
-# Adds CPU with specified ID.
-#
-# @id: ID of CPU to be created, valid values [0..max_cpus)
-#
-# Features:
-# @deprecated: This command is deprecated. Use `device_add` instead.
-# See the `query-hotpluggable-cpus` command for details.
-#
-# Returns: Nothing on success
-#
-# Since: 1.5
-#
-# Example:
-#
-# -> { "execute": "cpu-add", "arguments": { "id": 2 } }
-# <- { "return": {} }
-#
-##
-{ 'command': 'cpu-add', 'data': {'id': 'int'},
- 'features': [ 'deprecated' ] }
-
##
# @MachineInfo:
#
diff --git a/tests/qtest/cpu-plug-test.c b/tests/qtest/cpu-plug-test.c
index e8ffbbce4b..a1c689414b 100644
--- a/tests/qtest/cpu-plug-test.c
+++ b/tests/qtest/cpu-plug-test.c
@@ -25,54 +25,6 @@ struct PlugTestData {
};
typedef struct PlugTestData PlugTestData;
-static void test_plug_with_cpu_add(gconstpointer data)
-{
- const PlugTestData *s = data;
- char *args;
- QDict *response;
- unsigned int i;
-
- args = g_strdup_printf("-machine %s -cpu %s "
- "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
- s->machine, s->cpu_model,
- s->sockets, s->cores, s->threads, s->maxcpus);
- qtest_start(args);
-
- for (i = 1; i < s->maxcpus; i++) {
- response = qmp("{ 'execute': 'cpu-add',"
- " 'arguments': { 'id': %d } }", i);
- g_assert(response);
- g_assert(!qdict_haskey(response, "error"));
- qobject_unref(response);
- }
-
- qtest_end();
- g_free(args);
-}
-
-static void test_plug_without_cpu_add(gconstpointer data)
-{
- const PlugTestData *s = data;
- char *args;
- QDict *response;
-
- args = g_strdup_printf("-machine %s -cpu %s "
- "-smp 1,sockets=%u,cores=%u,threads=%u,maxcpus=%u",
- s->machine, s->cpu_model,
- s->sockets, s->cores, s->threads, s->maxcpus);
- qtest_start(args);
-
- response = qmp("{ 'execute': 'cpu-add',"
- " 'arguments': { 'id': %d } }",
- s->sockets * s->cores * s->threads);
- g_assert(response);
- g_assert(qdict_haskey(response, "error"));
- qobject_unref(response);
-
- qtest_end();
- g_free(args);
-}
-
static void test_plug_with_device_add(gconstpointer data)
{
const PlugTestData *td = data;
@@ -144,36 +96,13 @@ static void add_pc_test_case(const char *mname)
data->cores = 3;
data->threads = 2;
data->maxcpus = data->sockets * data->cores * data->threads;
- if (g_str_has_suffix(mname, "-1.4") ||
- (strcmp(mname, "pc-1.3") == 0) ||
- (strcmp(mname, "pc-1.2") == 0) ||
- (strcmp(mname, "pc-1.1") == 0) ||
- (strcmp(mname, "pc-1.0") == 0)) {
- path = g_strdup_printf("cpu-plug/%s/init/%ux%ux%u&maxcpus=%u",
- mname, data->sockets, data->cores,
- data->threads, data->maxcpus);
- qtest_add_data_func_full(path, data, test_plug_without_cpu_add,
- test_data_free);
- g_free(path);
- } else {
- PlugTestData *data2 = g_memdup(data, sizeof(PlugTestData));
-
- data2->machine = g_strdup(data->machine);
- data2->device_model = g_strdup(data->device_model);
- path = g_strdup_printf("cpu-plug/%s/cpu-add/%ux%ux%u&maxcpus=%u",
- mname, data->sockets, data->cores,
- data->threads, data->maxcpus);
- qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
- test_data_free);
- g_free(path);
- path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
- mname, data2->sockets, data2->cores,
- data2->threads, data2->maxcpus);
- qtest_add_data_func_full(path, data2, test_plug_with_device_add,
- test_data_free);
- g_free(path);
- }
+ path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
+ mname, data->sockets, data->cores,
+ data->threads, data->maxcpus);
+ qtest_add_data_func_full(path, data, test_plug_with_device_add,
+ test_data_free);
+ g_free(path);
}
static void add_pseries_test_case(const char *mname)
@@ -205,7 +134,7 @@ static void add_pseries_test_case(const char *mname)
static void add_s390x_test_case(const char *mname)
{
char *path;
- PlugTestData *data, *data2;
+ PlugTestData *data;
if (!g_str_has_prefix(mname, "s390-ccw-virtio-")) {
return;
@@ -220,21 +149,10 @@ static void add_s390x_test_case(const char *mname)
data->threads = 1;
data->maxcpus = data->sockets * data->cores * data->threads;
- data2 = g_memdup(data, sizeof(PlugTestData));
- data2->machine = g_strdup(data->machine);
- data2->device_model = g_strdup(data->device_model);
-
- path = g_strdup_printf("cpu-plug/%s/cpu-add/%ux%ux%u&maxcpus=%u",
+ path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
mname, data->sockets, data->cores,
data->threads, data->maxcpus);
- qtest_add_data_func_full(path, data, test_plug_with_cpu_add,
- test_data_free);
- g_free(path);
-
- path = g_strdup_printf("cpu-plug/%s/device-add/%ux%ux%u&maxcpus=%u",
- mname, data2->sockets, data2->cores,
- data2->threads, data2->maxcpus);
- qtest_add_data_func_full(path, data2, test_plug_with_device_add,
+ qtest_add_data_func_full(path, data, test_plug_with_device_add,
test_data_free);
g_free(path);
}
diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c
index aea1384bac..94a8023173 100644
--- a/tests/qtest/test-hmp.c
+++ b/tests/qtest/test-hmp.c
@@ -27,7 +27,6 @@ static const char *hmp_cmds[] = {
"chardev-change testchardev1 ringbuf",
"chardev-remove testchardev1",
"commit all",
- "cpu-add 1",
"cpu 0",
"device_add ?",
"device_add usb-mouse,id=mouse1",
--
2.27.0
4 years, 3 months
[libvirt PATCH v2 0/8] Replace VIR_{ALLOC, ALLOC_N, FREE} in src/cpu/*.
by Tim Wiederhake
V1: https://www.redhat.com/archives/libvir-list/2020-September/msg00540.html
Tim Wiederhake (8):
cpu_ppc64: Use g_auto* in ppc64MakeCPUData
cpu_map: Use g_auto* in loadData
cpu_map: Use g_auto* in loadIncludes
cpu_x86: Use g_auto* in virX86CpuIncompatible
cpu_map: Remove unnecessary variable in loadData
cpu: Replace VIR_ALLOC with g_new0
cpu: Replace VIR_ALLOC_N with g_new0
cpu: Replace VIR_FREE with g_free
src/cpu/cpu.c | 6 ++---
src/cpu/cpu_map.c | 20 ++++++---------
src/cpu/cpu_ppc64.c | 59 ++++++++++++++++-----------------------------
src/cpu/cpu_x86.c | 11 ++++-----
4 files changed, 36 insertions(+), 60 deletions(-)
--
2.26.2
4 years, 3 months
[libvirt PATCH] qemu: qemuDomainPMSuspendAgent: Don't assign to 'ret' in a conditional
by Erik Skultety
When the guest agent isn't running, we still report success on a PM
suspend action even though we logged an error correctly, this is because
we poisoned the 'ret' value a few lines above.
Fixes: a663a860819287e041c3de672aad1d8543098ecc
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
Pushed as trivial.
src/qemu/qemu_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2e46931c71..fcdee31971 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -16770,7 +16770,7 @@ qemuDomainPMSuspendAgent(virQEMUDriverPtr driver,
if (qemuDomainObjBeginAgentJob(driver, vm, QEMU_AGENT_JOB_MODIFY) < 0)
return -1;
- if ((ret = virDomainObjCheckActive(vm)) < 0)
+ if (virDomainObjCheckActive(vm) < 0)
goto endjob;
if (!qemuDomainAgentAvailable(vm, true))
--
2.26.2
4 years, 3 months
[PATCH 0/2] Definitive fix for NUMA nodes detection
by Michal Privoznik
See 2/2 for explanation.
Michal Prívozník (2):
virnuma: Assume numa_bitmask_isbitset() exists
virnuma: Use numa_nodes_ptr when checking available NUMA nodes
meson.build | 5 +----
src/util/virnuma.c | 8 ++++----
2 files changed, 5 insertions(+), 8 deletions(-)
--
2.26.2
4 years, 3 months
[PATCH] network: Only check kernel added routes in virNetDevIPCheckIPv6Forwarding
by Ian Wienand
The original motivation for adding virNetDevIPCheckIPv6Forwarding
(00d28a78b5d1f6eaf79f06ac59e31c568af9da37) was that networking routes
would disappear when ipv6 forwarding was enabled for an interface.
This is a fairly undocumented side-effect of the "accept_ra" sysctl
for an interface. 1 means the interface will accept_ra's if not
forwarding, 2 means always accept_RAs; but it is not explained that
enabling forwarding when accept_ra==1 will also clear any kernel RA
assigned routes, very likely breaking your networking.
The check to warn about this currently uses netlink to go through all
the routes and then look at the accept_ra status of the interfaces.
However, it has been noticed that this problem does not affect systems
where IPv6 RA configuration is handled in userspace, e.g. via tools
such as NetworkManager. In this case, the error message from libvirt
is spurious, and modifying the forwarding state will not affect the RA
state or disable your networking.
If you refer to the function rt6_purge_dflt_routers() in the kernel,
we can see that the routes being purged are only those with the
kernel's RTF_ADDRCONF flag set; that is, routes added by the kernel's
RA handling. Why does it do this? I think this is a Linux
implementation decision; it has always been like that and there are
some comments suggesting that it is because a router should be
statically configured, rather than accepting external configurations.
The solution implemented here is to convert the existing check into a
walk of /proc/net/ipv6_route and look for routes with this flag set.
We then check the accept_ra status for the interface, and if enabling
forwarding would break things raise an error.
This should hopefully avoid "interactive" users, who are likely to be
using NetworkManager and the like, having false warnings when enabling
IPv6, but retain the error check for users relying on kernel-based
IPv6 interface auto-configuration.
Signed-off-by: Ian Wienand <iwienand(a)redhat.com>
---
src/util/virnetdevip.c | 108 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 106 insertions(+), 2 deletions(-)
diff --git a/src/util/virnetdevip.c b/src/util/virnetdevip.c
index 7bd5a75f85..93f47f22d9 100644
--- a/src/util/virnetdevip.c
+++ b/src/util/virnetdevip.c
@@ -43,8 +43,11 @@
#ifdef __linux__
# include <linux/sockios.h>
# include <linux/if_vlan.h>
+# include <linux/ipv6_route.h>
#endif
+#define PROC_NET_IPV6_ROUTE "/proc/net/ipv6_route"
+
#define VIR_FROM_THIS VIR_FROM_NONE
VIR_LOG_INIT("util.netdevip");
@@ -688,15 +691,116 @@ virNetDevIPRouteAdd(const char *ifname,
return 0;
}
+#endif /* defined(__linux__) && defined(HAVE_LIBNL) */
+
+
+#if defined(__linux__)
+
+/**
+ * virNetDevIPCheckIPv6Forwarding
+ *
+ * This function checks if IPv6 routes have the RTF_ADDRCONF flag set,
+ * indicating they have been created by the kernel's RA configuration
+ * handling. These routes are subject to being flushed when ipv6
+ * forwarding is enabled unless accept_ra is explicitly set to "2".
+ * This will most likely result in ipv6 networking being broken.
+ *
+ * Returns: true if it is safe to enable forwarding, or false if
+ * breakable routes are found.
+ *
+ **/
+bool
+virNetDevIPCheckIPv6Forwarding(void)
+{
+ int len;
+ char *cur;
+ g_autofree char *buf = NULL;
+ /* lines are 150 chars */
+ enum {MAX_ROUTE_SIZE = 150*100000};
+
+ /* This is /proc/sys/net/ipv6/conf/all/accept_ra */
+ int all_accept_ra = virNetDevIPGetAcceptRA(NULL);
+
+ /* Read ipv6 routes */
+ if ((len = virFileReadAll(PROC_NET_IPV6_ROUTE,
+ MAX_ROUTE_SIZE, &buf)) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unable to read %s "
+ "for ipv6 forwarding checks"), PROC_NET_IPV6_ROUTE);
+ return false;
+ }
+
+ /* VIR_DEBUG("%s output:\n%s", PROC_NET_IPV6_ROUTE, buf); */
+
+ /* Dropping the last character to stop the loop */
+ if (len > 0)
+ buf[len-1] = '\0';
+
+ cur = buf;
+ while (cur) {
+ char route[33], flags[9], iface[9];
+ unsigned int flags_val;
+ char *iface_val;
+ int num;
+ char *nl = strchr(cur, '\n');
+
+ if (nl)
+ *nl++ = '\0';
+
+ num = sscanf(cur, "%32s %*s %*s %*s %*s %*s %*s %*s %8s %8s",
+ route, flags, iface);
+
+ cur = nl;
+ if (num != 3) {
+ VIR_DEBUG("Failed to parse route line: %s", cur);
+ continue;
+ }
+
+ if (virStrToLong_ui(flags, NULL, 16, &flags_val)) {
+ VIR_DEBUG("Failed to parse flags: %s", flags);
+ continue;
+ }
+
+ /* This is right justified, strip leading spaces */
+ iface_val = &iface[0];
+ while (*iface_val && g_ascii_isspace(*iface_val))
+ iface_val++;
+
+ VIR_DEBUG("%s iface %s flags %s : RTF_ADDRCONF %sset",
+ route, iface_val, flags,
+ (flags_val & RTF_ADDRCONF ? "" : "not "));
+
+ if (flags_val & RTF_ADDRCONF) {
+ int ret = virNetDevIPGetAcceptRA(iface_val);
+ VIR_DEBUG("%s reports accept_ra of %d",
+ iface_val, ret);
+ /* If the interface for this autoconfigured route
+ * has accept_ra == 1, or it is default and the "all"
+ * value of accept_ra == 1, it will be subject to
+ * flushing if forwarding is enabled.
+ */
+ if (ret == 1 || (ret == 0 && all_accept_ra == 1)) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Check the host setup: interface %s has kernel "
+ "autoconfigured IPv6 routes and enabling forwarding "
+ " without accept_ra set to 2 will cause the kernel "
+ "to flush them, breaking networking."), iface_val);
+ return false;
+ }
+ }
+ }
+ return true;
+}
+#else
bool
virNetDevIPCheckIPv6Forwarding(void)
{
- VIR_WARN("built without libnl: unable to check if IPv6 forwarding can be safely enabled");
+ VIR_DEBUG("No checks for IPv6 forwarding issues on non-Linux systems", flags);
return true;
}
-#endif /* defined(__linux__) && defined(WITH_LIBNL) */
+#endif /* defined(__linux__) */
/**
--
2.26.2
4 years, 3 months
[libvirt PATCH] esx: improve some of the virErrorNumber used
by Pino Toscano
A lot of virReportError() calls use VIR_ERR_INTERNAL_ERROR to represent
the number of the error, even in cases where there is one fitting more.
Hence, replace some of them with better virErrorNumber values.
Signed-off-by: Pino Toscano <ptoscano(a)redhat.com>
---
src/esx/esx_network_driver.c | 4 ++--
src/esx/esx_storage_backend_iscsi.c | 4 ++--
src/esx/esx_storage_backend_vmfs.c | 12 +++++-----
src/esx/esx_util.c | 4 ++--
src/esx/esx_vi.c | 36 ++++++++++++++---------------
5 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c
index d46fc9253d..88843aae2f 100644
--- a/src/esx/esx_network_driver.c
+++ b/src/esx/esx_network_driver.c
@@ -355,7 +355,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
for (hostPortGroup = hostPortGroupList; hostPortGroup;
hostPortGroup = hostPortGroup->_next) {
if (STREQ(def->portGroups[i].name, hostPortGroup->spec->name)) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NETWORK_EXIST,
_("HostPortGroup with name '%s' exists already"),
def->portGroups[i].name);
goto cleanup;
@@ -388,7 +388,7 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml)
if (def->forward.ifs[i].type !=
VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("unsupported device type in network %s "
"interface pool"),
def->name);
diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c
index 395a347cf3..017b800f06 100644
--- a/src/esx/esx_storage_backend_iscsi.c
+++ b/src/esx/esx_storage_backend_iscsi.c
@@ -321,7 +321,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
if (!target) {
/* pool not found */
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_STORAGE_POOL,
_("Could not find storage pool with name '%s'"),
pool->name);
goto cleanup;
@@ -699,7 +699,7 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume,
}
if (!scsiLun) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_STORAGE_VOL,
_("Could find volume with name: %s"), volume->name);
goto cleanup;
}
diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c
index 4f613bf93b..a98001d6b2 100644
--- a/src/esx/esx_storage_backend_vmfs.c
+++ b/src/esx/esx_storage_backend_vmfs.c
@@ -897,7 +897,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
goto cleanup;
if (def->type != VIR_STORAGE_VOL_FILE) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
@@ -913,7 +913,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
}
if (!virStringHasCaseSuffix(def->name, ".vmdk")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Volume name '%s' has unsupported suffix, "
"expecting '.vmdk'"), def->name);
goto cleanup;
@@ -1032,7 +1032,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool,
key = g_strdup(datastorePath);
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
@@ -1111,7 +1111,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
goto cleanup;
if (def->type != VIR_STORAGE_VOL_FILE) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_NO_SUPPORT, "%s",
_("Creating non-file volumes is not supported"));
goto cleanup;
}
@@ -1127,7 +1127,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
}
if (!virStringHasCaseSuffix(def->name, ".vmdk")) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Volume name '%s' has unsupported suffix, "
"expecting '.vmdk'"), def->name);
goto cleanup;
@@ -1212,7 +1212,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool,
key = g_strdup(datastorePath);
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_NO_SUPPORT,
_("Creation of %s volumes is not supported"),
virStorageFileFormatTypeToString(def->target.format));
goto cleanup;
diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c
index 11f43acc19..8755d80877 100644
--- a/src/esx/esx_util.c
+++ b/src/esx/esx_util.c
@@ -217,7 +217,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
if ((datastoreName && *datastoreName) ||
(directoryName && *directoryName) ||
(directoryAndFileName && *directoryAndFileName)) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
@@ -226,7 +226,7 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName,
/* Expected format: '[<datastore>] <path>' where <path> is optional */
if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' ||
!(preliminaryDatastoreName = strtok_r(tmp, "]", &saveptr))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INVALID_ARG,
_("Datastore path '%s' doesn't have expected format "
"'[<datastore>] <path>'"), datastorePath);
goto cleanup;
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index a4f3be02a4..61e9bcd920 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -430,7 +430,7 @@ esxVI_CURL_Upload(esxVI_CURL *curl, const char *url, const char *content)
int responseCode = 0;
if (!content) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
@@ -547,13 +547,13 @@ esxVI_SharedCURL_Add(esxVI_SharedCURL *shared, esxVI_CURL *curl)
size_t i;
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot share uninitialized CURL handle"));
return -1;
}
if (curl->shared) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot share CURL handle that is already shared"));
return -1;
}
@@ -602,19 +602,19 @@ int
esxVI_SharedCURL_Remove(esxVI_SharedCURL *shared, esxVI_CURL *curl)
{
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot unshare uninitialized CURL handle"));
return -1;
}
if (!curl->shared) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot unshare CURL handle that is not shared"));
return -1;
}
if (curl->shared != shared) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (share) mismatch"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (share) mismatch"));
return -1;
}
@@ -657,13 +657,13 @@ int
esxVI_MultiCURL_Add(esxVI_MultiCURL *multi, esxVI_CURL *curl)
{
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot add uninitialized CURL handle to a multi handle"));
return -1;
}
if (curl->multi) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot add CURL handle to a multi handle twice"));
return -1;
}
@@ -695,21 +695,21 @@ int
esxVI_MultiCURL_Remove(esxVI_MultiCURL *multi, esxVI_CURL *curl)
{
if (!curl->handle) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot remove uninitialized CURL handle from a "
"multi handle"));
return -1;
}
if (!curl->multi) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Cannot remove CURL handle from a multi handle when it "
"wasn't added before"));
return -1;
}
if (curl->multi != multi) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("CURL (multi) mismatch"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("CURL (multi) mismatch"));
return -1;
}
@@ -839,7 +839,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
if (!ctx || !url || !ipAddress || !username ||
!password || ctx->url || ctx->service || ctx->curl) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
@@ -1247,7 +1247,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
xmlNodePtr responseNode = NULL;
if (!request || !response || *response) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
@@ -1390,7 +1390,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName,
}
}
} else {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_HTTP_ERROR,
_("HTTP response code %d for call to '%s'"),
(*response)->responseCode, methodName);
goto cleanup;
@@ -1440,14 +1440,14 @@ esxVI_Enumeration_CastFromAnyType(const esxVI_Enumeration *enumeration,
size_t i;
if (!anyType || !value) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
*value = 0; /* undefined */
if (anyType->type != enumeration->type) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
+ virReportError(VIR_ERR_INVALID_ARG,
_("Expecting type '%s' but found '%s'"),
esxVI_Type_ToString(enumeration->type),
esxVI_AnyType_TypeToString(anyType));
@@ -1476,7 +1476,7 @@ esxVI_Enumeration_Serialize(const esxVI_Enumeration *enumeration,
const char *name = NULL;
if (!element || !output) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
@@ -1515,7 +1515,7 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration,
char *name = NULL;
if (!value) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ virReportError(VIR_ERR_INVALID_ARG, "%s", _("Invalid argument"));
return -1;
}
--
2.26.2
4 years, 3 months
[PATCH] tools: Remove unnecessary condition check
by Yi Li
virshDomainFree correctly handle null pointer parameters.
There is no need to check if the parameter is null before
calling this function.
Signed-off-by: Yi Li <yili(a)winhong.com>
---
tools/virsh-domain-monitor.c | 6 ++----
tools/virsh-domain.c | 3 +--
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 0111116885..4c0da3c695 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -1610,10 +1610,8 @@ virshDomainListFree(virshDomainListPtr domlist)
size_t i;
if (domlist && domlist->domains) {
- for (i = 0; i < domlist->ndomains; i++) {
- if (domlist->domains[i])
- virshDomainFree(domlist->domains[i]);
- }
+ for (i = 0; i < domlist->ndomains; i++)
+ virshDomainFree(domlist->domains[i]);
VIR_FREE(domlist->domains);
}
VIR_FREE(domlist);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index d1d3f8e566..08496cc5bf 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5509,8 +5509,7 @@ doDump(void *opaque)
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
#endif /* !WIN32 */
- if (dom)
- virshDomainFree(dom);
+ virshDomainFree(dom);
g_main_loop_quit(data->eventLoop);
}
--
2.25.3
4 years, 3 months