提交 f5059a92 编写于 作者: D Daniel P. Berrange

Change QEMU capabilities cache to check ctime instead of mtime

Debian's package manager will preserve mtime timestamp on binaries
from the time they are built, rather than installed. So if a
user downgrades their QEMU dpkg, the libvirt capabilities
cache will not refresh. The fix is to use ctime instead of mtime
since it cannot be faked.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 10ec0725
...@@ -259,7 +259,7 @@ struct _virQEMUCaps { ...@@ -259,7 +259,7 @@ struct _virQEMUCaps {
bool usedQMP; bool usedQMP;
char *binary; char *binary;
time_t mtime; time_t ctime;
virBitmapPtr flags; virBitmapPtr flags;
...@@ -2796,7 +2796,7 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary, ...@@ -2796,7 +2796,7 @@ virQEMUCapsPtr virQEMUCapsNewForBinary(const char *binary,
binary); binary);
goto error; goto error;
} }
qemuCaps->mtime = sb.st_mtime; qemuCaps->ctime = sb.st_ctime;
/* Make sure the binary we are about to try exec'ing exists. /* Make sure the binary we are about to try exec'ing exists.
* Technically we could catch the exec() failure, but that's * Technically we could catch the exec() failure, but that's
...@@ -2838,7 +2838,7 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps) ...@@ -2838,7 +2838,7 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps)
if (stat(qemuCaps->binary, &sb) < 0) if (stat(qemuCaps->binary, &sb) < 0)
return false; return false;
return sb.st_mtime == qemuCaps->mtime; return sb.st_ctime == qemuCaps->ctime;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册