mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: reject unknown flags
* src/qemu/qemu_driver.c (qemudOpen, qemuDomainScreenshot) (qemuDomainXMLFromNative, qemuDomainXMLToNative) (qemudDomainBlockPeek, qemuCPUCompare, qemuCPUBaseline): Reject unknown flags. * src/qemu/qemu_migration.c (qemuMigrationConfirm): Likewise. (_qemuMigrationCookie, qemuMigrationCookieXMLParse) (qemuMigrationCookieXMLParseStr, qemuMigrationBakeCookie) (qemuMigrationEatCookie): Make flags unsigned. * src/qemu/qemu_domain.h: (qemuDomainDefFormatXML) (qemuDomainFormatXML): Prefer unsigned flags. * src/qemu/qemu_domain.c (qemuDomainDefFormatXML) (qemuDomainFormatXML): Likewise. (qemuDomainOpenLogHelper, qemuDomainCreateLog): Rename variable.
This commit is contained in:
parent
76f40fa55f
commit
f548480b7f
@ -1032,7 +1032,7 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
|||||||
|
|
||||||
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
||||||
virDomainDefPtr def,
|
virDomainDefPtr def,
|
||||||
int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
virCPUDefPtr cpu = NULL;
|
virCPUDefPtr cpu = NULL;
|
||||||
@ -1064,7 +1064,7 @@ cleanup:
|
|||||||
|
|
||||||
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virDomainDefPtr def;
|
virDomainDefPtr def;
|
||||||
|
|
||||||
@ -1164,7 +1164,7 @@ void qemuDomainObjCheckNetTaint(struct qemud_driver *driver,
|
|||||||
static int
|
static int
|
||||||
qemuDomainOpenLogHelper(struct qemud_driver *driver,
|
qemuDomainOpenLogHelper(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
int flags,
|
int oflags,
|
||||||
mode_t mode)
|
mode_t mode)
|
||||||
{
|
{
|
||||||
char *logfile;
|
char *logfile;
|
||||||
@ -1175,7 +1175,7 @@ qemuDomainOpenLogHelper(struct qemud_driver *driver,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(logfile, flags, mode)) < 0) {
|
if ((fd = open(logfile, oflags, mode)) < 0) {
|
||||||
virReportSystemError(errno, _("failed to create logfile %s"),
|
virReportSystemError(errno, _("failed to create logfile %s"),
|
||||||
logfile);
|
logfile);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1194,18 +1194,19 @@ cleanup:
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
qemuDomainCreateLog(struct qemud_driver *driver, virDomainObjPtr vm, bool append)
|
qemuDomainCreateLog(struct qemud_driver *driver, virDomainObjPtr vm,
|
||||||
|
bool append)
|
||||||
{
|
{
|
||||||
int flags;
|
int oflags;
|
||||||
|
|
||||||
flags = O_CREAT | O_WRONLY;
|
oflags = O_CREAT | O_WRONLY;
|
||||||
/* Only logrotate files in /var/log, so only append if running privileged */
|
/* Only logrotate files in /var/log, so only append if running privileged */
|
||||||
if (driver->privileged || append)
|
if (driver->privileged || append)
|
||||||
flags |= O_APPEND;
|
oflags |= O_APPEND;
|
||||||
else
|
else
|
||||||
flags |= O_TRUNC;
|
oflags |= O_TRUNC;
|
||||||
|
|
||||||
return qemuDomainOpenLogHelper(driver, vm, flags, S_IRUSR | S_IWUSR);
|
return qemuDomainOpenLogHelper(driver, vm, oflags, S_IRUSR | S_IWUSR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,11 +215,11 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
|
|||||||
|
|
||||||
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
|
||||||
virDomainDefPtr vm,
|
virDomainDefPtr vm,
|
||||||
int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
char *qemuDomainFormatXML(struct qemud_driver *driver,
|
||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
void qemuDomainObjTaint(struct qemud_driver *driver,
|
void qemuDomainObjTaint(struct qemud_driver *driver,
|
||||||
virDomainObjPtr obj,
|
virDomainObjPtr obj,
|
||||||
|
@ -804,8 +804,10 @@ static int qemuDomainSnapshotSetCurrentInactive(virDomainObjPtr vm,
|
|||||||
|
|
||||||
static virDrvOpenStatus qemudOpen(virConnectPtr conn,
|
static virDrvOpenStatus qemudOpen(virConnectPtr conn,
|
||||||
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR);
|
||||||
|
|
||||||
if (conn->uri == NULL) {
|
if (conn->uri == NULL) {
|
||||||
if (qemu_driver == NULL)
|
if (qemu_driver == NULL)
|
||||||
return VIR_DRV_OPEN_DECLINED;
|
return VIR_DRV_OPEN_DECLINED;
|
||||||
@ -2691,7 +2693,7 @@ static char *
|
|||||||
qemuDomainScreenshot(virDomainPtr dom,
|
qemuDomainScreenshot(virDomainPtr dom,
|
||||||
virStreamPtr st,
|
virStreamPtr st,
|
||||||
unsigned int screen,
|
unsigned int screen,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
@ -2700,6 +2702,8 @@ qemuDomainScreenshot(virDomainPtr dom,
|
|||||||
int tmp_fd = -1;
|
int tmp_fd = -1;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
@ -3890,11 +3894,14 @@ cleanup:
|
|||||||
static char *qemuDomainXMLFromNative(virConnectPtr conn,
|
static char *qemuDomainXMLFromNative(virConnectPtr conn,
|
||||||
const char *format,
|
const char *format,
|
||||||
const char *config,
|
const char *config,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED) {
|
unsigned int flags)
|
||||||
|
{
|
||||||
struct qemud_driver *driver = conn->privateData;
|
struct qemud_driver *driver = conn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
char *xml = NULL;
|
char *xml = NULL;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
|
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
|
||||||
qemuReportError(VIR_ERR_INVALID_ARG,
|
qemuReportError(VIR_ERR_INVALID_ARG,
|
||||||
_("unsupported config type %s"), format);
|
_("unsupported config type %s"), format);
|
||||||
@ -3924,7 +3931,8 @@ cleanup:
|
|||||||
static char *qemuDomainXMLToNative(virConnectPtr conn,
|
static char *qemuDomainXMLToNative(virConnectPtr conn,
|
||||||
const char *format,
|
const char *format,
|
||||||
const char *xmlData,
|
const char *xmlData,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED) {
|
unsigned int flags)
|
||||||
|
{
|
||||||
struct qemud_driver *driver = conn->privateData;
|
struct qemud_driver *driver = conn->privateData;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
virDomainChrSourceDef monConfig;
|
virDomainChrSourceDef monConfig;
|
||||||
@ -3933,6 +3941,8 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
|
|||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
|
|
||||||
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
|
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
|
||||||
@ -6182,12 +6192,14 @@ qemudDomainBlockPeek (virDomainPtr dom,
|
|||||||
const char *path,
|
const char *path,
|
||||||
unsigned long long offset, size_t size,
|
unsigned long long offset, size_t size,
|
||||||
void *buffer,
|
void *buffer,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct qemud_driver *driver = dom->conn->privateData;
|
struct qemud_driver *driver = dom->conn->privateData;
|
||||||
virDomainObjPtr vm;
|
virDomainObjPtr vm;
|
||||||
int fd = -1, ret = -1, i;
|
int fd = -1, ret = -1, i;
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
|
||||||
qemuDriverUnlock(driver);
|
qemuDriverUnlock(driver);
|
||||||
@ -7258,11 +7270,13 @@ out:
|
|||||||
static int
|
static int
|
||||||
qemuCPUCompare(virConnectPtr conn,
|
qemuCPUCompare(virConnectPtr conn,
|
||||||
const char *xmlDesc,
|
const char *xmlDesc,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
struct qemud_driver *driver = conn->privateData;
|
struct qemud_driver *driver = conn->privateData;
|
||||||
int ret = VIR_CPU_COMPARE_ERROR;
|
int ret = VIR_CPU_COMPARE_ERROR;
|
||||||
|
|
||||||
|
virCheckFlags(0, VIR_CPU_COMPARE_ERROR);
|
||||||
|
|
||||||
qemuDriverLock(driver);
|
qemuDriverLock(driver);
|
||||||
|
|
||||||
if (!driver->caps || !driver->caps->host.cpu) {
|
if (!driver->caps || !driver->caps->host.cpu) {
|
||||||
@ -7282,10 +7296,12 @@ static char *
|
|||||||
qemuCPUBaseline(virConnectPtr conn ATTRIBUTE_UNUSED,
|
qemuCPUBaseline(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
const char **xmlCPUs,
|
const char **xmlCPUs,
|
||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *cpu;
|
char *cpu;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0);
|
cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0);
|
||||||
|
|
||||||
return cpu;
|
return cpu;
|
||||||
|
@ -76,8 +76,8 @@ struct _qemuMigrationCookieGraphics {
|
|||||||
typedef struct _qemuMigrationCookie qemuMigrationCookie;
|
typedef struct _qemuMigrationCookie qemuMigrationCookie;
|
||||||
typedef qemuMigrationCookie *qemuMigrationCookiePtr;
|
typedef qemuMigrationCookie *qemuMigrationCookiePtr;
|
||||||
struct _qemuMigrationCookie {
|
struct _qemuMigrationCookie {
|
||||||
int flags;
|
unsigned int flags;
|
||||||
int flagsMandatory;
|
unsigned int flagsMandatory;
|
||||||
|
|
||||||
/* Host properties */
|
/* Host properties */
|
||||||
unsigned char localHostuuid[VIR_UUID_BUFLEN];
|
unsigned char localHostuuid[VIR_UUID_BUFLEN];
|
||||||
@ -446,7 +446,7 @@ error:
|
|||||||
static int
|
static int
|
||||||
qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
|
qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
|
||||||
xmlXPathContextPtr ctxt,
|
xmlXPathContextPtr ctxt,
|
||||||
int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
char *tmp;
|
char *tmp;
|
||||||
@ -580,7 +580,7 @@ error:
|
|||||||
static int
|
static int
|
||||||
qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
|
qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
|
||||||
const char *xml,
|
const char *xml,
|
||||||
int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
xmlDocPtr doc = NULL;
|
xmlDocPtr doc = NULL;
|
||||||
xmlXPathContextPtr ctxt = NULL;
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
@ -614,7 +614,7 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
|
|||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom,
|
||||||
char **cookieout,
|
char **cookieout,
|
||||||
int *cookieoutlen,
|
int *cookieoutlen,
|
||||||
int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
if (!cookieout || !cookieoutlen)
|
if (!cookieout || !cookieoutlen)
|
||||||
return 0;
|
return 0;
|
||||||
@ -645,7 +645,7 @@ qemuMigrationEatCookie(struct qemud_driver *driver,
|
|||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom,
|
||||||
const char *cookiein,
|
const char *cookiein,
|
||||||
int cookieinlen,
|
int cookieinlen,
|
||||||
int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
qemuMigrationCookiePtr mig = NULL;
|
qemuMigrationCookiePtr mig = NULL;
|
||||||
|
|
||||||
@ -2564,7 +2564,7 @@ int qemuMigrationConfirm(struct qemud_driver *driver,
|
|||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
const char *cookiein,
|
const char *cookiein,
|
||||||
int cookieinlen,
|
int cookieinlen,
|
||||||
unsigned int flags ATTRIBUTE_UNUSED,
|
unsigned int flags,
|
||||||
int retcode)
|
int retcode)
|
||||||
{
|
{
|
||||||
qemuMigrationCookiePtr mig;
|
qemuMigrationCookiePtr mig;
|
||||||
@ -2575,6 +2575,8 @@ int qemuMigrationConfirm(struct qemud_driver *driver,
|
|||||||
driver, conn, vm, NULLSTR(cookiein), cookieinlen,
|
driver, conn, vm, NULLSTR(cookiein), cookieinlen,
|
||||||
flags, retcode);
|
flags, retcode);
|
||||||
|
|
||||||
|
virCheckFlags(0, -1);
|
||||||
|
|
||||||
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, 0)))
|
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, 0)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user