提交 74e03496 编写于 作者: T Taku Izumi 提交者: Laine Stump

qemu: make qemu processes to retain rawio capability

This patch revises qemuProcessStart() function for qemu
processes to retain CAP_SYS_RAWIO if needed.
And in case of that, add taint flag to domain.
Signed-off-by: NTaku Izumi <izumi.taku@jp.fujitsu.com>
Signed-off-by: NShota Hirae <m11g1401@hibikino.ne.jp>
上级 c2e146bf
...@@ -1259,6 +1259,9 @@ void qemuDomainObjCheckDiskTaint(struct qemud_driver *driver, ...@@ -1259,6 +1259,9 @@ void qemuDomainObjCheckDiskTaint(struct qemud_driver *driver,
if (!disk->driverType && if (!disk->driverType &&
driver->allowDiskFormatProbing) driver->allowDiskFormatProbing)
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_DISK_PROBING, logFD); qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_DISK_PROBING, logFD);
if (disk->rawio)
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_HIGH_PRIVILEGES, logFD);
} }
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <linux/capability.h>
#include "qemu_process.h" #include "qemu_process.h"
#include "qemu_domain.h" #include "qemu_domain.h"
...@@ -3083,6 +3084,7 @@ int qemuProcessStart(virConnectPtr conn, ...@@ -3083,6 +3084,7 @@ int qemuProcessStart(virConnectPtr conn,
virCommandPtr cmd = NULL; virCommandPtr cmd = NULL;
struct qemuProcessHookData hookData; struct qemuProcessHookData hookData;
unsigned long cur_balloon; unsigned long cur_balloon;
int i;
hookData.conn = conn; hookData.conn = conn;
hookData.vm = vm; hookData.vm = vm;
...@@ -3335,6 +3337,12 @@ int qemuProcessStart(virConnectPtr conn, ...@@ -3335,6 +3337,12 @@ int qemuProcessStart(virConnectPtr conn,
if (driver->clearEmulatorCapabilities) if (driver->clearEmulatorCapabilities)
virCommandClearCaps(cmd); virCommandClearCaps(cmd);
/* in case a certain disk is desirous of CAP_SYS_RAWIO, add this */
for (i = 0; i < vm->def->ndisks; i++) {
if (vm->def->disks[i]->rawio == 1)
virCommandAllowCap(cmd, CAP_SYS_RAWIO);
}
virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData); virCommandSetPreExecHook(cmd, qemuProcessHook, &hookData);
virCommandSetOutputFD(cmd, &logfile); virCommandSetOutputFD(cmd, &logfile);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册