Compare commits
10 Commits
35c4e39997
...
6c63885fbf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c63885fbf | ||
|
|
4757f653ca | ||
|
|
6e6b7fef0a | ||
|
|
838c3a9aa4 | ||
|
|
cef3af2248 | ||
|
|
5d41f7e23d | ||
|
|
bd4f2ca3c2 | ||
|
|
145ea1206d | ||
|
|
fa4ca9455f | ||
|
|
aaeec40e35 |
189
Add-cvm-parameter-into-the-type-of-LaunchSecurity-wh.patch
Normal file
189
Add-cvm-parameter-into-the-type-of-LaunchSecurity-wh.patch
Normal file
@ -0,0 +1,189 @@
|
||||
From ddf9053ad7df4553ec4abb04370e74f90bb134cf Mon Sep 17 00:00:00 2001
|
||||
From: ikarosYuuki <tujipei@huawei.com>
|
||||
Date: Fri, 2 Aug 2024 14:16:37 +0800
|
||||
Subject: [PATCH] Add cvm parameter into the type of LaunchSecurity which is a
|
||||
optional filed for libvirt xml. Its purpose is to pass the cvm parameter
|
||||
through to qemu. Also this patch support virsh edit to save cvm parameter
|
||||
into libvirt temporary xml.
|
||||
|
||||
---
|
||||
src/conf/domain_conf.c | 4 ++++
|
||||
src/conf/domain_conf.h | 1 +
|
||||
src/conf/schemas/domaincommon.rng | 9 +++++++++
|
||||
src/qemu/qemu_command.c | 5 +++++
|
||||
src/qemu/qemu_driver.c | 8 ++++++++
|
||||
src/qemu/qemu_firmware.c | 1 +
|
||||
src/qemu/qemu_namespace.c | 1 +
|
||||
src/qemu/qemu_process.c | 1 +
|
||||
src/qemu/qemu_validate.c | 2 ++
|
||||
9 files changed, 32 insertions(+)
|
||||
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index 4798d01d12..db49355788 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -1516,6 +1516,7 @@ VIR_ENUM_IMPL(virDomainLaunchSecurity,
|
||||
"",
|
||||
"sev",
|
||||
"s390-pv",
|
||||
+ "cvm",
|
||||
);
|
||||
|
||||
typedef enum {
|
||||
@@ -3829,6 +3830,7 @@ virDomainSecDefFree(virDomainSecDef *def)
|
||||
g_free(def->data.sev.session);
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
break;
|
||||
@@ -13570,6 +13572,7 @@ virDomainSecDefParseXML(xmlNodePtr lsecNode,
|
||||
return NULL;
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
@@ -26614,6 +26617,7 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSecDef *sec)
|
||||
}
|
||||
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
||||
index e8a75afa2c..a687895726 100644
|
||||
--- a/src/conf/domain_conf.h
|
||||
+++ b/src/conf/domain_conf.h
|
||||
@@ -2858,6 +2858,7 @@ typedef enum {
|
||||
VIR_DOMAIN_LAUNCH_SECURITY_NONE,
|
||||
VIR_DOMAIN_LAUNCH_SECURITY_SEV,
|
||||
VIR_DOMAIN_LAUNCH_SECURITY_PV,
|
||||
+ VIR_DOMAIN_LAUNCH_SECURITY_CVM,
|
||||
|
||||
VIR_DOMAIN_LAUNCH_SECURITY_LAST,
|
||||
} virDomainLaunchSecurity;
|
||||
diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincommon.rng
|
||||
index b98a2ae602..f31603b2fd 100644
|
||||
--- a/src/conf/schemas/domaincommon.rng
|
||||
+++ b/src/conf/schemas/domaincommon.rng
|
||||
@@ -520,6 +520,9 @@
|
||||
<value>s390-pv</value>
|
||||
</attribute>
|
||||
</group>
|
||||
+ <group>
|
||||
+ <ref name="launchSecurityCVM"/>
|
||||
+ </group>
|
||||
</choice>
|
||||
</element>
|
||||
</define>
|
||||
@@ -565,6 +568,12 @@
|
||||
</interleave>
|
||||
</define>
|
||||
|
||||
+ <define name="launchSecurityCVM">
|
||||
+ <attribute name="type">
|
||||
+ <value>cvm</value>
|
||||
+ </attribute>
|
||||
+ </define>
|
||||
+
|
||||
<!--
|
||||
Enable or disable perf events for the domain. For each
|
||||
of the events the following rules apply:
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index 609eb6772e..6e16e65d54 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -7035,6 +7035,9 @@ qemuBuildMachineCommandLine(virCommand *cmd,
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
virBufferAddLit(&buf, ",confidential-guest-support=lsec0");
|
||||
break;
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
+ virBufferAddLit(&buf, ",kvm-type=cvm");
|
||||
+ break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, def->sec->sectype);
|
||||
@@ -9769,6 +9772,8 @@ qemuBuildSecCommandLine(virDomainObj *vm, virCommand *cmd,
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
return qemuBuildPVCommandLine(vm, cmd);
|
||||
break;
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
+ break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, sec->sectype);
|
||||
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
||||
index 6b07bcc8dc..d7fb93b3b3 100644
|
||||
--- a/src/qemu/qemu_driver.c
|
||||
+++ b/src/qemu/qemu_driver.c
|
||||
@@ -6315,6 +6315,14 @@ qemuDomainObjStart(virConnectPtr conn,
|
||||
}
|
||||
}
|
||||
|
||||
+ if (vm->def->sec && vm->def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_CVM) {
|
||||
+ if (virFileWriteStr("/proc/sys/vm/overcommit_memory", "1", 0)) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
+ _("Failed to enable overcommit_memory"));
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
ret = qemuProcessStart(conn, driver, vm, NULL, asyncJob,
|
||||
NULL, -1, NULL, NULL,
|
||||
VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags);
|
||||
diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c
|
||||
index d39e61d071..31ed6e881b 100644
|
||||
--- a/src/qemu/qemu_firmware.c
|
||||
+++ b/src/qemu/qemu_firmware.c
|
||||
@@ -1374,6 +1374,7 @@ qemuFirmwareMatchDomain(const virDomainDef *def,
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c
|
||||
index 915d44310f..ff314ce243 100644
|
||||
--- a/src/qemu/qemu_namespace.c
|
||||
+++ b/src/qemu/qemu_namespace.c
|
||||
@@ -660,6 +660,7 @@ qemuDomainSetupLaunchSecurity(virDomainObj *vm,
|
||||
VIR_DEBUG("Set up launch security for SEV");
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index 08d4f257eb..7ba5575037 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -7045,6 +7045,7 @@ qemuProcessPrepareLaunchSecurityGuestInput(virDomainObj *vm)
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
return qemuProcessPrepareSEVGuestInput(vm);
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
return 0;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
|
||||
index a51cb6017d..449fb2f2d1 100644
|
||||
--- a/src/qemu/qemu_validate.c
|
||||
+++ b/src/qemu/qemu_validate.c
|
||||
@@ -1322,6 +1322,8 @@ qemuValidateDomainDef(const virDomainDef *def,
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
+ case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
+ break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_NONE:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_LAST:
|
||||
virReportEnumRangeError(virDomainLaunchSecurity, def->sec->sectype);
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
328
Add-loongarch-cpu-support.patch
Normal file
328
Add-loongarch-cpu-support.patch
Normal file
@ -0,0 +1,328 @@
|
||||
From f4f93d489679307ca40e8cb0bd381f39ad0eff4b Mon Sep 17 00:00:00 2001
|
||||
From: xianglai li <lixianglai@loongson.cn>
|
||||
Date: Fri, 28 Jul 2023 02:45:55 -0400
|
||||
Subject: [PATCH 1/3] Add loongarch cpu support
|
||||
|
||||
Add loongarch cpu support, Define new cpu type 'loongarch64'
|
||||
and implement it's driver functions.
|
||||
|
||||
Signed-off-by: "Xianglai Li" <lixianglai@loongson.cn>
|
||||
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
|
||||
---
|
||||
src/conf/schemas/basictypes.rng | 1 +
|
||||
src/cpu/cpu.c | 2 ++
|
||||
src/cpu/cpu_loongarch.c | 58 +++++++++++++++++++++++++++++++++
|
||||
src/cpu/cpu_loongarch.h | 25 ++++++++++++++
|
||||
src/cpu/meson.build | 1 +
|
||||
src/qemu/qemu_capabilities.c | 11 ++++---
|
||||
src/qemu/qemu_domain.c | 1 +
|
||||
src/util/virarch.c | 11 ++++---
|
||||
src/util/virarch.h | 13 +++++---
|
||||
9 files changed, 108 insertions(+), 15 deletions(-)
|
||||
create mode 100644 src/cpu/cpu_loongarch.c
|
||||
create mode 100644 src/cpu/cpu_loongarch.h
|
||||
|
||||
diff --git a/src/conf/schemas/basictypes.rng b/src/conf/schemas/basictypes.rng
|
||||
index 26eb538077..f117f19d33 100644
|
||||
--- a/src/conf/schemas/basictypes.rng
|
||||
+++ b/src/conf/schemas/basictypes.rng
|
||||
@@ -444,6 +444,7 @@
|
||||
<value>i686</value>
|
||||
<value>ia64</value>
|
||||
<value>lm32</value>
|
||||
+ <value>loongarch64</value>
|
||||
<value>m68k</value>
|
||||
<value>microblaze</value>
|
||||
<value>microblazeel</value>
|
||||
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
|
||||
index 4f048d0dad..33701811fb 100644
|
||||
--- a/src/cpu/cpu.c
|
||||
+++ b/src/cpu/cpu.c
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "cpu_ppc64.h"
|
||||
#include "cpu_s390.h"
|
||||
#include "cpu_arm.h"
|
||||
+#include "cpu_loongarch.h"
|
||||
#include "cpu_riscv64.h"
|
||||
#include "capabilities.h"
|
||||
|
||||
@@ -41,6 +42,7 @@ static struct cpuArchDriver *drivers[] = {
|
||||
&cpuDriverS390,
|
||||
&cpuDriverArm,
|
||||
&cpuDriverRiscv64,
|
||||
+ &cpuDriverLoongArch,
|
||||
};
|
||||
|
||||
|
||||
diff --git a/src/cpu/cpu_loongarch.c b/src/cpu/cpu_loongarch.c
|
||||
new file mode 100644
|
||||
index 0000000000..78d9941320
|
||||
--- /dev/null
|
||||
+++ b/src/cpu/cpu_loongarch.c
|
||||
@@ -0,0 +1,58 @@
|
||||
+/*
|
||||
+ * cpu_loongarch.c: CPU driver for 64-bit LOONGARCH CPUs
|
||||
+ *
|
||||
+ * Copyright (C) 2024 Loongson Technology.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library. If not, see
|
||||
+ * <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#include <config.h>
|
||||
+#include "virlog.h"
|
||||
+#include "cpu.h"
|
||||
+
|
||||
+#define VIR_FROM_THIS VIR_FROM_CPU
|
||||
+
|
||||
+VIR_LOG_INIT("cpu.cpu_loongarch");
|
||||
+
|
||||
+static const virArch archs[] = { VIR_ARCH_LOONGARCH64 };
|
||||
+
|
||||
+static virCPUCompareResult
|
||||
+virCPULoongArchCompare(virCPUDef *host G_GNUC_UNUSED,
|
||||
+ virCPUDef *cpu G_GNUC_UNUSED,
|
||||
+ bool failIncompatible G_GNUC_UNUSED)
|
||||
+{
|
||||
+ return VIR_CPU_COMPARE_IDENTICAL;
|
||||
+}
|
||||
+
|
||||
+static int
|
||||
+virCPULoongArchUpdate(virCPUDef *guest G_GNUC_UNUSED,
|
||||
+ const virCPUDef *host G_GNUC_UNUSED,
|
||||
+ bool relative G_GNUC_UNUSED)
|
||||
+{
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+struct cpuArchDriver cpuDriverLoongArch = {
|
||||
+ .name = "LoongArch",
|
||||
+ .arch = archs,
|
||||
+ .narch = G_N_ELEMENTS(archs),
|
||||
+ .compare = virCPULoongArchCompare,
|
||||
+ .decode = NULL,
|
||||
+ .encode = NULL,
|
||||
+ .dataFree = NULL,
|
||||
+ .baseline = NULL,
|
||||
+ .update = virCPULoongArchUpdate,
|
||||
+ .getModels = NULL,
|
||||
+};
|
||||
diff --git a/src/cpu/cpu_loongarch.h b/src/cpu/cpu_loongarch.h
|
||||
new file mode 100644
|
||||
index 0000000000..4bc1c0cd8f
|
||||
--- /dev/null
|
||||
+++ b/src/cpu/cpu_loongarch.h
|
||||
@@ -0,0 +1,25 @@
|
||||
+/*
|
||||
+ * cpu_loongarch.h: CPU driver for 64-bit LOONGARCH CPUs
|
||||
+ *
|
||||
+ * Copyright (C) 2024 Loongson Technology.
|
||||
+ *
|
||||
+ * This library is free software; you can redistribute it and/or
|
||||
+ * modify it under the terms of the GNU Lesser General Public
|
||||
+ * License as published by the Free Software Foundation; either
|
||||
+ * version 2.1 of the License, or (at your option) any later version.
|
||||
+ *
|
||||
+ * This library is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
+ * Lesser General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU Lesser General Public
|
||||
+ * License along with this library. If not, see
|
||||
+ * <http://www.gnu.org/licenses/>.
|
||||
+ */
|
||||
+
|
||||
+#pragma once
|
||||
+
|
||||
+#include "cpu.h"
|
||||
+
|
||||
+extern struct cpuArchDriver cpuDriverLoongArch;
|
||||
diff --git a/src/cpu/meson.build b/src/cpu/meson.build
|
||||
index 55396903b9..141230e380 100644
|
||||
--- a/src/cpu/meson.build
|
||||
+++ b/src/cpu/meson.build
|
||||
@@ -1,6 +1,7 @@
|
||||
cpu_sources = [
|
||||
'cpu.c',
|
||||
'cpu_arm.c',
|
||||
+ 'cpu_loongarch.c',
|
||||
'cpu_map.c',
|
||||
'cpu_ppc64.c',
|
||||
'cpu_riscv64.c',
|
||||
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
||||
index d25062b225..509e751274 100644
|
||||
--- a/src/qemu/qemu_capabilities.c
|
||||
+++ b/src/qemu/qemu_capabilities.c
|
||||
@@ -2667,36 +2667,37 @@ static const char *preferredMachines[] =
|
||||
NULL, /* VIR_ARCH_ITANIUM (doesn't exist in QEMU any more) */
|
||||
"lm32-evr", /* VIR_ARCH_LM32 */
|
||||
|
||||
+ NULL, /* VIR_ARCH_LOONGARCH64 */
|
||||
"mcf5208evb", /* VIR_ARCH_M68K */
|
||||
"petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZE */
|
||||
"petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZEEL */
|
||||
"malta", /* VIR_ARCH_MIPS */
|
||||
- "malta", /* VIR_ARCH_MIPSEL */
|
||||
|
||||
+ "malta", /* VIR_ARCH_MIPSEL */
|
||||
"malta", /* VIR_ARCH_MIPS64 */
|
||||
"malta", /* VIR_ARCH_MIPS64EL */
|
||||
"or1k-sim", /* VIR_ARCH_OR32 */
|
||||
NULL, /* VIR_ARCH_PARISC (no QEMU impl) */
|
||||
- NULL, /* VIR_ARCH_PARISC64 (no QEMU impl) */
|
||||
|
||||
+ NULL, /* VIR_ARCH_PARISC64 (no QEMU impl) */
|
||||
"g3beige", /* VIR_ARCH_PPC */
|
||||
"g3beige", /* VIR_ARCH_PPCLE */
|
||||
"pseries", /* VIR_ARCH_PPC64 */
|
||||
"pseries", /* VIR_ARCH_PPC64LE */
|
||||
- "bamboo", /* VIR_ARCH_PPCEMB */
|
||||
|
||||
+ "bamboo", /* VIR_ARCH_PPCEMB */
|
||||
"virt", /* VIR_ARCH_RISCV32 */
|
||||
"virt", /* VIR_ARCH_RISCV64 */
|
||||
NULL, /* VIR_ARCH_S390 (no QEMU impl) */
|
||||
"s390-ccw-virtio", /* VIR_ARCH_S390X */
|
||||
- "shix", /* VIR_ARCH_SH4 */
|
||||
|
||||
+ "shix", /* VIR_ARCH_SH4 */
|
||||
"shix", /* VIR_ARCH_SH4EB */
|
||||
"SS-5", /* VIR_ARCH_SPARC */
|
||||
"sun4u", /* VIR_ARCH_SPARC64 */
|
||||
"puv3", /* VIR_ARCH_UNICORE32 */
|
||||
- "pc", /* VIR_ARCH_X86_64 */
|
||||
|
||||
+ "pc", /* VIR_ARCH_X86_64 */
|
||||
"sim", /* VIR_ARCH_XTENSA */
|
||||
"sim", /* VIR_ARCH_XTENSAEB */
|
||||
};
|
||||
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||
index d54846e734..8374780507 100644
|
||||
--- a/src/qemu/qemu_domain.c
|
||||
+++ b/src/qemu/qemu_domain.c
|
||||
@@ -4233,6 +4233,7 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
|
||||
case VIR_ARCH_CRIS:
|
||||
case VIR_ARCH_ITANIUM:
|
||||
case VIR_ARCH_LM32:
|
||||
+ case VIR_ARCH_LOONGARCH64:
|
||||
case VIR_ARCH_M68K:
|
||||
case VIR_ARCH_MICROBLAZE:
|
||||
case VIR_ARCH_MICROBLAZEEL:
|
||||
diff --git a/src/util/virarch.c b/src/util/virarch.c
|
||||
index 01e520de73..8545f993ea 100644
|
||||
--- a/src/util/virarch.c
|
||||
+++ b/src/util/virarch.c
|
||||
@@ -51,36 +51,37 @@ static const struct virArchData {
|
||||
{ "ia64", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "lm32", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
|
||||
+ { "loongarch64", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "m68k", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "microblaze", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "microblazeel", 32, VIR_ARCH_LITTLE_ENDIAN},
|
||||
{ "mips", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
- { "mipsel", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
|
||||
+ { "mipsel", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "mips64", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "mips64el", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "openrisc", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "parisc", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
- { "parisc64", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
|
||||
+ { "parisc64", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "ppc", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "ppcle", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "ppc64", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "ppc64le", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
- { "ppcemb", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
|
||||
+ { "ppcemb", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "riscv32", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "riscv64", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "s390", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "s390x", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
- { "sh4", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
|
||||
+ { "sh4", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "sh4eb", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "sparc", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "sparc64", 64, VIR_ARCH_BIG_ENDIAN },
|
||||
{ "unicore32", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
- { "x86_64", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
|
||||
+ { "x86_64", 64, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "xtensa", 32, VIR_ARCH_LITTLE_ENDIAN },
|
||||
{ "xtensaeb", 32, VIR_ARCH_BIG_ENDIAN },
|
||||
};
|
||||
diff --git a/src/util/virarch.h b/src/util/virarch.h
|
||||
index 747f77c48e..2c01a13b8e 100644
|
||||
--- a/src/util/virarch.h
|
||||
+++ b/src/util/virarch.h
|
||||
@@ -36,36 +36,37 @@ typedef enum {
|
||||
VIR_ARCH_ITANIUM, /* Itanium 64 LE https://en.wikipedia.org/wiki/Itanium */
|
||||
VIR_ARCH_LM32, /* MilkyMist 32 BE https://en.wikipedia.org/wiki/Milkymist */
|
||||
|
||||
+ VIR_ARCH_LOONGARCH64, /* LoongArch 64 LE https://en.wikipedia.org/wiki/Loongson#LoongArch */
|
||||
VIR_ARCH_M68K, /* m68k 32 BE https://en.wikipedia.org/wiki/Motorola_68000_family */
|
||||
VIR_ARCH_MICROBLAZE, /* Microblaze 32 BE https://en.wikipedia.org/wiki/MicroBlaze */
|
||||
VIR_ARCH_MICROBLAZEEL, /* Microblaze 32 LE https://en.wikipedia.org/wiki/MicroBlaze */
|
||||
VIR_ARCH_MIPS, /* MIPS 32 BE https://en.wikipedia.org/wiki/MIPS_architecture */
|
||||
- VIR_ARCH_MIPSEL, /* MIPS 32 LE https://en.wikipedia.org/wiki/MIPS_architecture */
|
||||
|
||||
+ VIR_ARCH_MIPSEL, /* MIPS 32 LE https://en.wikipedia.org/wiki/MIPS_architecture */
|
||||
VIR_ARCH_MIPS64, /* MIPS 64 BE https://en.wikipedia.org/wiki/MIPS_architecture */
|
||||
VIR_ARCH_MIPS64EL, /* MIPS 64 LE https://en.wikipedia.org/wiki/MIPS_architecture */
|
||||
VIR_ARCH_OR32, /* OpenRisc 32 BE https://en.wikipedia.org/wiki/OpenRISC#QEMU_support */
|
||||
VIR_ARCH_PARISC, /* PA-Risc 32 BE https://en.wikipedia.org/wiki/PA-RISC */
|
||||
- VIR_ARCH_PARISC64, /* PA-Risc 64 BE https://en.wikipedia.org/wiki/PA-RISC */
|
||||
|
||||
+ VIR_ARCH_PARISC64, /* PA-Risc 64 BE https://en.wikipedia.org/wiki/PA-RISC */
|
||||
VIR_ARCH_PPC, /* PowerPC 32 BE https://en.wikipedia.org/wiki/PowerPC */
|
||||
VIR_ARCH_PPCLE, /* PowerPC 32 LE https://en.wikipedia.org/wiki/PowerPC */
|
||||
VIR_ARCH_PPC64, /* PowerPC 64 BE https://en.wikipedia.org/wiki/PowerPC */
|
||||
VIR_ARCH_PPC64LE, /* PowerPC 64 LE https://en.wikipedia.org/wiki/PowerPC */
|
||||
- VIR_ARCH_PPCEMB, /* PowerPC 32 BE https://en.wikipedia.org/wiki/PowerPC */
|
||||
|
||||
+ VIR_ARCH_PPCEMB, /* PowerPC 32 BE https://en.wikipedia.org/wiki/PowerPC */
|
||||
VIR_ARCH_RISCV32, /* RISC-V 32 LE https://en.wikipedia.org/wiki/RISC-V */
|
||||
VIR_ARCH_RISCV64, /* RISC-V 64 LE https://en.wikipedia.org/wiki/RISC-V */
|
||||
VIR_ARCH_S390, /* S390 32 BE https://en.wikipedia.org/wiki/S390 */
|
||||
VIR_ARCH_S390X, /* S390 64 BE https://en.wikipedia.org/wiki/S390x */
|
||||
- VIR_ARCH_SH4, /* SuperH4 32 LE https://en.wikipedia.org/wiki/SuperH */
|
||||
|
||||
+ VIR_ARCH_SH4, /* SuperH4 32 LE https://en.wikipedia.org/wiki/SuperH */
|
||||
VIR_ARCH_SH4EB, /* SuperH4 32 BE https://en.wikipedia.org/wiki/SuperH */
|
||||
VIR_ARCH_SPARC, /* Sparc 32 BE https://en.wikipedia.org/wiki/Sparc */
|
||||
VIR_ARCH_SPARC64, /* Sparc 64 BE https://en.wikipedia.org/wiki/Sparc */
|
||||
VIR_ARCH_UNICORE32, /* UniCore 32 LE https://en.wikipedia.org/wiki/Unicore */
|
||||
- VIR_ARCH_X86_64, /* x86 64 LE https://en.wikipedia.org/wiki/X86 */
|
||||
|
||||
+ VIR_ARCH_X86_64, /* x86 64 LE https://en.wikipedia.org/wiki/X86 */
|
||||
VIR_ARCH_XTENSA, /* XTensa 32 LE https://en.wikipedia.org/wiki/Xtensa#Processor_Cores */
|
||||
VIR_ARCH_XTENSAEB, /* XTensa 32 BE https://en.wikipedia.org/wiki/Xtensa#Processor_Cores */
|
||||
|
||||
@@ -106,6 +107,8 @@ typedef enum {
|
||||
#define ARCH_IS_SH4(arch) ((arch) == VIR_ARCH_SH4 ||\
|
||||
(arch) == VIR_ARCH_SH4EB)
|
||||
|
||||
+#define ARCH_IS_LOONGARCH(arch) ((arch) == VIR_ARCH_LOONGARCH64)
|
||||
+
|
||||
typedef enum {
|
||||
VIR_ARCH_LITTLE_ENDIAN,
|
||||
VIR_ARCH_BIG_ENDIAN,
|
||||
--
|
||||
2.39.1
|
||||
|
||||
509
Add-the-get-tmm-memory-info-API-into-libvirt-host.-A.patch
Normal file
509
Add-the-get-tmm-memory-info-API-into-libvirt-host.-A.patch
Normal file
@ -0,0 +1,509 @@
|
||||
From 96ec8dcd8c5ac0459259cf0d40a163bcee668484 Mon Sep 17 00:00:00 2001
|
||||
From: ikarosYuuki <tujipei@huawei.com>
|
||||
Date: Fri, 2 Aug 2024 14:18:11 +0800
|
||||
Subject: [PATCH] Add the get tmm memory info API into libvirt-host. Also
|
||||
should add the RPC calls into libvirtd for API calling.
|
||||
|
||||
---
|
||||
include/libvirt/libvirt-host.h | 2 +
|
||||
scripts/apibuild.py | 1 +
|
||||
scripts/check-aclrules.py | 1 +
|
||||
src/driver-hypervisor.h | 5 ++
|
||||
src/libvirt-host.c | 36 ++++++++
|
||||
src/libvirt_public.syms | 1 +
|
||||
src/qemu/qemu_driver.c | 128 ++++++++++++++++++++++++++++
|
||||
src/remote/remote_daemon_dispatch.c | 22 +++++
|
||||
src/remote/remote_driver.c | 28 ++++++
|
||||
src/remote/remote_protocol.x | 17 +++-
|
||||
tools/virsh-host.c | 98 +++++++++++++++++++++
|
||||
11 files changed, 338 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h
|
||||
index 3112f2b676..af7dede24e 100644
|
||||
--- a/include/libvirt/libvirt-host.h
|
||||
+++ b/include/libvirt/libvirt-host.h
|
||||
@@ -1016,5 +1016,7 @@ int virNodeAllocPages(virConnectPtr conn,
|
||||
unsigned int cellCount,
|
||||
unsigned int flags);
|
||||
|
||||
+char *virConnectGetTmmMemoryInfo(virConnectPtr conn,
|
||||
+ unsigned int detail);
|
||||
|
||||
#endif /* LIBVIRT_HOST_H */
|
||||
diff --git a/scripts/apibuild.py b/scripts/apibuild.py
|
||||
index 3ecc3eadf7..f1cfa5aa0a 100755
|
||||
--- a/scripts/apibuild.py
|
||||
+++ b/scripts/apibuild.py
|
||||
@@ -109,6 +109,7 @@ ignored_functions = {
|
||||
"virDomainMigrateConfirm3Params": "private function for migration",
|
||||
"virDomainMigratePrepareTunnel3Params": "private function for tunnelled migration",
|
||||
"virErrorCopyNew": "private",
|
||||
+ "virConnectGetTmmMemoryInfo": "private function for tmm",
|
||||
}
|
||||
|
||||
# The version in the .sym file might different from
|
||||
diff --git a/scripts/check-aclrules.py b/scripts/check-aclrules.py
|
||||
index e39dbd2ba8..e6bcf00b11 100755
|
||||
--- a/scripts/check-aclrules.py
|
||||
+++ b/scripts/check-aclrules.py
|
||||
@@ -54,6 +54,7 @@ permitted = {
|
||||
"localOnly": True,
|
||||
"domainQemuAttach": True,
|
||||
"domainHotpatchManage": True,
|
||||
+ "connectGetTmmMemoryInfo": True,
|
||||
}
|
||||
|
||||
# XXX this vzDomainMigrateConfirm3Params looks
|
||||
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
|
||||
index e54af0515f..619a091ffa 100644
|
||||
--- a/src/driver-hypervisor.h
|
||||
+++ b/src/driver-hypervisor.h
|
||||
@@ -1457,6 +1457,10 @@ typedef char *
|
||||
|
||||
typedef struct _virHypervisorDriver virHypervisorDriver;
|
||||
|
||||
+typedef char *
|
||||
+(*virDrvConnectGetTmmMemoryInfo)(virConnectPtr conn,
|
||||
+ bool detail);
|
||||
+
|
||||
/**
|
||||
* _virHypervisorDriver:
|
||||
*
|
||||
@@ -1728,4 +1732,5 @@ struct _virHypervisorDriver {
|
||||
virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc;
|
||||
virDrvDomainFDAssociate domainFDAssociate;
|
||||
virDrvDomainHotpatchManage domainHotpatchManage;
|
||||
+ virDrvConnectGetTmmMemoryInfo connectGetTmmMemoryInfo;
|
||||
};
|
||||
diff --git a/src/libvirt-host.c b/src/libvirt-host.c
|
||||
index e67b36812e..e763d5c86c 100644
|
||||
--- a/src/libvirt-host.c
|
||||
+++ b/src/libvirt-host.c
|
||||
@@ -1829,3 +1829,39 @@ virNodeGetSEVInfo(virConnectPtr conn,
|
||||
virDispatchError(conn);
|
||||
return -1;
|
||||
}
|
||||
+
|
||||
+/*
|
||||
+ * virConnectGetTmmMemoryInfo:
|
||||
+ * @conn: pointer to the hypervisor connection
|
||||
+ * @detail: whether libvirtd return detailed tmm memory information;
|
||||
+ * the default value is 0 which means don't return detailed tmm memory information.
|
||||
+ *
|
||||
+ * If Tmm enable, then will fill the cotents of string buffer with tmm memory information.
|
||||
+ *
|
||||
+ * Returns string ptr in case of success, and NULL in case of failure.
|
||||
+ *
|
||||
+ * Since: 9.7.0
|
||||
+ */
|
||||
+char *
|
||||
+virConnectGetTmmMemoryInfo(virConnectPtr conn,
|
||||
+ unsigned int detail)
|
||||
+{
|
||||
+ VIR_DEBUG("conn=%p", conn);
|
||||
+
|
||||
+ virResetLastError();
|
||||
+
|
||||
+ virCheckConnectReturn(conn, NULL);
|
||||
+
|
||||
+ if (conn->driver->connectGetTmmMemoryInfo) {
|
||||
+ char *ret;
|
||||
+ ret = conn->driver->connectGetTmmMemoryInfo(conn, detail);
|
||||
+ if (!ret)
|
||||
+ goto error;
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ virReportUnsupportedError();
|
||||
+ error:
|
||||
+ virDispatchError(conn);
|
||||
+ return NULL;
|
||||
+}
|
||||
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
|
||||
index 8b38fe9a5f..72efec0b61 100644
|
||||
--- a/src/libvirt_public.syms
|
||||
+++ b/src/libvirt_public.syms
|
||||
@@ -941,6 +941,7 @@ LIBVIRT_9.7.0 {
|
||||
global:
|
||||
virNetworkGetMetadata;
|
||||
virNetworkSetMetadata;
|
||||
+ virConnectGetTmmMemoryInfo;
|
||||
} LIBVIRT_9.0.0;
|
||||
|
||||
# .... define new API here using predicted next version number ....
|
||||
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
||||
index d7fb93b3b3..5a5aa28449 100644
|
||||
--- a/src/qemu/qemu_driver.c
|
||||
+++ b/src/qemu/qemu_driver.c
|
||||
@@ -20010,6 +20010,133 @@ qemuDomainHotpatchManage(virDomainPtr domain,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+static int
|
||||
+qemuConnectTmmInfoListAppend(char **format,
|
||||
+ char **infoStrList,
|
||||
+ int targetNumaNum,
|
||||
+ int *startIndex,
|
||||
+ int maxListSize)
|
||||
+{
|
||||
+ char *numStart;
|
||||
+ char *strPtr = NULL;
|
||||
+ int numaNode, index, ret = 0;
|
||||
+
|
||||
+ for (index = *startIndex; index < maxListSize; index++) {
|
||||
+ if (strlen(infoStrList[index]) == 0)
|
||||
+ break;
|
||||
+
|
||||
+ numStart = strstr(infoStrList[index], "node ");
|
||||
+ if (!numStart)
|
||||
+ return -1;
|
||||
+
|
||||
+ virSkipToDigit((const char **)(&numStart));
|
||||
+ ret = virStrToLong_i(numStart, &numStart, 10, &numaNode);
|
||||
+ if (ret < 0) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
+ _("Failed to get current numa node"));
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ if (numaNode == targetNumaNum) {
|
||||
+ strPtr = *format;
|
||||
+ *format = g_strconcat(*format, "\n", infoStrList[index], NULL);
|
||||
+ free(strPtr);
|
||||
+ } else {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *startIndex = index;
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+static char *
|
||||
+qemuConnectTmmDetailInfoFormat(char *baseMeminfo,
|
||||
+ char *slabInfo)
|
||||
+{
|
||||
+ int ret, i = 0, j = 0;
|
||||
+ char *numStart, *numListStart, *format = NULL;
|
||||
+ char **baseMeminfoSplits = g_strsplit(baseMeminfo, "\n", 0);
|
||||
+ char **slabInfoSplits = g_strsplit(slabInfo, "\n", 0);
|
||||
+ int numaSize, numaIndex, headNumaNode;
|
||||
+ ssize_t meminfoListSize = g_strv_length(baseMeminfoSplits);
|
||||
+ ssize_t slabInfoSize = g_strv_length(slabInfoSplits);
|
||||
+
|
||||
+ numStart = strchr(baseMeminfoSplits[i], ':');
|
||||
+ numListStart = strchr(baseMeminfoSplits[i], '(');
|
||||
+ if (!numStart || !numListStart)
|
||||
+ goto cleanup;
|
||||
+
|
||||
+ virSkipToDigit((const char **)(&numStart));
|
||||
+ ret = virStrToLong_i(numStart, &numStart, 10, &numaSize);
|
||||
+ if (ret < 0) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
+ _("Failed to get available numa size"));
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ format = g_strconcat(baseMeminfoSplits[i++], NULL);
|
||||
+
|
||||
+ virSkipToDigit((const char **)(&numListStart));
|
||||
+ for (numaIndex = 0; *numListStart && numaIndex < numaSize; numaIndex++, numListStart++) {
|
||||
+ ret = virStrToLong_i(numListStart, &numListStart, 10, &headNumaNode);
|
||||
+ if (ret < 0) {
|
||||
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
+ _("Failed to get current numa node"));
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+ ret = qemuConnectTmmInfoListAppend(&format, baseMeminfoSplits, headNumaNode, &i, meminfoListSize);
|
||||
+ if (ret < 0)
|
||||
+ goto cleanup;
|
||||
+ ret = qemuConnectTmmInfoListAppend(&format, slabInfoSplits, headNumaNode, &j, slabInfoSize);
|
||||
+ if (ret < 0)
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+
|
||||
+cleanup:
|
||||
+ g_strfreev(baseMeminfoSplits);
|
||||
+ g_strfreev(slabInfoSplits);
|
||||
+ return format;
|
||||
+}
|
||||
+
|
||||
+static char *
|
||||
+qemuConnectGetTmmMemoryInfo(virConnectPtr conn G_GNUC_UNUSED,
|
||||
+ bool detail)
|
||||
+{
|
||||
+ int maxLen = 10 * 1024;
|
||||
+ char *meminfo = NULL;
|
||||
+ g_autofree char *formatInfo = NULL;
|
||||
+ g_autofree char *baseMeminfo = NULL;
|
||||
+ g_autofree char *slabInfo = NULL;
|
||||
+ g_autofree char *buddyInfo = NULL;
|
||||
+
|
||||
+ if (virFileReadAll("/sys/kernel/tmm/memory_info", maxLen, &baseMeminfo) < 0)
|
||||
+ goto end;
|
||||
+ if (detail && virFileReadAll("/sys/kernel/tmm/slab_info", maxLen, &slabInfo) < 0)
|
||||
+ goto end;
|
||||
+ if (detail && virFileReadAll("/sys/kernel/tmm/buddy_info", maxLen, &buddyInfo) < 0)
|
||||
+ goto end;
|
||||
+
|
||||
+ if (detail) {
|
||||
+ if (!virStringIsEmpty(baseMeminfo) && !virStringIsEmpty(slabInfo)) {
|
||||
+ formatInfo = qemuConnectTmmDetailInfoFormat(baseMeminfo, slabInfo);
|
||||
+ if (formatInfo == NULL)
|
||||
+ goto end;
|
||||
+ } else {
|
||||
+ formatInfo = g_strdup_printf(_("%s%s"), baseMeminfo, slabInfo);
|
||||
+ }
|
||||
+
|
||||
+ meminfo = g_strdup_printf(_("%s\n%s"), formatInfo, buddyInfo);
|
||||
+ } else {
|
||||
+ meminfo = g_steal_pointer(&baseMeminfo);
|
||||
+ }
|
||||
+
|
||||
+end:
|
||||
+ return meminfo;
|
||||
+}
|
||||
+
|
||||
static virHypervisorDriver qemuHypervisorDriver = {
|
||||
.name = QEMU_DRIVER_NAME,
|
||||
.connectURIProbe = qemuConnectURIProbe,
|
||||
@@ -20260,6 +20387,7 @@ static virHypervisorDriver qemuHypervisorDriver = {
|
||||
.domainStartDirtyRateCalc = qemuDomainStartDirtyRateCalc, /* 7.2.0 */
|
||||
.domainSetLaunchSecurityState = qemuDomainSetLaunchSecurityState, /* 8.0.0 */
|
||||
.domainFDAssociate = qemuDomainFDAssociate, /* 9.0.0 */
|
||||
+ .connectGetTmmMemoryInfo = qemuConnectGetTmmMemoryInfo, /* 9.0.0 */
|
||||
};
|
||||
|
||||
|
||||
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
|
||||
index 7542caa952..10f343843a 100644
|
||||
--- a/src/remote/remote_daemon_dispatch.c
|
||||
+++ b/src/remote/remote_daemon_dispatch.c
|
||||
@@ -7125,6 +7125,28 @@ remoteDispatchNetworkPortGetParameters(virNetServer *server G_GNUC_UNUSED,
|
||||
return rv;
|
||||
}
|
||||
|
||||
+static int
|
||||
+remoteDispatchConnectGetTmmMemoryInfo(virNetServer *server G_GNUC_UNUSED,
|
||||
+ virNetServerClient *client,
|
||||
+ virNetMessage *msg G_GNUC_UNUSED,
|
||||
+ struct virNetMessageError *rerr,
|
||||
+ remote_connect_get_tmm_memory_info_args *args,
|
||||
+ remote_connect_get_tmm_memory_info_ret *ret)
|
||||
+{
|
||||
+ int rv = -1;
|
||||
+ char *meminfo = NULL;
|
||||
+ virConnectPtr conn = remoteGetHypervisorConn(client);
|
||||
+
|
||||
+ if (conn && (meminfo = virConnectGetTmmMemoryInfo(conn, args->detail))) {
|
||||
+ rv = 0;
|
||||
+ ret->meminfo = meminfo;
|
||||
+ }
|
||||
+
|
||||
+ if (rv < 0)
|
||||
+ virNetMessageSaveError(rerr);
|
||||
+
|
||||
+ return rv;
|
||||
+}
|
||||
|
||||
/*----- Helpers. -----*/
|
||||
|
||||
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
|
||||
index 9350e811d6..4b9ad30ed6 100644
|
||||
--- a/src/remote/remote_driver.c
|
||||
+++ b/src/remote/remote_driver.c
|
||||
@@ -7406,6 +7406,33 @@ remoteDomainFDAssociate(virDomainPtr domain,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+static char *
|
||||
+remoteConnectGetTmmMemoryInfo(virConnectPtr conn,
|
||||
+ bool detail)
|
||||
+{
|
||||
+ char *rv = NULL;
|
||||
+ struct private_data *priv = conn->privateData;
|
||||
+ remote_connect_get_tmm_memory_info_args args;
|
||||
+ remote_connect_get_tmm_memory_info_ret ret;
|
||||
+
|
||||
+ remoteDriverLock(priv);
|
||||
+
|
||||
+ args.detail = detail;
|
||||
+
|
||||
+ memset(&ret, 0, sizeof(ret));
|
||||
+
|
||||
+ if (call(conn, priv, 0, REMOTE_PROC_CONNECT_GET_TMM_MEMORY_INFO,
|
||||
+ (xdrproc_t)xdr_remote_connect_get_tmm_memory_info_args, (char *)&args,
|
||||
+ (xdrproc_t)xdr_remote_connect_get_tmm_memory_info_ret, (char *)&ret) < 0) {
|
||||
+ goto done;
|
||||
+ }
|
||||
+
|
||||
+ rv = ret.meminfo;
|
||||
+
|
||||
+ done:
|
||||
+ remoteDriverUnlock(priv);
|
||||
+ return rv;
|
||||
+}
|
||||
|
||||
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
||||
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
|
||||
@@ -7849,6 +7876,7 @@ static virHypervisorDriver hypervisor_driver = {
|
||||
.domainStartDirtyRateCalc = remoteDomainStartDirtyRateCalc, /* 7.2.0 */
|
||||
.domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */
|
||||
.domainFDAssociate = remoteDomainFDAssociate, /* 9.0.0 */
|
||||
+ .connectGetTmmMemoryInfo = remoteConnectGetTmmMemoryInfo /* 9.0.0 */
|
||||
};
|
||||
|
||||
static virNetworkDriver network_driver = {
|
||||
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
|
||||
index eea11df2ea..39069ce207 100644
|
||||
--- a/src/remote/remote_protocol.x
|
||||
+++ b/src/remote/remote_protocol.x
|
||||
@@ -3973,6 +3973,15 @@ struct remote_domain_fd_associate_args {
|
||||
remote_nonnull_string name;
|
||||
unsigned int flags;
|
||||
};
|
||||
+
|
||||
+struct remote_connect_get_tmm_memory_info_args {
|
||||
+ unsigned int detail;
|
||||
+};
|
||||
+
|
||||
+struct remote_connect_get_tmm_memory_info_ret {
|
||||
+ remote_nonnull_string meminfo;
|
||||
+};
|
||||
+
|
||||
/*----- Protocol. -----*/
|
||||
|
||||
/* Define the program number, protocol version and procedure numbers here. */
|
||||
@@ -7038,5 +7047,11 @@ enum remote_procedure {
|
||||
* @generate: both
|
||||
* @acl: domain:read
|
||||
*/
|
||||
- REMOTE_PROC_DOMAIN_HOTPATCH_MANAGE = 800
|
||||
+ REMOTE_PROC_DOMAIN_HOTPATCH_MANAGE = 800,
|
||||
+
|
||||
+ /**
|
||||
+ * @generate: none
|
||||
+ * @acl: connect:read
|
||||
+ */
|
||||
+ REMOTE_PROC_CONNECT_GET_TMM_MEMORY_INFO = 900
|
||||
};
|
||||
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
|
||||
index 6c14be865f..7fdd6aed53 100644
|
||||
--- a/tools/virsh-host.c
|
||||
+++ b/tools/virsh-host.c
|
||||
@@ -1826,6 +1826,98 @@ cmdHypervisorCPUBaseline(vshControl *ctl,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+ * "securememinfo" command
|
||||
+ */
|
||||
+static const vshCmdInfo info_tmm[] = {
|
||||
+ {.name = "help",
|
||||
+ .data = N_("Interaction with the tmm")
|
||||
+ },
|
||||
+ {.name = "desc",
|
||||
+ .data = N_("Call the host kernel dev which is provided for virsh to use receiving tmm informations.")
|
||||
+ },
|
||||
+ {.name = NULL}
|
||||
+};
|
||||
+
|
||||
+static const vshCmdOptDef opts_tmm[] = {
|
||||
+ {.name = "dev",
|
||||
+ .type = VSH_OT_DATA,
|
||||
+ .flags = VSH_OFLAG_REQ,
|
||||
+ .help = N_("Device name of host kernel dev")
|
||||
+ },
|
||||
+ {.name = "detail",
|
||||
+ .type = VSH_OT_BOOL,
|
||||
+ .help = N_("print detailed info if this option contained in cmd")
|
||||
+ },
|
||||
+ {.name = NULL}
|
||||
+};
|
||||
+
|
||||
+static bool
|
||||
+virshGetTmmMemoryInfo(vshControl *ctl,
|
||||
+ const vshCmd *cmd)
|
||||
+{
|
||||
+ char *tmmMemoryInfo = NULL;
|
||||
+ bool detail;
|
||||
+ virshControl *priv = ctl->privData;
|
||||
+
|
||||
+ detail = vshCommandOptBool(cmd, "detail");
|
||||
+ if (!(tmmMemoryInfo = virConnectGetTmmMemoryInfo(priv->conn, (unsigned int)detail))) {
|
||||
+ vshError(ctl, _("Get tmm_memory_info failed"));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ vshPrintExtra(ctl, _("%s"), tmmMemoryInfo);
|
||||
+
|
||||
+ VIR_FREE(tmmMemoryInfo);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+typedef bool
|
||||
+(*virshTmmFunc)(vshControl *ctl,
|
||||
+ const vshCmd *cmd);
|
||||
+
|
||||
+struct _virshTmmFuncInfo {
|
||||
+ const char *devName;
|
||||
+ virshTmmFunc funcPtr;
|
||||
+};
|
||||
+
|
||||
+typedef struct _virshTmmFuncInfo virshTmmFuncInfo;
|
||||
+
|
||||
+static virshTmmFuncInfo virshTmmFuncMap[] = {
|
||||
+ {"tmm_memory_info", virshGetTmmMemoryInfo},
|
||||
+};
|
||||
+
|
||||
+static bool
|
||||
+virshTmmRunFunc(vshControl *ctl,
|
||||
+ const char *devName,
|
||||
+ const vshCmd *cmd)
|
||||
+{
|
||||
+ int funcIndex;
|
||||
+
|
||||
+ for (funcIndex = 0; funcIndex < sizeof(virshTmmFuncMap) / sizeof(virshTmmFuncInfo); funcIndex++) {
|
||||
+ if (strcmp(devName, virshTmmFuncMap[funcIndex].devName) == 0) {
|
||||
+ virshTmmFuncMap[funcIndex].funcPtr(ctl, cmd);
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ vshError(ctl, _("Invalid dev name"));
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static bool
|
||||
+cmdTmm(vshControl *ctl, const vshCmd *cmd)
|
||||
+{
|
||||
+ const char *devName = NULL;
|
||||
+
|
||||
+ if (vshCommandOptStringReq(ctl, cmd, "dev", &devName) < 0)
|
||||
+ return false;
|
||||
+
|
||||
+ if (!virshTmmRunFunc(ctl, devName, cmd))
|
||||
+ return false;
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
|
||||
const vshCmdDef hostAndHypervisorCmds[] = {
|
||||
{.name = "allocpages",
|
||||
@@ -1960,5 +2052,11 @@ const vshCmdDef hostAndHypervisorCmds[] = {
|
||||
.info = info_version,
|
||||
.flags = 0
|
||||
},
|
||||
+ {.name = "tmm",
|
||||
+ .handler = cmdTmm,
|
||||
+ .opts = opts_tmm,
|
||||
+ .info = info_tmm,
|
||||
+ .flags = 0
|
||||
+ },
|
||||
{.name = NULL}
|
||||
};
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
151
Automatically-unbind-all-devices-driver-under-same-r.patch
Normal file
151
Automatically-unbind-all-devices-driver-under-same-r.patch
Normal file
@ -0,0 +1,151 @@
|
||||
From f81b9542f0d172c06cb38efb61b472786533ae3f Mon Sep 17 00:00:00 2001
|
||||
From: yangxiangkai <yangxiangkai@huawei.com>
|
||||
Date: Wed, 4 Sep 2024 03:43:09 +0000
|
||||
Subject: [PATCH] Automatically unbind all devices' driver under same root port
|
||||
and bind to vfio-pci in the context of CVM.
|
||||
|
||||
---
|
||||
src/hypervisor/virhostdev.c | 5 ++++
|
||||
src/hypervisor/virhostdev.h | 1 +
|
||||
src/qemu/qemu_process.c | 3 +++
|
||||
src/util/virpci.c | 53 +++++++++++++++++++++++++++++++++++++
|
||||
src/util/virpci.h | 3 +++
|
||||
5 files changed, 65 insertions(+)
|
||||
|
||||
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
|
||||
index 4672bd8785..43493fc64a 100644
|
||||
--- a/src/hypervisor/virhostdev.c
|
||||
+++ b/src/hypervisor/virhostdev.c
|
||||
@@ -707,6 +707,8 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mgr,
|
||||
* shared across guests. Check if that's the case. */
|
||||
if (usesVFIO) {
|
||||
data.usesVFIO = true;
|
||||
+ if (flags & VIR_HOSTDEV_SP_SECURE)
|
||||
+ virtccaVirPCIDeviceSetSecure(pci, true);
|
||||
if (virPCIDeviceAddressIOMMUGroupIterate(devAddr,
|
||||
virHostdevIsPCINodeDeviceUsed,
|
||||
&data) < 0)
|
||||
@@ -735,6 +737,9 @@ virHostdevPreparePCIDevicesImpl(virHostdevManager *mgr,
|
||||
* actual device going forward */
|
||||
VIR_DEBUG("Detaching managed PCI device %s",
|
||||
virPCIDeviceGetName(pci));
|
||||
+ if (virtccaVirPCIDeviceGetSecure(pci))
|
||||
+ virtccaVirPCIDeviceDetach(pci);
|
||||
+
|
||||
if (virPCIDeviceDetach(pci,
|
||||
mgr->activePCIHostdevs,
|
||||
mgr->inactivePCIHostdevs) < 0)
|
||||
diff --git a/src/hypervisor/virhostdev.h b/src/hypervisor/virhostdev.h
|
||||
index 642d753ffb..6150d327aa 100644
|
||||
--- a/src/hypervisor/virhostdev.h
|
||||
+++ b/src/hypervisor/virhostdev.h
|
||||
@@ -38,6 +38,7 @@ typedef enum {
|
||||
VIR_HOSTDEV_SP_PCI = (1 << 8), /* support pci passthrough */
|
||||
VIR_HOSTDEV_SP_USB = (1 << 9), /* support usb passthrough */
|
||||
VIR_HOSTDEV_SP_SCSI = (1 << 10), /* support scsi passthrough */
|
||||
+ VIR_HOSTDEV_SP_SECURE = (1 << 11), /* support secure dev passthrough */
|
||||
} virHostdevFlag;
|
||||
|
||||
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index 7ba5575037..892676c020 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -7507,6 +7507,9 @@ qemuProcessPrepareHost(virQEMUDriver *driver,
|
||||
hostdev_flags |= VIR_HOSTDEV_STRICT_ACS_CHECK;
|
||||
if (flags & VIR_QEMU_PROCESS_START_NEW)
|
||||
hostdev_flags |= VIR_HOSTDEV_COLD_BOOT;
|
||||
+ if (vm->def->sec && vm->def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_CVM) {
|
||||
+ hostdev_flags |= VIR_HOSTDEV_SP_SECURE;
|
||||
+ }
|
||||
if (qemuHostdevPrepareDomainDevices(driver, vm->def, hostdev_flags) < 0)
|
||||
return -1;
|
||||
|
||||
diff --git a/src/util/virpci.c b/src/util/virpci.c
|
||||
index baacde4c14..c5ae10956f 100644
|
||||
--- a/src/util/virpci.c
|
||||
+++ b/src/util/virpci.c
|
||||
@@ -94,6 +94,9 @@ struct _virPCIDevice {
|
||||
bool unbind_from_stub;
|
||||
bool remove_slot;
|
||||
bool reprobe;
|
||||
+
|
||||
+ /* used by virtcca CoDA feature*/
|
||||
+ bool secure;
|
||||
};
|
||||
|
||||
struct _virPCIDeviceList {
|
||||
@@ -1377,6 +1380,56 @@ virPCIDeviceDetach(virPCIDevice *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int
|
||||
+virtccaVirPCIDeviceDetach(virPCIDevice *_dev)
|
||||
+{
|
||||
+ int ret = 0;
|
||||
+ virPCIDevice *dev = NULL;
|
||||
+ size_t i, j;
|
||||
+
|
||||
+ /* Given bus number, there are 32 devices and 8 functions */
|
||||
+ for (i = 0; i < 32; i++) {
|
||||
+ for (j = 0; j < 8; j++) {
|
||||
+ virPCIDeviceAddress devAddr = {.domain = _dev->address.domain,
|
||||
+ .bus = _dev->address.bus,
|
||||
+ .slot = i, .function = j};
|
||||
+ g_autofree char *name = virPCIDeviceAddressAsString(&devAddr);
|
||||
+ g_autofree char *path = g_strdup_printf(PCI_SYSFS "devices/%s/config", name);
|
||||
+
|
||||
+ if (!virFileExists(path))
|
||||
+ continue;
|
||||
+
|
||||
+ if (!(dev = virPCIDeviceNew(&devAddr)))
|
||||
+ continue;
|
||||
+
|
||||
+ virPCIDeviceSetStubDriverType(dev, VIR_PCI_STUB_DRIVER_VFIO);
|
||||
+
|
||||
+ if (virPCIDeviceBindToStub(dev) < 0) {
|
||||
+ ret = -1;
|
||||
+ goto cleanup;
|
||||
+ }
|
||||
+ virPCIDeviceFree(dev);
|
||||
+ }
|
||||
+ }
|
||||
+ return ret;
|
||||
+
|
||||
+cleanup:
|
||||
+ virPCIDeviceFree(dev);
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+bool
|
||||
+virtccaVirPCIDeviceGetSecure(virPCIDevice *dev)
|
||||
+{
|
||||
+ return dev->secure;
|
||||
+}
|
||||
+
|
||||
+void
|
||||
+virtccaVirPCIDeviceSetSecure(virPCIDevice *dev, bool secure)
|
||||
+{
|
||||
+ dev->secure = secure;
|
||||
+}
|
||||
+
|
||||
/*
|
||||
* Pre-condition: inactivePCIHostdevs & activePCIHostdevs
|
||||
* are locked
|
||||
diff --git a/src/util/virpci.h b/src/util/virpci.h
|
||||
index faca6cf6f9..7cc754f4af 100644
|
||||
--- a/src/util/virpci.h
|
||||
+++ b/src/util/virpci.h
|
||||
@@ -302,6 +302,9 @@ void virPCIEDeviceInfoFree(virPCIEDeviceInfo *dev);
|
||||
|
||||
void virPCIDeviceAddressFree(virPCIDeviceAddress *address);
|
||||
|
||||
+int virtccaVirPCIDeviceDetach(virPCIDevice *dev);
|
||||
+bool virtccaVirPCIDeviceGetSecure(virPCIDevice *dev);
|
||||
+void virtccaVirPCIDeviceSetSecure(virPCIDevice *dev, bool secure);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIDevice, virPCIDeviceFree);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIDeviceAddress, virPCIDeviceAddressFree);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virPCIEDeviceInfo, virPCIEDeviceInfoFree);
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
66
Bugfix-Enhance-the-capability-to-trace-the-shutdown-.patch
Normal file
66
Bugfix-Enhance-the-capability-to-trace-the-shutdown-.patch
Normal file
@ -0,0 +1,66 @@
|
||||
From f97100914ff9e00c78e41012b695afe864df6c54 Mon Sep 17 00:00:00 2001
|
||||
From: Adttil <2429917001@qq.com>
|
||||
Date: Thu, 12 Dec 2024 19:39:52 +0800
|
||||
Subject: [PATCH] Bugfix: Enhance the capability to trace the shutdown status
|
||||
of large VMS
|
||||
|
||||
Since the passthrough device needs to be unpinned when shutting down,
|
||||
this greatly extends the VM shutdown time. Previously, libvirt's
|
||||
tracking time for the qemu process was only related to the number of
|
||||
devices, which led to the tracking time exceeding the limit in scenarios
|
||||
with large-size passthrough devices. Now fix him by adjusting the delay
|
||||
to vary with memory size.
|
||||
|
||||
Signed-off-by: wwwumr <1127858301@qq.com>
|
||||
Signed-off-by: Adttil <2429917001@qq.com>
|
||||
---
|
||||
src/qemu/qemu_process.c | 17 +++++++++++++++--
|
||||
1 file changed, 15 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index 63ce075812..89dfd23c84 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -103,6 +103,7 @@
|
||||
#include "logging/log_protocol.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_QEMU
|
||||
+#define MEMORY_LATENCY_FACTOR (1 << 20)
|
||||
|
||||
VIR_LOG_INIT("qemu.qemu_process");
|
||||
|
||||
@@ -8610,6 +8611,9 @@ qemuProcessCreatePretendCmdBuild(virDomainObj *vm,
|
||||
int
|
||||
qemuProcessKill(virDomainObj *vm, unsigned int flags)
|
||||
{
|
||||
+ unsigned long long memoryPotentialDelay;
|
||||
+ size_t extraWaitingTime;
|
||||
+
|
||||
VIR_DEBUG("vm=%p name=%s pid=%lld flags=0x%x",
|
||||
vm, vm->def->name,
|
||||
(long long)vm->pid, flags);
|
||||
@@ -8629,10 +8633,19 @@ qemuProcessKill(virDomainObj *vm, unsigned int flags)
|
||||
}
|
||||
|
||||
/* Request an extra delay of two seconds per current nhostdevs
|
||||
- * to be safe against stalls by the kernel freeing up the resources */
|
||||
+ * to be safe against stalls by the kernel freeing up the resources
|
||||
+ * At the same time, Calculate the extra waiting delay required by the
|
||||
+ * VM specifications. The unpin time during device passthrough is
|
||||
+ * related to the momory */
|
||||
+ extraWaitingTime = vm->def->nhostdevs * 2;
|
||||
+ if (vm->def->nhostdevs > 0) {
|
||||
+ memoryPotentialDelay = vm->def->mem.total_memory / MEMORY_LATENCY_FACTOR;
|
||||
+ extraWaitingTime += (size_t)memoryPotentialDelay;
|
||||
+ }
|
||||
+
|
||||
return virProcessKillPainfullyDelay(vm->pid,
|
||||
!!(flags & VIR_QEMU_PROCESS_KILL_FORCE),
|
||||
- vm->def->nhostdevs * 2,
|
||||
+ extraWaitingTime,
|
||||
false);
|
||||
}
|
||||
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
49
Consistent-coding-style-with-opensource.patch
Normal file
49
Consistent-coding-style-with-opensource.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From 10972b18fd6d91a82bc4be81b21a2db72224e8a0 Mon Sep 17 00:00:00 2001
|
||||
From: lihhua <lihuhua@huawei.com>
|
||||
Date: Tue, 3 Sep 2024 10:40:35 +0800
|
||||
Subject: [PATCH] Consistent coding style with opensource.
|
||||
|
||||
---
|
||||
src/qemu/qemu_driver.c | 12 ++++++++++++
|
||||
src/remote/remote_driver.c | 2 +-
|
||||
2 files changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
||||
index 5a5aa28449..df275c403c 100644
|
||||
--- a/src/qemu/qemu_driver.c
|
||||
+++ b/src/qemu/qemu_driver.c
|
||||
@@ -20051,6 +20051,18 @@ qemuConnectTmmInfoListAppend(char **format,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/*
|
||||
+* The format of baseMeminfo should be:
|
||||
+* available: X num nodes (1 2 3 4)
|
||||
+* numa node 0 size: XXXMi
|
||||
+* numa node 0 free: XXXMi
|
||||
+* ...
|
||||
+*
|
||||
+* The format of slabInfo should be:
|
||||
+* numa node 0 td meta_data cnt: xxx
|
||||
+* numa node 0 td meta_data free cnt: xxx
|
||||
+* ...
|
||||
+*/
|
||||
static char *
|
||||
qemuConnectTmmDetailInfoFormat(char *baseMeminfo,
|
||||
char *slabInfo)
|
||||
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
|
||||
index 4b9ad30ed6..82d4c968ea 100644
|
||||
--- a/src/remote/remote_driver.c
|
||||
+++ b/src/remote/remote_driver.c
|
||||
@@ -7876,7 +7876,7 @@ static virHypervisorDriver hypervisor_driver = {
|
||||
.domainStartDirtyRateCalc = remoteDomainStartDirtyRateCalc, /* 7.2.0 */
|
||||
.domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */
|
||||
.domainFDAssociate = remoteDomainFDAssociate, /* 9.0.0 */
|
||||
- .connectGetTmmMemoryInfo = remoteConnectGetTmmMemoryInfo /* 9.0.0 */
|
||||
+ .connectGetTmmMemoryInfo = remoteConnectGetTmmMemoryInfo, /* 9.0.0 */
|
||||
};
|
||||
|
||||
static virNetworkDriver network_driver = {
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
77
Implement-the-method-of-getting-host-info-for-loonga.patch
Normal file
77
Implement-the-method-of-getting-host-info-for-loonga.patch
Normal file
@ -0,0 +1,77 @@
|
||||
From 918a7e7601cf7fc5d8619ff7214e7d43cdee2e08 Mon Sep 17 00:00:00 2001
|
||||
From: Xianglai Li <lixianglai@loongson.cn>
|
||||
Date: Fri, 28 Jul 2023 03:27:41 -0400
|
||||
Subject: [PATCH 3/3] Implement the method of getting host info for loongarch
|
||||
|
||||
Implement method for loongarch to get host info, such as
|
||||
cpu frequency, system info, etc.
|
||||
|
||||
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
|
||||
---
|
||||
src/util/virarch.c | 2 ++
|
||||
src/util/virhostcpu.c | 7 +++++--
|
||||
src/util/virsysinfo.c | 3 ++-
|
||||
3 files changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/util/virarch.c b/src/util/virarch.c
|
||||
index 8545f993ea..a94318da0d 100644
|
||||
--- a/src/util/virarch.c
|
||||
+++ b/src/util/virarch.c
|
||||
@@ -223,6 +223,8 @@ virArch virArchFromHost(void)
|
||||
arch = VIR_ARCH_X86_64;
|
||||
} else if (STREQ(ut.machine, "arm64")) {
|
||||
arch = VIR_ARCH_AARCH64;
|
||||
+ } else if (STREQ(ut.machine, "loongarch64")) {
|
||||
+ arch = VIR_ARCH_LOONGARCH64;
|
||||
} else {
|
||||
/* Otherwise assume the canonical name */
|
||||
if ((arch = virArchFromString(ut.machine)) == VIR_ARCH_NONE) {
|
||||
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
|
||||
index a3781ca870..01de69c0d1 100644
|
||||
--- a/src/util/virhostcpu.c
|
||||
+++ b/src/util/virhostcpu.c
|
||||
@@ -575,6 +575,8 @@ virHostCPUParseFrequency(FILE *cpuinfo,
|
||||
prefix = "clock";
|
||||
else if (ARCH_IS_S390(arch))
|
||||
prefix = "cpu MHz dynamic";
|
||||
+ else if (ARCH_IS_LOONGARCH(arch))
|
||||
+ prefix = "CPU MHz";
|
||||
|
||||
if (!prefix) {
|
||||
VIR_WARN("%s is not supported by the %s parser",
|
||||
@@ -601,7 +603,7 @@ virHostCPUParsePhysAddrSize(FILE *cpuinfo, unsigned int *addrsz)
|
||||
char *str;
|
||||
char *endptr;
|
||||
|
||||
- if (!(str = STRSKIP(line, "address sizes")))
|
||||
+ if (!(str = STRCASESKIP(line, "address sizes")))
|
||||
continue;
|
||||
|
||||
/* Skip the colon. */
|
||||
@@ -1672,7 +1674,8 @@ virHostCPUGetPhysAddrSize(const virArch hostArch,
|
||||
{
|
||||
g_autoptr(FILE) cpuinfo = NULL;
|
||||
|
||||
- if (!(ARCH_IS_X86(hostArch) || ARCH_IS_SH4(hostArch))) {
|
||||
+ if (!(ARCH_IS_X86(hostArch) || ARCH_IS_SH4(hostArch) ||
|
||||
+ ARCH_IS_LOONGARCH(hostArch))) {
|
||||
/* Ensure size is set to 0 as physical address size is unknown */
|
||||
*size = 0;
|
||||
return 0;
|
||||
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
|
||||
index 36a861c53f..4a03fc3246 100644
|
||||
--- a/src/util/virsysinfo.c
|
||||
+++ b/src/util/virsysinfo.c
|
||||
@@ -1248,7 +1248,8 @@ virSysinfoRead(void)
|
||||
#elif !defined(WIN32) && \
|
||||
(defined(__x86_64__) || \
|
||||
defined(__i386__) || \
|
||||
- defined(__amd64__))
|
||||
+ defined(__amd64__) || \
|
||||
+ defined(__loongarch__))
|
||||
return virSysinfoReadDMI();
|
||||
#else /* WIN32 || not supported arch */
|
||||
/*
|
||||
--
|
||||
2.39.1
|
||||
|
||||
39
Revert-node_device-fix-leak-of-DIR.patch
Normal file
39
Revert-node_device-fix-leak-of-DIR.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From 27cb1a66b291d3493c12a8ebc90c28f7b1fe67b0 Mon Sep 17 00:00:00 2001
|
||||
From: Adttil <2429917001@qq.com>
|
||||
Date: Sat, 23 Nov 2024 18:15:26 +0800
|
||||
Subject: [PATCH 2/2] Revert "node_device: fix leak of DIR*"
|
||||
|
||||
This reverts commit 3cd86072fd6725178b669174eb99ab24a0bcee6c.
|
||||
Updating the dir variable in the udevGetVDPACharDev function
|
||||
to a smart pointer fixed a bug where dir was not freeing,
|
||||
but a previous incorrect commit resulted in a double free
|
||||
of the pointer, and the patch is now rolled back
|
||||
---
|
||||
src/node_device/node_device_udev.c | 4 ----
|
||||
1 file changed, 4 deletions(-)
|
||||
|
||||
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
|
||||
index aa2781db34..6c5b788279 100644
|
||||
--- a/src/node_device/node_device_udev.c
|
||||
+++ b/src/node_device/node_device_udev.c
|
||||
@@ -1198,7 +1198,6 @@ udevGetVDPACharDev(const char *sysfs_path,
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("vDPA chardev path '%1$s' does not exist"),
|
||||
chardev);
|
||||
- virDirClose(dir);
|
||||
return -1;
|
||||
}
|
||||
VIR_DEBUG("vDPA chardev is at '%s'", chardev);
|
||||
@@ -1207,9 +1206,6 @@ udevGetVDPACharDev(const char *sysfs_path,
|
||||
break;
|
||||
}
|
||||
}
|
||||
-
|
||||
- virDirClose(dir);
|
||||
-
|
||||
if (direrr < 0)
|
||||
return -1;
|
||||
|
||||
--
|
||||
2.43.0
|
||||
|
||||
208
Support-for-loongarch64-in-the-QEMU-driver.patch
Normal file
208
Support-for-loongarch64-in-the-QEMU-driver.patch
Normal file
@ -0,0 +1,208 @@
|
||||
From aeaef8019c4c1f16af1ebcb60c73c06f4f691261 Mon Sep 17 00:00:00 2001
|
||||
From: xianglai li <lixianglai@loongson.cn>
|
||||
Date: Fri, 28 Jul 2023 03:18:44 -0400
|
||||
Subject: [PATCH 2/3] Support for loongarch64 in the QEMU driver
|
||||
|
||||
Implement support for loongarch64 in the QEMU driver.
|
||||
|
||||
Signed-off-by: "Xianglai Li" <lixianglai@loongson.cn>
|
||||
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
|
||||
---
|
||||
src/qemu/qemu_capabilities.c | 10 +++++----
|
||||
src/qemu/qemu_command.c | 3 ++-
|
||||
src/qemu/qemu_domain.c | 42 ++++++++++++++++++++++++++++++++----
|
||||
src/qemu/qemu_domain.h | 1 +
|
||||
src/qemu/qemu_validate.c | 1 +
|
||||
5 files changed, 48 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
||||
index 509e751274..79414becfd 100644
|
||||
--- a/src/qemu/qemu_capabilities.c
|
||||
+++ b/src/qemu/qemu_capabilities.c
|
||||
@@ -1139,7 +1139,8 @@ virQEMUCapsInitGuestFromBinary(virCaps *caps,
|
||||
NULL, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
- if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64))
|
||||
+ if (ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64 ||
|
||||
+ ARCH_IS_LOONGARCH(guestarch))
|
||||
virCapabilitiesAddGuestFeatureWithToggle(guest, VIR_CAPS_GUEST_FEATURE_TYPE_ACPI,
|
||||
true, true);
|
||||
|
||||
@@ -2075,9 +2076,10 @@ bool virQEMUCapsHasPCIMultiBus(const virDomainDef *def)
|
||||
if (ARCH_IS_S390(def->os.arch))
|
||||
return true;
|
||||
|
||||
- /* If the virt machine, both on ARM and RISC-V, supports PCI,
|
||||
+ /* If the virt machine, both on ARM and RISC-V and LOONGARCH64, supports PCI,
|
||||
* then it also supports multibus */
|
||||
if (qemuDomainIsARMVirt(def) ||
|
||||
+ qemuDomainIsLoongArchVirt(def) ||
|
||||
qemuDomainIsRISCVVirt(def)) {
|
||||
return true;
|
||||
}
|
||||
@@ -2667,7 +2669,7 @@ static const char *preferredMachines[] =
|
||||
NULL, /* VIR_ARCH_ITANIUM (doesn't exist in QEMU any more) */
|
||||
"lm32-evr", /* VIR_ARCH_LM32 */
|
||||
|
||||
- NULL, /* VIR_ARCH_LOONGARCH64 */
|
||||
+ "virt", /* VIR_ARCH_LOONGARCH64 */
|
||||
"mcf5208evb", /* VIR_ARCH_M68K */
|
||||
"petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZE */
|
||||
"petalogix-s3adsp1800", /* VIR_ARCH_MICROBLAZEEL */
|
||||
@@ -3743,7 +3745,7 @@ virQEMUCapsInitCPUModel(virQEMUCaps *qemuCaps,
|
||||
} else if (ARCH_IS_X86(qemuCaps->arch)) {
|
||||
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, modelInfo,
|
||||
cpu, migratable);
|
||||
- } else if (ARCH_IS_ARM(qemuCaps->arch)) {
|
||||
+ } else if (ARCH_IS_ARM(qemuCaps->arch) || ARCH_IS_LOONGARCH(qemuCaps->arch)) {
|
||||
ret = 2;
|
||||
}
|
||||
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index 6403d5692e..609eb6772e 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -9209,7 +9209,8 @@ qemuChrIsPlatformDevice(const virDomainDef *def,
|
||||
}
|
||||
}
|
||||
|
||||
- if (ARCH_IS_RISCV(def->os.arch)) {
|
||||
+ if (ARCH_IS_RISCV(def->os.arch) ||
|
||||
+ ARCH_IS_LOONGARCH(def->os.arch)) {
|
||||
|
||||
/* 16550a (used by riscv/virt guests) is a platform device */
|
||||
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
|
||||
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
||||
index 8374780507..020cfc8bff 100644
|
||||
--- a/src/qemu/qemu_domain.c
|
||||
+++ b/src/qemu/qemu_domain.c
|
||||
@@ -4229,11 +4229,14 @@ qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
|
||||
addPCIRoot = true;
|
||||
break;
|
||||
|
||||
+ case VIR_ARCH_LOONGARCH64:
|
||||
+ addPCIeRoot = true;
|
||||
+ break;
|
||||
+
|
||||
case VIR_ARCH_ARMV7B:
|
||||
case VIR_ARCH_CRIS:
|
||||
case VIR_ARCH_ITANIUM:
|
||||
case VIR_ARCH_LM32:
|
||||
- case VIR_ARCH_LOONGARCH64:
|
||||
case VIR_ARCH_M68K:
|
||||
case VIR_ARCH_MICROBLAZE:
|
||||
case VIR_ARCH_MICROBLAZEEL:
|
||||
@@ -5400,7 +5403,8 @@ static int
|
||||
qemuDomainDefaultNetModel(const virDomainDef *def,
|
||||
virQEMUCaps *qemuCaps)
|
||||
{
|
||||
- if (ARCH_IS_S390(def->os.arch))
|
||||
+ if (ARCH_IS_S390(def->os.arch) ||
|
||||
+ qemuDomainIsLoongArchVirt(def))
|
||||
return VIR_DOMAIN_NET_MODEL_VIRTIO;
|
||||
|
||||
if (def->os.arch == VIR_ARCH_ARMV6L ||
|
||||
@@ -5639,6 +5643,9 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
|
||||
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
|
||||
else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI))
|
||||
cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI;
|
||||
+ } else if (ARCH_IS_LOONGARCH(def->os.arch)) {
|
||||
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI))
|
||||
+ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI;
|
||||
}
|
||||
}
|
||||
/* forbid usb model 'qusb1' and 'qusb2' in this kind of hyperviosr */
|
||||
@@ -5738,7 +5745,9 @@ qemuDomainChrDefPostParse(virDomainChrDef *chr,
|
||||
chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA;
|
||||
} else if (qemuDomainIsPSeries(def)) {
|
||||
chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SPAPR_VIO;
|
||||
- } else if (qemuDomainIsARMVirt(def) || qemuDomainIsRISCVVirt(def)) {
|
||||
+ } else if (qemuDomainIsARMVirt(def) ||
|
||||
+ qemuDomainIsLoongArchVirt(def) ||
|
||||
+ qemuDomainIsRISCVVirt(def)) {
|
||||
chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM;
|
||||
} else if (ARCH_IS_S390(def->os.arch)) {
|
||||
chr->targetType = VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SCLP;
|
||||
@@ -5764,7 +5773,8 @@ qemuDomainChrDefPostParse(virDomainChrDef *chr,
|
||||
case VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_SYSTEM:
|
||||
if (qemuDomainIsARMVirt(def)) {
|
||||
chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_PL011;
|
||||
- } else if (qemuDomainIsRISCVVirt(def)) {
|
||||
+ } else if (qemuDomainIsLoongArchVirt(def) ||
|
||||
+ qemuDomainIsRISCVVirt(def)) {
|
||||
chr->targetModel = VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A;
|
||||
}
|
||||
break;
|
||||
@@ -5936,6 +5946,7 @@ qemuDomainDefaultVideoDevice(const virDomainDef *def,
|
||||
if (ARCH_IS_PPC64(def->os.arch))
|
||||
return VIR_DOMAIN_VIDEO_TYPE_VGA;
|
||||
if (qemuDomainIsARMVirt(def) ||
|
||||
+ qemuDomainIsLoongArchVirt(def) ||
|
||||
qemuDomainIsRISCVVirt(def) ||
|
||||
ARCH_IS_S390(def->os.arch)) {
|
||||
return VIR_DOMAIN_VIDEO_TYPE_VIRTIO;
|
||||
@@ -8930,6 +8941,22 @@ qemuDomainMachineIsPSeries(const char *machine,
|
||||
}
|
||||
|
||||
|
||||
+static bool
|
||||
+qemuDomainMachineIsLoongArchVirt(const char *machine,
|
||||
+ const virArch arch)
|
||||
+{
|
||||
+ if (!ARCH_IS_LOONGARCH(arch))
|
||||
+ return false;
|
||||
+
|
||||
+ if (STREQ(machine, "virt") ||
|
||||
+ STRPREFIX(machine, "virt-")) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static bool
|
||||
qemuDomainMachineIsMipsMalta(const char *machine,
|
||||
const virArch arch)
|
||||
@@ -9023,6 +9050,13 @@ qemuDomainIsMipsMalta(const virDomainDef *def)
|
||||
}
|
||||
|
||||
|
||||
+bool
|
||||
+qemuDomainIsLoongArchVirt(const virDomainDef *def)
|
||||
+{
|
||||
+ return qemuDomainMachineIsLoongArchVirt(def->os.machine, def->os.arch);
|
||||
+}
|
||||
+
|
||||
+
|
||||
bool
|
||||
qemuDomainHasPCIRoot(const virDomainDef *def)
|
||||
{
|
||||
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
|
||||
index 7074023229..c90a361e8a 100644
|
||||
--- a/src/qemu/qemu_domain.h
|
||||
+++ b/src/qemu/qemu_domain.h
|
||||
@@ -829,6 +829,7 @@ bool qemuDomainIsQ35(const virDomainDef *def);
|
||||
bool qemuDomainIsI440FX(const virDomainDef *def);
|
||||
bool qemuDomainIsS390CCW(const virDomainDef *def);
|
||||
bool qemuDomainIsARMVirt(const virDomainDef *def);
|
||||
+bool qemuDomainIsLoongArchVirt(const virDomainDef *def);
|
||||
bool qemuDomainIsRISCVVirt(const virDomainDef *def);
|
||||
bool qemuDomainIsPSeries(const virDomainDef *def);
|
||||
bool qemuDomainIsMipsMalta(const virDomainDef *def);
|
||||
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
|
||||
index 18c5b60a35..a51cb6017d 100644
|
||||
--- a/src/qemu/qemu_validate.c
|
||||
+++ b/src/qemu/qemu_validate.c
|
||||
@@ -2064,6 +2064,7 @@ qemuValidateDomainChrDef(const virDomainChrDef *dev,
|
||||
isCompatible = false;
|
||||
}
|
||||
if (dev->targetModel == VIR_DOMAIN_CHR_SERIAL_TARGET_MODEL_16550A &&
|
||||
+ !qemuDomainIsLoongArchVirt(def) &&
|
||||
!qemuDomainIsRISCVVirt(def)) {
|
||||
isCompatible = false;
|
||||
}
|
||||
--
|
||||
2.39.1
|
||||
|
||||
91
build-Make-daemons-depend-on-generated-_protocol.-ch.patch
Normal file
91
build-Make-daemons-depend-on-generated-_protocol.-ch.patch
Normal file
@ -0,0 +1,91 @@
|
||||
From 2703f133869014a99cdfb9107e8315f4ea419d48 Mon Sep 17 00:00:00 2001
|
||||
From: lihhua <lihuhua@huawei.com>
|
||||
Date: Sat, 24 Aug 2024 11:11:42 +0800
|
||||
Subject: [PATCH] build: Make daemons depend on generated *_protocol.[ch]
|
||||
|
||||
---
|
||||
po/meson.build | 1 +
|
||||
src/meson.build | 6 +++++-
|
||||
src/remote/meson.build | 15 +++++++++++----
|
||||
3 files changed, 17 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/po/meson.build b/po/meson.build
|
||||
index a20877ad34..592b254447 100644
|
||||
--- a/po/meson.build
|
||||
+++ b/po/meson.build
|
||||
@@ -20,6 +20,7 @@ potfiles_dep = [
|
||||
access_gen_sources,
|
||||
admin_client_generated,
|
||||
admin_driver_generated,
|
||||
+ remote_protocol_generated,
|
||||
remote_driver_generated,
|
||||
remote_daemon_generated,
|
||||
]
|
||||
diff --git a/src/meson.build b/src/meson.build
|
||||
index 6538c43628..f52d2d5994 100644
|
||||
--- a/src/meson.build
|
||||
+++ b/src/meson.build
|
||||
@@ -616,7 +616,11 @@ foreach daemon : virt_daemons
|
||||
bin = executable(
|
||||
daemon['name'],
|
||||
[
|
||||
- daemon.get('sources', [ remote_daemon_sources, remote_daemon_generated ]),
|
||||
+ daemon.get('sources', [
|
||||
+ remote_protocol_generated,
|
||||
+ remote_daemon_sources,
|
||||
+ remote_daemon_generated
|
||||
+ ]),
|
||||
dtrace_gen_objects,
|
||||
],
|
||||
c_args: [
|
||||
diff --git a/src/remote/meson.build b/src/remote/meson.build
|
||||
index 16b903fcaf..43bf2d0083 100644
|
||||
--- a/src/remote/meson.build
|
||||
+++ b/src/remote/meson.build
|
||||
@@ -7,8 +7,6 @@ remote_driver_generated = []
|
||||
|
||||
foreach name : [ 'remote', 'qemu', 'lxc' ]
|
||||
client_bodies_h = '@0@_client_bodies.h'.format(name)
|
||||
- protocol_c = '@0@_protocol.c'.format(name)
|
||||
- protocol_h = '@0@_protocol.h'.format(name)
|
||||
protocol_x = '@0@_protocol.x'.format(name)
|
||||
|
||||
remote_driver_generated += custom_target(
|
||||
@@ -20,8 +18,16 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
|
||||
],
|
||||
capture: true,
|
||||
)
|
||||
+endforeach
|
||||
|
||||
- remote_driver_generated += custom_target(
|
||||
+remote_protocol_generated = []
|
||||
+
|
||||
+foreach name : [ 'remote', 'qemu', 'lxc' ]
|
||||
+ protocol_c = '@0@_protocol.c'.format(name)
|
||||
+ protocol_h = '@0@_protocol.h'.format(name)
|
||||
+ protocol_x = '@0@_protocol.x'.format(name)
|
||||
+
|
||||
+ remote_protocol_generated += custom_target(
|
||||
protocol_h,
|
||||
input: protocol_x,
|
||||
output: protocol_h,
|
||||
@@ -32,7 +38,7 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
|
||||
],
|
||||
)
|
||||
|
||||
- remote_driver_generated += custom_target(
|
||||
+ remote_protocol_generated += custom_target(
|
||||
protocol_c,
|
||||
input: protocol_x,
|
||||
output: protocol_c,
|
||||
@@ -143,6 +149,7 @@ if conf.has('WITH_REMOTE')
|
||||
remote_driver_lib = static_library(
|
||||
'virt_remote_driver',
|
||||
[
|
||||
+ remote_protocol_generated,
|
||||
remote_driver_sources,
|
||||
remote_driver_generated,
|
||||
],
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
89
conf-qemu-add-libvirt-support-reuse-id-for-hygon-CSV.patch
Normal file
89
conf-qemu-add-libvirt-support-reuse-id-for-hygon-CSV.patch
Normal file
@ -0,0 +1,89 @@
|
||||
From cbc574f26c7fa7d107a2827ea335a13c4b253726 Mon Sep 17 00:00:00 2001
|
||||
From: panpingsheng <panpingsheng@hygon.cn>
|
||||
Date: Fri, 8 Sep 2023 15:04:44 +0800
|
||||
Subject: [PATCH] conf: qemu: add libvirt support reuse id for hygon CSV
|
||||
|
||||
csv xml format:
|
||||
<launchSecurity type='sev'>
|
||||
<policy>0x0081</policy>
|
||||
<cbitpos>47</cbitpos>
|
||||
<reducedPhysBits>5</reducedPhysBits>
|
||||
<userid>usertest</userid>
|
||||
</launchSecurity>
|
||||
|
||||
Signed-off-by: panpingsheng <panpingsheng@hygon.cn>
|
||||
Signed-off-by: Xin Jiang <jiangxin@hygon.cn>
|
||||
Signed-off-by: hanliyang <hanliyang@hygon.cn>
|
||||
---
|
||||
src/conf/domain_conf.c | 5 +++++
|
||||
src/conf/domain_conf.h | 1 +
|
||||
src/qemu/qemu_command.c | 4 ++++
|
||||
3 files changed, 10 insertions(+)
|
||||
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index db49355788..2be4706b03 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -3828,6 +3828,7 @@ virDomainSecDefFree(virDomainSecDef *def)
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_SEV:
|
||||
g_free(def->data.sev.dh_cert);
|
||||
g_free(def->data.sev.session);
|
||||
+ g_free(def->data.sev.user_id);
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
@@ -13547,6 +13548,7 @@ virDomainSEVDefParseXML(virDomainSEVDef *def,
|
||||
|
||||
def->dh_cert = virXPathString("string(./dhCert)", ctxt);
|
||||
def->session = virXPathString("string(./session)", ctxt);
|
||||
+ def->user_id = virXPathString("string(./userid)", ctxt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -26613,6 +26615,9 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSecDef *sec)
|
||||
if (sev->session)
|
||||
virBufferEscapeString(&childBuf, "<session>%s</session>\n", sev->session);
|
||||
|
||||
+ if (sev->user_id)
|
||||
+ virBufferEscapeString(&childBuf, "<userid>%s</userid>\n", sev->user_id);
|
||||
+
|
||||
break;
|
||||
}
|
||||
|
||||
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
||||
index a687895726..c06ac9552c 100644
|
||||
--- a/src/conf/domain_conf.h
|
||||
+++ b/src/conf/domain_conf.h
|
||||
@@ -2873,6 +2873,7 @@ struct _virDomainSEVDef {
|
||||
bool haveReducedPhysBits;
|
||||
unsigned int reduced_phys_bits;
|
||||
virTristateBool kernel_hashes;
|
||||
+ char *user_id;
|
||||
};
|
||||
|
||||
struct _virDomainSecDef {
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index 6e16e65d54..d4a0d73aae 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -9718,6 +9718,9 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||||
VIR_DEBUG("policy=0x%x cbitpos=%d reduced_phys_bits=%d",
|
||||
sev->policy, sev->cbitpos, sev->reduced_phys_bits);
|
||||
|
||||
+ if (sev->user_id)
|
||||
+ VIR_DEBUG("user_id=%s", sev->user_id);
|
||||
+
|
||||
if (sev->dh_cert)
|
||||
dhpath = g_strdup_printf("%s/dh_cert.base64", priv->libDir);
|
||||
|
||||
@@ -9728,6 +9731,7 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||||
"u:cbitpos", sev->cbitpos,
|
||||
"u:reduced-phys-bits", sev->reduced_phys_bits,
|
||||
"u:policy", sev->policy,
|
||||
+ "S:user-id", sev->user_id,
|
||||
"S:dh-cert-file", dhpath,
|
||||
"S:session-file", sessionpath,
|
||||
"T:kernel-hashes", sev->kernel_hashes,
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
129
conf-qemu-support-provide-inject-secret-for-Hygon-CS.patch
Normal file
129
conf-qemu-support-provide-inject-secret-for-Hygon-CS.patch
Normal file
@ -0,0 +1,129 @@
|
||||
From 66ab1f1ce7ae35f757580062ef6653ae64c01522 Mon Sep 17 00:00:00 2001
|
||||
From: hanliyang <hanliyang@hygon.cn>
|
||||
Date: Wed, 13 Nov 2024 16:12:57 +0800
|
||||
Subject: [PATCH] conf: qemu: support provide inject secret for Hygon CSV
|
||||
|
||||
csv xml format:
|
||||
<launchSecurity type='sev'>
|
||||
<policy>0x0001</policy>
|
||||
<cbitpos>47</cbitpos>
|
||||
<reducePhysBits>5</reducedPhysBits>
|
||||
<dhCert>U2FsdGVkX1+rW6B/JbYqNA==</dhCert>
|
||||
<session>5aeG4mH2E/OqN1a3uT8hfg==</session>
|
||||
<secretHeader>gW3E30rG/I3L1nD/YfG+DA==</secretHeader>
|
||||
<secret>zP1oY9W7ZcPFtL0QeN11vQ==</secret>
|
||||
</launchSecurity>
|
||||
|
||||
Signed-off-by: hanliyang <hanliyang@hygon.cn>
|
||||
---
|
||||
src/conf/domain_conf.c | 8 ++++++++
|
||||
src/conf/domain_conf.h | 2 ++
|
||||
src/qemu/qemu_command.c | 10 ++++++++++
|
||||
src/qemu/qemu_process.c | 10 ++++++++++
|
||||
4 files changed, 30 insertions(+)
|
||||
|
||||
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
||||
index 2be4706b03..b3475757c3 100644
|
||||
--- a/src/conf/domain_conf.c
|
||||
+++ b/src/conf/domain_conf.c
|
||||
@@ -3829,6 +3829,8 @@ virDomainSecDefFree(virDomainSecDef *def)
|
||||
g_free(def->data.sev.dh_cert);
|
||||
g_free(def->data.sev.session);
|
||||
g_free(def->data.sev.user_id);
|
||||
+ g_free(def->data.sev.secret_header);
|
||||
+ g_free(def->data.sev.secret);
|
||||
break;
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_PV:
|
||||
case VIR_DOMAIN_LAUNCH_SECURITY_CVM:
|
||||
@@ -13549,6 +13551,8 @@ virDomainSEVDefParseXML(virDomainSEVDef *def,
|
||||
def->dh_cert = virXPathString("string(./dhCert)", ctxt);
|
||||
def->session = virXPathString("string(./session)", ctxt);
|
||||
def->user_id = virXPathString("string(./userid)", ctxt);
|
||||
+ def->secret_header = virXPathString("string(./secretHeader)", ctxt);
|
||||
+ def->secret = virXPathString("string(./secret)", ctxt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -26617,6 +26621,10 @@ virDomainSecDefFormat(virBuffer *buf, virDomainSecDef *sec)
|
||||
|
||||
if (sev->user_id)
|
||||
virBufferEscapeString(&childBuf, "<userid>%s</userid>\n", sev->user_id);
|
||||
+ if (sev->secret_header)
|
||||
+ virBufferEscapeString(&childBuf, "<secretHeader>%s</secretHeader>\n", sev->secret_header);
|
||||
+ if (sev->secret)
|
||||
+ virBufferEscapeString(&childBuf, "<secret>%s</secret>\n", sev->secret);
|
||||
|
||||
break;
|
||||
}
|
||||
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
||||
index c06ac9552c..f0e5535013 100644
|
||||
--- a/src/conf/domain_conf.h
|
||||
+++ b/src/conf/domain_conf.h
|
||||
@@ -2874,6 +2874,8 @@ struct _virDomainSEVDef {
|
||||
unsigned int reduced_phys_bits;
|
||||
virTristateBool kernel_hashes;
|
||||
char *user_id;
|
||||
+ char *secret_header;
|
||||
+ char *secret;
|
||||
};
|
||||
|
||||
struct _virDomainSecDef {
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index d4a0d73aae..0c47f019f2 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -9714,6 +9714,8 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
g_autofree char *dhpath = NULL;
|
||||
g_autofree char *sessionpath = NULL;
|
||||
+ g_autofree char *secretheaderpath = NULL;
|
||||
+ g_autofree char *secretpath = NULL;
|
||||
|
||||
VIR_DEBUG("policy=0x%x cbitpos=%d reduced_phys_bits=%d",
|
||||
sev->policy, sev->cbitpos, sev->reduced_phys_bits);
|
||||
@@ -9727,6 +9729,12 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||||
if (sev->session)
|
||||
sessionpath = g_strdup_printf("%s/session.base64", priv->libDir);
|
||||
|
||||
+ if (sev->secret_header)
|
||||
+ secretheaderpath = g_strdup_printf("%s/secret_header.base64", priv->libDir);
|
||||
+
|
||||
+ if (sev->secret)
|
||||
+ secretpath = g_strdup_printf("%s/secret.base64", priv->libDir);
|
||||
+
|
||||
if (qemuMonitorCreateObjectProps(&props, "sev-guest", "lsec0",
|
||||
"u:cbitpos", sev->cbitpos,
|
||||
"u:reduced-phys-bits", sev->reduced_phys_bits,
|
||||
@@ -9735,6 +9743,8 @@ qemuBuildSEVCommandLine(virDomainObj *vm, virCommand *cmd,
|
||||
"S:dh-cert-file", dhpath,
|
||||
"S:session-file", sessionpath,
|
||||
"T:kernel-hashes", sev->kernel_hashes,
|
||||
+ "S:secret-header-file", secretheaderpath,
|
||||
+ "S:secret-file", secretpath,
|
||||
NULL) < 0)
|
||||
return -1;
|
||||
|
||||
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
|
||||
index 892676c020..63ce075812 100644
|
||||
--- a/src/qemu/qemu_process.c
|
||||
+++ b/src/qemu/qemu_process.c
|
||||
@@ -7029,6 +7029,16 @@ qemuProcessPrepareSEVGuestInput(virDomainObj *vm)
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ if (sev->secret_header) {
|
||||
+ if (qemuProcessSEVCreateFile(vm, "secret_header", sev->secret_header) < 0)
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (sev->secret) {
|
||||
+ if (qemuProcessSEVCreateFile(vm, "secret", sev->secret) < 0)
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
|
||||
--
|
||||
2.41.0.windows.1
|
||||
|
||||
54
libvirt.spec
54
libvirt.spec
@ -6,20 +6,20 @@
|
||||
%define min_rhel 8
|
||||
%define min_fedora 37
|
||||
|
||||
%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x riscv64
|
||||
%define arches_qemu_kvm %{ix86} x86_64 %{power64} %{arm} aarch64 s390x riscv64 loongarch64
|
||||
%if 0%{?rhel}
|
||||
%if 0%{?rhel} > 8
|
||||
%define arches_qemu_kvm x86_64 aarch64 s390x
|
||||
%define arches_qemu_kvm x86_64 aarch64 s390x loongarch64
|
||||
%else
|
||||
%define arches_qemu_kvm x86_64 %{power64} aarch64 s390x
|
||||
%define arches_qemu_kvm x86_64 %{power64} aarch64 s390x loongarch64
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64
|
||||
%define arches_64bit x86_64 %{power64} aarch64 s390x riscv64 loongarch64
|
||||
%define arches_x86 %{ix86} x86_64
|
||||
|
||||
%define arches_systemtap_64bit %{arches_64bit}
|
||||
%define arches_dmidecode %{arches_x86}
|
||||
%define arches_dmidecode %{arches_x86 loongarch64}
|
||||
%define arches_xen %{arches_x86} aarch64
|
||||
%if 0%{?fedora}
|
||||
%define arches_xen x86_64 aarch64
|
||||
@ -27,8 +27,8 @@
|
||||
%define arches_vbox %{arches_x86}
|
||||
%define arches_ceph %{arches_64bit}
|
||||
%define arches_zfs %{arches_x86} %{power64} %{arm}
|
||||
%define arches_numactl %{arches_x86} %{power64} aarch64 s390x
|
||||
%define arches_numad %{arches_x86} %{power64} aarch64
|
||||
%define arches_numactl %{arches_x86} %{power64} aarch64 s390x loongarch64
|
||||
%define arches_numad %{arches_x86} %{power64} aarch64 loongarch64
|
||||
|
||||
# The hypervisor drivers that run in libvirtd
|
||||
%define with_qemu 0%{!?_without_qemu:1}
|
||||
@ -262,7 +262,7 @@
|
||||
Summary: Library providing a simple virtualization API
|
||||
Name: libvirt
|
||||
Version: 9.10.0
|
||||
Release: 9
|
||||
Release: 14
|
||||
License: LGPLv2+
|
||||
URL: https://libvirt.org/
|
||||
|
||||
@ -315,6 +315,20 @@ Patch0041: remote-check-for-negative-array-lengths-before-alloc.patch
|
||||
Patch0042: hotpatch-if-hotpatch_path-not-in-qemu.conf-the-hotpa.patch
|
||||
Patch0043: remote_driver-Restore-special-behavior-of-remoteDoma.patch
|
||||
Patch0044: remote_driver-fix-the-UAF-causing-UnicodeDecodeError.patch
|
||||
Patch0045: Add-loongarch-cpu-support.patch
|
||||
Patch0046: Support-for-loongarch64-in-the-QEMU-driver.patch
|
||||
Patch0047: Implement-the-method-of-getting-host-info-for-loonga.patch
|
||||
Patch0048: rpc-ensure-temporary-GSource-is-removed-from-client-.patch
|
||||
Patch0049: vdpa-vdpa-device-hotplug-unplug-bugfix-and-support-v.patch
|
||||
Patch0050: Revert-node_device-fix-leak-of-DIR.patch
|
||||
Patch0051: Add-cvm-parameter-into-the-type-of-LaunchSecurity-wh.patch
|
||||
Patch0052: Add-the-get-tmm-memory-info-API-into-libvirt-host.-A.patch
|
||||
Patch0053: build-Make-daemons-depend-on-generated-_protocol.-ch.patch
|
||||
Patch0054: Consistent-coding-style-with-opensource.patch
|
||||
Patch0055: Automatically-unbind-all-devices-driver-under-same-r.patch
|
||||
Patch0056: conf-qemu-add-libvirt-support-reuse-id-for-hygon-CSV.patch
|
||||
Patch0057: conf-qemu-support-provide-inject-secret-for-Hygon-CS.patch
|
||||
Patch0058: Bugfix-Enhance-the-capability-to-trace-the-shutdown-.patch
|
||||
|
||||
Requires: libvirt-daemon = %{version}-%{release}
|
||||
Requires: libvirt-daemon-config-network = %{version}-%{release}
|
||||
@ -2606,7 +2620,29 @@ exit 0
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* SAT May 18 2024 QingXiu <xiuqing1@huawei.com> 9.10.0-9
|
||||
* Thu Dec 12 2024 JiaboFeng <fengjiabo1@huawei.com> - 9.10.0-14
|
||||
- Bugfix: Enhance the capability to trace the shutdown status of large VMS
|
||||
- conf: qemu: support provide inject secret for Hygon CSV
|
||||
- conf: qemu: add libvirt support reuse id for hygon CSV
|
||||
- Automatically unbind all devices' driver under same root port and bind to vfio-pci in the context of CVM.
|
||||
- Consistent coding style with opensource.
|
||||
- build: Make daemons depend on generated *_protocol.[ch]
|
||||
- Add the get tmm memory info API into libvirt-host. Also should add the RPC calls into libvirtd for API calling.
|
||||
- Add cvm parameter into the type of LaunchSecurity which is a optional filed for libvirt xml
|
||||
|
||||
* Thu Nov 28 2024 Adttil <2429917001@qq.com> 9.10.0-13
|
||||
- vdpa: support vdpa device boot index and fix hotplug/unplug bug
|
||||
|
||||
* Fri May 31 2024 LiXiangLai <lixianglai@loongson.cn> 9.10.0-12
|
||||
- spec: add numa support for loongarch64
|
||||
|
||||
* Fri May 24 2024 jiangjiacheng <jiangjiacheng@huawei.com> - 9.10.0-11
|
||||
- rpc: ensure temporary GSource is removed from client event loop
|
||||
|
||||
* Mon May 20 2024 LiXiangLai <lixianglai@loongson.cn> 9.10.0-10
|
||||
- spec: Add loongarch support for libvirt
|
||||
|
||||
* Sat May 18 2024 QingXiu <xiuqing1@huawei.com> 9.10.0-9
|
||||
- spec: remote_driver: fix the UAF causing UnicodeDecodeError
|
||||
|
||||
* Mon May 06 2024 laokz <zhangkai@iscas.ac.cn> - 9.10.0-8
|
||||
|
||||
99
rpc-ensure-temporary-GSource-is-removed-from-client-.patch
Normal file
99
rpc-ensure-temporary-GSource-is-removed-from-client-.patch
Normal file
@ -0,0 +1,99 @@
|
||||
From dcd602b968e89cf02eb6227358f0106e7b127b03 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Tue, 30 Apr 2024 11:51:15 +0100
|
||||
Subject: [PATCH] rpc: ensure temporary GSource is removed from client event
|
||||
loop
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Users are seeing periodic segfaults from libvirt client apps,
|
||||
especially thread heavy ones like virt-manager. A typical
|
||||
stack trace would end up in the virNetClientIOEventFD method,
|
||||
with illegal access to stale stack data. eg
|
||||
|
||||
==238721==ERROR: AddressSanitizer: stack-use-after-return on address 0x75cd18709788 at pc 0x75cd3111f907 bp 0x75cd181ff550 sp 0x75cd181ff548
|
||||
WRITE of size 4 at 0x75cd18709788 thread T11
|
||||
#0 0x75cd3111f906 in virNetClientIOEventFD /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:1634:15
|
||||
#1 0x75cd3210d198 (/usr/lib/libglib-2.0.so.0+0x5a198) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
|
||||
#2 0x75cd3216c3be (/usr/lib/libglib-2.0.so.0+0xb93be) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
|
||||
#3 0x75cd3210ddc6 in g_main_loop_run (/usr/lib/libglib-2.0.so.0+0x5adc6) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
|
||||
#4 0x75cd3111a47c in virNetClientIOEventLoop /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:1722:9
|
||||
#5 0x75cd3111a47c in virNetClientIO /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2002:10
|
||||
#6 0x75cd3111a47c in virNetClientSendInternal /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2170:11
|
||||
#7 0x75cd311198a8 in virNetClientSendWithReply /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2198:11
|
||||
#8 0x75cd31111653 in virNetClientProgramCall /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclientprogram.c:318:9
|
||||
#9 0x75cd31241c8f in callFull /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/remote/remote_driver.c:6054:10
|
||||
#10 0x75cd31241c8f in call /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/remote/remote_driver.c:6076:12
|
||||
#11 0x75cd31241c8f in remoteNetworkGetXMLDesc /usr/src/debug/libvirt/libvirt-10.2.0/build/src/remote/remote_client_bodies.h:5959:9
|
||||
#12 0x75cd31410ff7 in virNetworkGetXMLDesc /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/libvirt-network.c:952:15
|
||||
|
||||
The root cause is a bad assumption in the virNetClientIOEventLoop
|
||||
method. This method is run by whichever thread currently owns the
|
||||
buck, and is responsible for handling I/O. Inside a for(;;) loop,
|
||||
this method creates a temporary GSource, adds it to the event loop
|
||||
and runs g_main_loop_run(). When I/O is ready, the GSource callback
|
||||
(virNetClientIOEventFD) will fire and call g_main_loop_quit(), and
|
||||
return G_SOURCE_REMOVE which results in the temporary GSource being
|
||||
destroyed. A g_autoptr() will then remove the last reference.
|
||||
|
||||
What was overlooked, is that a second thread can come along and
|
||||
while it can't enter virNetClientIOEventLoop, it will register an
|
||||
idle source that uses virNetClientIOWakeup to interrupt the
|
||||
original thread's 'g_main_loop_run' call. When this happens the
|
||||
virNetClientIOEventFD callback never runs, and so the temporary
|
||||
GSource is not destroyed. The g_autoptr() will remove a reference,
|
||||
but by virtue of still being attached to the event context, there
|
||||
is an extra reference held causing GSource to be leaked. The
|
||||
next time 'g_main_loop_run' is called, the original GSource will
|
||||
trigger its callback, and access data that was allocated on the
|
||||
stack by the previous thread, and likely SEGV.
|
||||
|
||||
To solve this, the thread calling 'g_main_loop_run' must call
|
||||
g_source_destroy, immediately upon return, to guarantee that
|
||||
the temporary GSource is removed.
|
||||
|
||||
CVE-2024-4418
|
||||
Reviewed-by: Jan Tomko <jtomko@redhat.com>
|
||||
Reported-by: Martin Shirokov <shirokovmartin@gmail.com>
|
||||
Tested-by: Martin Shirokov <shirokovmartin@gmail.com>
|
||||
Signed-off-by: Daniel P. Berrang茅 <berrange@redhat.com>
|
||||
---
|
||||
src/rpc/virnetclient.c | 14 +++++++++++++-
|
||||
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
|
||||
index 4ab8af68c5..d51bf14eee 100644
|
||||
--- a/src/rpc/virnetclient.c
|
||||
+++ b/src/rpc/virnetclient.c
|
||||
@@ -1657,7 +1657,7 @@ static int virNetClientIOEventLoop(virNetClient *client,
|
||||
#endif /* !WIN32 */
|
||||
int timeout = -1;
|
||||
virNetMessage *msg = NULL;
|
||||
- g_autoptr(GSource) G_GNUC_UNUSED source = NULL;
|
||||
+ g_autoptr(GSource) source = NULL;
|
||||
GIOCondition ev = 0;
|
||||
struct virNetClientIOEventData data = {
|
||||
.client = client,
|
||||
@@ -1721,6 +1721,18 @@ static int virNetClientIOEventLoop(virNetClient *client,
|
||||
|
||||
g_main_loop_run(client->eventLoop);
|
||||
|
||||
+ /*
|
||||
+ * If virNetClientIOEventFD ran, this GSource will already be
|
||||
+ * destroyed due to G_SOURCE_REMOVE. It is harmless to re-destroy
|
||||
+ * it, since we still own a reference.
|
||||
+ *
|
||||
+ * If virNetClientIOWakeup ran, it will have interrupted the
|
||||
+ * g_main_loop_run call, before virNetClientIOEventFD could
|
||||
+ * run, and thus the GSource is still registered, and we need
|
||||
+ * to destroy it since it is referencing stack memory for 'data'
|
||||
+ */
|
||||
+ g_source_destroy(source);
|
||||
+
|
||||
#ifndef WIN32
|
||||
ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
|
||||
#endif /* !WIN32 */
|
||||
--
|
||||
2.33.0
|
||||
|
||||
142
vdpa-vdpa-device-hotplug-unplug-bugfix-and-support-v.patch
Normal file
142
vdpa-vdpa-device-hotplug-unplug-bugfix-and-support-v.patch
Normal file
@ -0,0 +1,142 @@
|
||||
From a588417aec2a5e3da333e89254448ee5944c35e4 Mon Sep 17 00:00:00 2001
|
||||
From: Adttil <2429917001@qq.com>
|
||||
Date: Sat, 23 Nov 2024 18:09:39 +0800
|
||||
Subject: [PATCH 1/2] vdpa: vdpa device hotplug/unplug bugfix and support vdpa
|
||||
device boot index
|
||||
|
||||
---
|
||||
src/qemu/qemu_command.c | 11 +++++++++--
|
||||
src/qemu/qemu_command.h | 3 ++-
|
||||
src/qemu/qemu_domain_address.c | 13 +++++++++++--
|
||||
src/qemu/qemu_hotplug.c | 12 +++++++++++-
|
||||
4 files changed, 33 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
|
||||
index 0c47f019f2..7ca4397dfe 100644
|
||||
--- a/src/qemu/qemu_command.c
|
||||
+++ b/src/qemu/qemu_command.c
|
||||
@@ -5018,15 +5018,22 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def,
|
||||
}
|
||||
|
||||
virJSONValue *
|
||||
-qemuBuildHostdevVDPADevProps(virDomainHostdevDef *dev)
|
||||
+qemuBuildHostdevVDPADevProps(const virDomainDef *def,
|
||||
+ virDomainHostdevDef *dev)
|
||||
{
|
||||
g_autoptr(virJSONValue) props = NULL;
|
||||
virDomainHostdevSubsysVDPA *vdpasrc = &dev->source.subsys.u.vdpa;
|
||||
if (virJSONValueObjectAdd(&props,
|
||||
"s:driver", "vhost-vdpa-device-pci",
|
||||
+ "s:id", dev->info->alias,
|
||||
"s:vhostdev", vdpasrc->devpath,
|
||||
+ "p:bootindex", dev->info->bootIndex,
|
||||
NULL) < 0)
|
||||
return NULL;
|
||||
+
|
||||
+ if (qemuBuildDeviceAddressProps(props, def, dev->info) < 0)
|
||||
+ return NULL;
|
||||
+
|
||||
return g_steal_pointer(&props);
|
||||
}
|
||||
|
||||
@@ -5225,7 +5232,7 @@ qemuBuildHostdevCommandLine(virCommand *cmd,
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA:
|
||||
- if (!(devprops = qemuBuildHostdevVDPADevProps(hostdev)))
|
||||
+ if (!(devprops = qemuBuildHostdevVDPADevProps(def, hostdev)))
|
||||
return -1;
|
||||
if (qemuBuildDeviceCommandlineFromJSON(cmd, devprops, def, qemuCaps) < 0)
|
||||
return -1;
|
||||
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
|
||||
index 432ea59310..273c084322 100644
|
||||
--- a/src/qemu/qemu_command.h
|
||||
+++ b/src/qemu/qemu_command.h
|
||||
@@ -199,7 +199,8 @@ qemuBuildHostdevMediatedDevProps(const virDomainDef *def,
|
||||
virDomainHostdevDef *dev);
|
||||
|
||||
virJSONValue *
|
||||
-qemuBuildHostdevVDPADevProps(virDomainHostdevDef *dev);
|
||||
+qemuBuildHostdevVDPADevProps(const virDomainDef *def,
|
||||
+ virDomainHostdevDef *dev);
|
||||
|
||||
virJSONValue *
|
||||
qemuBuildRedirdevDevProps(const virDomainDef *def,
|
||||
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
|
||||
index 099778b2a8..1f8eee8d61 100644
|
||||
--- a/src/qemu/qemu_domain_address.c
|
||||
+++ b/src/qemu/qemu_domain_address.c
|
||||
@@ -828,7 +828,8 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
||||
if (!virHostdevIsMdevDevice(hostdev) &&
|
||||
(hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
|
||||
(hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
||||
- hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST))) {
|
||||
+ hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST &&
|
||||
+ hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -860,6 +861,13 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
|
||||
if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV)
|
||||
return pcieFlags;
|
||||
|
||||
+ /*
|
||||
+ * if pcieFlags not equal to pciFlags, domain has pcie root port.
|
||||
+ * Thus, we just return pcieFlags.
|
||||
+ */
|
||||
+ if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA)
|
||||
+ return pcieFlags;
|
||||
+
|
||||
/* according to pbonzini, from the guest PoV vhost-scsi devices
|
||||
* are the same as virtio-scsi, so they should follow virtio logic
|
||||
*/
|
||||
@@ -2333,7 +2341,8 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def,
|
||||
if (subsys->type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI &&
|
||||
subsys->type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST &&
|
||||
!(subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV &&
|
||||
- subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_PCI)) {
|
||||
+ subsys->u.mdev.model == VIR_MDEV_MODEL_TYPE_VFIO_PCI) &&
|
||||
+ subsys->type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA) {
|
||||
continue;
|
||||
}
|
||||
|
||||
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
|
||||
index 87353d2149..907971b41f 100644
|
||||
--- a/src/qemu/qemu_hotplug.c
|
||||
+++ b/src/qemu/qemu_hotplug.c
|
||||
@@ -2800,7 +2800,7 @@ qemuDomainAttachVDPADevice(virQEMUDriver *driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
- if (!(devprops = qemuBuildHostdevVDPADevProps(hostdev)))
|
||||
+ if (!(devprops = qemuBuildHostdevVDPADevProps(vm->def, hostdev)))
|
||||
goto cleanup;
|
||||
|
||||
VIR_REALLOC_N(vm->def->hostdevs, vm->def->nhostdevs + 1);
|
||||
@@ -4726,6 +4726,14 @@ qemuDomainRemoveMediatedDevice(virQEMUDriver *driver,
|
||||
}
|
||||
|
||||
|
||||
+static void
|
||||
+qemuDomainRemoveVDPADevice(virDomainObj *vm,
|
||||
+ virDomainHostdevDef *hostdev)
|
||||
+{
|
||||
+ qemuDomainReleaseDeviceAddress(vm, hostdev->info);
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
qemuDomainRemoveHostDevice(virQEMUDriver *driver,
|
||||
virDomainObj *vm,
|
||||
@@ -4798,6 +4806,8 @@ qemuDomainRemoveHostDevice(virQEMUDriver *driver,
|
||||
qemuDomainRemoveMediatedDevice(driver, vm, hostdev);
|
||||
break;
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA:
|
||||
+ qemuDomainRemoveVDPADevice(vm, hostdev);
|
||||
+ break;
|
||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.43.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user