This function works over domain definition and not domain object.
Its name is thus misleading.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
src/conf/domain_conf.c | 4 ++--
src/conf/domain_conf.h | 2 +-
src/libvirt_private.syms | 2 +-
src/qemu/qemu_conf.c | 2 +-
src/qemu/qemu_domain.c | 4 ++--
src/qemu/qemu_driver.c | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 77c20c697..58b75c672 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27871,14 +27871,14 @@ virDomainDefHasMemballoon(const virDomainDef *def)
#define VIR_DOMAIN_SHORT_NAME_MAX 20
/**
- * virDomainObjGetShortName:
+ * virDomainDefGetShortName:
* @vm: Machine for which to get a name
* @unique: Make sure the name is unique (use id as well)
*
* Shorten domain name to avoid possible path length limitations.
*/
char *
-virDomainObjGetShortName(const virDomainDef *def)
+virDomainDefGetShortName(const virDomainDef *def)
{
wchar_t wshortname[VIR_DOMAIN_SHORT_NAME_MAX + 1] = {0};
size_t len = 0;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 38de70b15..bd541a9c5 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -3366,7 +3366,7 @@ int virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def,
bool virDomainDefHasMemballoon(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
-char *virDomainObjGetShortName(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
+char *virDomainDefGetShortName(const virDomainDef *def) ATTRIBUTE_NONNULL(1);
int
virDomainGetBlkioParametersAssignFromDef(virDomainDefPtr def,
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 448d962b2..3ebff18aa 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -262,6 +262,7 @@ virDomainDefGetMemoryInitial;
virDomainDefGetMemoryTotal;
virDomainDefGetOnlineVcpumap;
virDomainDefGetSecurityLabelDef;
+virDomainDefGetShortName;
virDomainDefGetVcpu;
virDomainDefGetVcpuPinInfoHelper;
virDomainDefGetVcpus;
@@ -457,7 +458,6 @@ virDomainObjGetMetadata;
virDomainObjGetOneDef;
virDomainObjGetOneDefState;
virDomainObjGetPersistentDef;
-virDomainObjGetShortName;
virDomainObjGetState;
virDomainObjNew;
virDomainObjParseNode;
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index ec61c9c52..bf6b334f4 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1659,7 +1659,7 @@ qemuGetDomainHugepagePath(const virDomainDef *def,
virHugeTLBFSPtr hugepage)
{
char *base = qemuGetBaseHugepagePath(hugepage);
- char *domPath = virDomainObjGetShortName(def);
+ char *domPath = virDomainDefGetShortName(def);
char *ret = NULL;
if (base && domPath)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index c7c9e94da..e828fa2f6 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1705,7 +1705,7 @@ qemuDomainSetPrivatePaths(virQEMUDriverPtr driver,
{
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv = vm->privateData;
- char *domname = virDomainObjGetShortName(vm->def);
+ char *domname = virDomainDefGetShortName(vm->def);
int ret = -1;
if (!domname)
@@ -8203,7 +8203,7 @@ qemuDomainGetPreservedMountPath(virQEMUDriverConfigPtr cfg,
char *path = NULL;
char *tmp;
const char *suffix = mountpoint + strlen(DEVPREFIX);
- char *domname = virDomainObjGetShortName(vm->def);
+ char *domname = virDomainDefGetShortName(vm->def);
size_t off;
if (!domname)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 74fdfdb0f..135c20749 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4079,7 +4079,7 @@ getAutoDumpPath(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
char *dumpfile = NULL;
- char *domname = virDomainObjGetShortName(vm->def);
+ char *domname = virDomainDefGetShortName(vm->def);
char timestr[100];
struct tm time_info;
time_t curtime = time(NULL);
--
2.13.6
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On 10/24/2017 07:41 AM, Michal Privoznik wrote: > This function works over domain definition and not domain object. > Its name is thus misleading. > > Signed-off-by: Michal Privoznik <mprivozn@redhat.com> > --- > src/conf/domain_conf.c | 4 ++-- > src/conf/domain_conf.h | 2 +- > src/libvirt_private.syms | 2 +- > src/qemu/qemu_conf.c | 2 +- > src/qemu/qemu_domain.c | 4 ++-- > src/qemu/qemu_driver.c | 2 +- > 6 files changed, 8 insertions(+), 8 deletions(-) > Reviewed-by: John Ferlan <jferlan@redhat.com> John BTW: I wonder if this function is somewhat broken - it's using def->id in order to generate the output, right? Which means for paths generated before the guest starts, they'll start with "-1"... IOW: Directory and file names that start with "-". This wasn't a problem originally (commit id a042275a) since the resulting path had "domain-" prepended to it - resulting in "domain--1-QEMUGuest1, for example). Personally, this looks REALLY odd when (re)using for example with a hugepage test where the path is "-mem-path /dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1". OK - maybe it's just me, but seeing a filename start with "-" is really painful because it's not just a simple task of "rm $file", since "-" needs to escaped so as to not be considered an argument to rm <sigh>. I know, send a patch or just grumble and let someone else do it ;-) -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
On 11/02/2017 12:11 AM, John Ferlan wrote: > > > On 10/24/2017 07:41 AM, Michal Privoznik wrote: >> This function works over domain definition and not domain object. >> Its name is thus misleading. >> >> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> >> --- >> src/conf/domain_conf.c | 4 ++-- >> src/conf/domain_conf.h | 2 +- >> src/libvirt_private.syms | 2 +- >> src/qemu/qemu_conf.c | 2 +- >> src/qemu/qemu_domain.c | 4 ++-- >> src/qemu/qemu_driver.c | 2 +- >> 6 files changed, 8 insertions(+), 8 deletions(-) >> > > Reviewed-by: John Ferlan <jferlan@redhat.com> > > John > > BTW: I wonder if this function is somewhat broken - it's using def->id > in order to generate the output, right? Which means for paths generated > before the guest starts, they'll start with "-1"... IOW: Directory and > file names that start with "-". > > This wasn't a problem originally (commit id a042275a) since the > resulting path had "domain-" prepended to it - resulting in > "domain--1-QEMUGuest1, for example). > > Personally, this looks REALLY odd when (re)using for example with a > hugepage test where the path is "-mem-path > /dev/hugepages2M/libvirt/qemu/-1-QEMUGuest1". This is because we don't set an ID for domains when testing. However, in real scenarios this function is called over running domains. Therefore, the path will always start with a natural number. I don't think there's anything to fix really. We could go with "domain-" prefix but that'd be no better in fact. Yes, it would help with 'rm' case but other than that it has no added value. Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2025 Red Hat, Inc.