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:
Eric Blake 2011-07-06 16:42:06 -06:00
parent 76f40fa55f
commit f548480b7f
4 changed files with 45 additions and 26 deletions

View File

@ -1032,7 +1032,7 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
virDomainDefPtr def,
int flags)
unsigned int flags)
{
char *ret = NULL;
virCPUDefPtr cpu = NULL;
@ -1064,7 +1064,7 @@ cleanup:
char *qemuDomainFormatXML(struct qemud_driver *driver,
virDomainObjPtr vm,
int flags)
unsigned int flags)
{
virDomainDefPtr def;
@ -1164,7 +1164,7 @@ void qemuDomainObjCheckNetTaint(struct qemud_driver *driver,
static int
qemuDomainOpenLogHelper(struct qemud_driver *driver,
virDomainObjPtr vm,
int flags,
int oflags,
mode_t mode)
{
char *logfile;
@ -1175,7 +1175,7 @@ qemuDomainOpenLogHelper(struct qemud_driver *driver,
return -1;
}
if ((fd = open(logfile, flags, mode)) < 0) {
if ((fd = open(logfile, oflags, mode)) < 0) {
virReportSystemError(errno, _("failed to create logfile %s"),
logfile);
goto cleanup;
@ -1194,18 +1194,19 @@ cleanup:
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 */
if (driver->privileged || append)
flags |= O_APPEND;
oflags |= O_APPEND;
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);
}

View File

@ -215,11 +215,11 @@ void qemuDomainObjExitRemoteWithDriver(struct qemud_driver *driver,
char *qemuDomainDefFormatXML(struct qemud_driver *driver,
virDomainDefPtr vm,
int flags);
unsigned int flags);
char *qemuDomainFormatXML(struct qemud_driver *driver,
virDomainObjPtr vm,
int flags);
unsigned int flags);
void qemuDomainObjTaint(struct qemud_driver *driver,
virDomainObjPtr obj,

View File

@ -804,8 +804,10 @@ static int qemuDomainSnapshotSetCurrentInactive(virDomainObjPtr vm,
static virDrvOpenStatus qemudOpen(virConnectPtr conn,
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 (qemu_driver == NULL)
return VIR_DRV_OPEN_DECLINED;
@ -2691,7 +2693,7 @@ static char *
qemuDomainScreenshot(virDomainPtr dom,
virStreamPtr st,
unsigned int screen,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
@ -2700,6 +2702,8 @@ qemuDomainScreenshot(virDomainPtr dom,
int tmp_fd = -1;
char *ret = NULL;
virCheckFlags(0, NULL);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver);
@ -3890,11 +3894,14 @@ cleanup:
static char *qemuDomainXMLFromNative(virConnectPtr conn,
const char *format,
const char *config,
unsigned int flags ATTRIBUTE_UNUSED) {
unsigned int flags)
{
struct qemud_driver *driver = conn->privateData;
virDomainDefPtr def = NULL;
char *xml = NULL;
virCheckFlags(0, NULL);
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
qemuReportError(VIR_ERR_INVALID_ARG,
_("unsupported config type %s"), format);
@ -3924,7 +3931,8 @@ cleanup:
static char *qemuDomainXMLToNative(virConnectPtr conn,
const char *format,
const char *xmlData,
unsigned int flags ATTRIBUTE_UNUSED) {
unsigned int flags)
{
struct qemud_driver *driver = conn->privateData;
virDomainDefPtr def = NULL;
virDomainChrSourceDef monConfig;
@ -3933,6 +3941,8 @@ static char *qemuDomainXMLToNative(virConnectPtr conn,
char *ret = NULL;
int i;
virCheckFlags(0, NULL);
qemuDriverLock(driver);
if (STRNEQ(format, QEMU_CONFIG_FORMAT_ARGV)) {
@ -6182,12 +6192,14 @@ qemudDomainBlockPeek (virDomainPtr dom,
const char *path,
unsigned long long offset, size_t size,
void *buffer,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
struct qemud_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
int fd = -1, ret = -1, i;
virCheckFlags(0, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
qemuDriverUnlock(driver);
@ -7258,11 +7270,13 @@ out:
static int
qemuCPUCompare(virConnectPtr conn,
const char *xmlDesc,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
struct qemud_driver *driver = conn->privateData;
int ret = VIR_CPU_COMPARE_ERROR;
virCheckFlags(0, VIR_CPU_COMPARE_ERROR);
qemuDriverLock(driver);
if (!driver->caps || !driver->caps->host.cpu) {
@ -7282,10 +7296,12 @@ static char *
qemuCPUBaseline(virConnectPtr conn ATTRIBUTE_UNUSED,
const char **xmlCPUs,
unsigned int ncpus,
unsigned int flags ATTRIBUTE_UNUSED)
unsigned int flags)
{
char *cpu;
virCheckFlags(0, NULL);
cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0);
return cpu;

View File

@ -76,8 +76,8 @@ struct _qemuMigrationCookieGraphics {
typedef struct _qemuMigrationCookie qemuMigrationCookie;
typedef qemuMigrationCookie *qemuMigrationCookiePtr;
struct _qemuMigrationCookie {
int flags;
int flagsMandatory;
unsigned int flags;
unsigned int flagsMandatory;
/* Host properties */
unsigned char localHostuuid[VIR_UUID_BUFLEN];
@ -446,7 +446,7 @@ error:
static int
qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
xmlXPathContextPtr ctxt,
int flags)
unsigned int flags)
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *tmp;
@ -580,7 +580,7 @@ error:
static int
qemuMigrationCookieXMLParseStr(qemuMigrationCookiePtr mig,
const char *xml,
int flags)
unsigned int flags)
{
xmlDocPtr doc = NULL;
xmlXPathContextPtr ctxt = NULL;
@ -614,7 +614,7 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
virDomainObjPtr dom,
char **cookieout,
int *cookieoutlen,
int flags)
unsigned int flags)
{
if (!cookieout || !cookieoutlen)
return 0;
@ -645,7 +645,7 @@ qemuMigrationEatCookie(struct qemud_driver *driver,
virDomainObjPtr dom,
const char *cookiein,
int cookieinlen,
int flags)
unsigned int flags)
{
qemuMigrationCookiePtr mig = NULL;
@ -2564,7 +2564,7 @@ int qemuMigrationConfirm(struct qemud_driver *driver,
virDomainObjPtr vm,
const char *cookiein,
int cookieinlen,
unsigned int flags ATTRIBUTE_UNUSED,
unsigned int flags,
int retcode)
{
qemuMigrationCookiePtr mig;
@ -2575,6 +2575,8 @@ int qemuMigrationConfirm(struct qemud_driver *driver,
driver, conn, vm, NULLSTR(cookiein), cookieinlen,
flags, retcode);
virCheckFlags(0, -1);
if (!(mig = qemuMigrationEatCookie(driver, vm, cookiein, cookieinlen, 0)))
return -1;