提交 c1a34c87 编写于 作者: P Peter Krempa

test: Use atomic access to @nextDomID in struct virTestDriver

上级 beba6a0e
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "virstring.h" #include "virstring.h"
#include "cpu/cpu.h" #include "cpu/cpu.h"
#include "virauth.h" #include "virauth.h"
#include "viratomic.h"
#define VIR_FROM_THIS VIR_FROM_TEST #define VIR_FROM_THIS VIR_FROM_TEST
...@@ -95,7 +96,6 @@ typedef struct _testAuth *testAuthPtr; ...@@ -95,7 +96,6 @@ typedef struct _testAuth *testAuthPtr;
struct _testDriver { struct _testDriver {
virMutex lock; virMutex lock;
int nextDomID;
virNodeInfo nodeInfo; virNodeInfo nodeInfo;
virInterfaceObjList ifaces; virInterfaceObjList ifaces;
bool transaction_running; bool transaction_running;
...@@ -107,6 +107,9 @@ struct _testDriver { ...@@ -107,6 +107,9 @@ struct _testDriver {
size_t numAuths; size_t numAuths;
testAuthPtr auths; testAuthPtr auths;
/* virAtomic access only */
volatile int nextDomID;
/* immutable pointer, immutable object after being initialized with /* immutable pointer, immutable object after being initialized with
* testBuildCapabilities */ * testBuildCapabilities */
virCapsPtr caps; virCapsPtr caps;
...@@ -417,7 +420,7 @@ testDriverNew(void) ...@@ -417,7 +420,7 @@ testDriverNew(void)
!(ret->networks = virNetworkObjListNew())) !(ret->networks = virNetworkObjListNew()))
goto error; goto error;
ret->nextDomID = 1; virAtomicIntSet(&ret->nextDomID, 1);
return ret; return ret;
...@@ -712,7 +715,7 @@ testDomainStartState(testDriverPtr privconn, ...@@ -712,7 +715,7 @@ testDomainStartState(testDriverPtr privconn,
goto cleanup; goto cleanup;
virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason); virDomainObjSetState(dom, VIR_DOMAIN_RUNNING, reason);
dom->def->id = privconn->nextDomID++; dom->def->id = virAtomicIntAdd(&privconn->nextDomID, 1);
if (virDomainObjSetDefTransient(privconn->caps, if (virDomainObjSetDefTransient(privconn->caps,
privconn->xmlopt, privconn->xmlopt,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册