libvirt/src/xen/xm_internal.h
Daniel P. Berrange 427067f7ed xen: fix race in refresh of config cache
The xenXMConfigCacheRefresh method scans /etc/xen and loads
all config files it finds. It then scans its internal hash
table and purges any (previously) loaded config files whose
refresh timestamp does not match the timestamp recorded at
the start of xenXMConfigCacheRefresh(). There is unfortunately
a subtle flaw in this, because if loading the config files
takes longer than 1 second, some of the config files will
have a refresh timestamp that is 1 or more seconds different
(newer) than is checked for. So we immediately purge a bunch
of valid config files we just loaded.

To avoid this flaw, we must pass the timestamp we record at
the start of xenXMConfigCacheRefresh() into the
xenXMConfigCacheAddFile() method, instead of letting the
latter call time(NULL) again.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-09-11 17:25:29 +01:00

106 lines
4.3 KiB
C

/*
* xm_internal.h: helper routines for dealing with inactive domains
*
* Copyright (C) 2006-2007, 2010-2012 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* 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/>.
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*
*/
#ifndef _LIBVIRT_XM_INTERNAL_H_
# define _LIBVIRT_XM_INTERNAL_H_
# include "internal.h"
# include "driver.h"
# include "virconf.h"
# include "domain_conf.h"
int xenXMConfigCacheRefresh (virConnectPtr conn);
int xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename, time_t now);
int xenXMConfigCacheRemoveFile(virConnectPtr conn, const char *filename);
int xenXMOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags);
int xenXMClose(virConnectPtr conn);
const char *xenXMGetType(virConnectPtr conn);
int xenXMDomainGetInfo(virConnectPtr conn,
virDomainDefPtr def,
virDomainInfoPtr info);
int xenXMDomainGetState(virConnectPtr conn,
virDomainDefPtr def,
int *state,
int *reason);
virDomainDefPtr xenXMDomainGetXMLDesc(virConnectPtr conn,
virDomainDefPtr def);
int xenXMDomainSetMemory(virConnectPtr conn,
virDomainDefPtr def,
unsigned long memory);
int xenXMDomainSetMaxMemory(virConnectPtr conn,
virDomainDefPtr def,
unsigned long memory);
unsigned long long xenXMDomainGetMaxMemory(virConnectPtr conn,
virDomainDefPtr def);
int xenXMDomainSetVcpus(virConnectPtr conn,
virDomainDefPtr def,
unsigned int vcpus);
int xenXMDomainSetVcpusFlags(virConnectPtr conn,
virDomainDefPtr def,
unsigned int vcpus,
unsigned int flags);
int xenXMDomainGetVcpusFlags(virConnectPtr conn,
virDomainDefPtr def,
unsigned int flags);
int xenXMDomainPinVcpu(virConnectPtr conn,
virDomainDefPtr def,
unsigned int vcpu,
unsigned char *cpumap,
int maplen);
virDomainDefPtr xenXMDomainLookupByName(virConnectPtr conn, const char *domname);
virDomainDefPtr xenXMDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid);
int xenXMListDefinedDomains(virConnectPtr conn, char ** const names, int maxnames);
int xenXMNumOfDefinedDomains(virConnectPtr conn);
int xenXMDomainCreate(virConnectPtr conn,
virDomainDefPtr def);
int xenXMDomainDefineXML(virConnectPtr con, virDomainDefPtr def);
int xenXMDomainUndefine(virConnectPtr conn, virDomainDefPtr def);
int xenXMDomainBlockPeek(virConnectPtr conn,
virDomainDefPtr def,
const char *path,
unsigned long long offset,
size_t size,
void *buffer);
int xenXMDomainGetAutostart(virDomainDefPtr def,
int *autostart);
int xenXMDomainSetAutostart(virDomainDefPtr def,
int autostart);
int xenXMDomainAttachDeviceFlags(virConnectPtr conn,
virDomainDefPtr def,
const char *xml,
unsigned int flags);
int xenXMDomainDetachDeviceFlags(virConnectPtr conn,
virDomainDefPtr def,
const char *xml,
unsigned int flags);
#endif