[PATCH 0/2] Use g_autofree annotatins instead of VIR_FREE
by Karim Taha
Substitute VIR_FREE with g_autofree annotations in openvz_driver.c and
node_device_driver.c whenever possible.
The remaining instances of VIR_FREE are used to free return values
in case of error.
Kariiem (2):
openvz_driver: use g_autofree instead of VIR_FREE in openvz_driver.c
node_device: use g_autofree instead of VIR_FREE in
node_device_driver.c
src/node_device/node_device_driver.c | 4 +---
src/openvz/openvz_driver.c | 15 ++++-----------
2 files changed, 5 insertions(+), 14 deletions(-)
--
2.44.0
1 year, 1 month
[PATCH 1/1] gitignore: add cscope files to git ignore
by Denis V. Lunev
Signed-off-by: Denis V. Lunev <den(a)openvz.org>
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 4695391342..44a9b446bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ __pycache__/
/build/
/ci/scratch/
tags
+cscope.*
# clangd related ignores
.clangd
--
2.40.1
1 year, 1 month
[PATCH v2] virthreadpool: create threads from the newly expanded workers
by Wei Gong
when the thread pool is dynamically expanded, threads should
not be created from the existing workers; they should be created
from the newly expanded workers
Signed-off-by: Wei Gong <gongwei833x(a)gmail.com>
---
src/util/virthreadpool.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index d45fa92061..de8113df81 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -184,7 +184,8 @@ virThreadPoolExpand(virThreadPool *pool, size_t gain, bool priority)
size_t i = 0;
struct virThreadPoolWorkerData *data = NULL;
- VIR_EXPAND_N(*workers, *curWorkers, gain);
+ VIR_REALLOC_N(*workers, *curWorkers + gain);
+ memset(&(*workers)[*curWorkers], 0, sizeof(virThread) * gain);
for (i = 0; i < gain; i++) {
g_autofree char *name = NULL;
@@ -199,7 +200,7 @@ virThreadPoolExpand(virThreadPool *pool, size_t gain, bool priority)
else
name = g_strdup(pool->jobName);
- if (virThreadCreateFull(&(*workers)[i],
+ if (virThreadCreateFull(&(*workers)[*curWorkers],
false,
virThreadPoolWorker,
name,
@@ -207,15 +208,13 @@ virThreadPoolExpand(virThreadPool *pool, size_t gain, bool priority)
data) < 0) {
VIR_FREE(data);
virReportSystemError(errno, "%s", _("Failed to create thread"));
- goto error;
+ return -1;
}
+
+ (*curWorkers)++;
}
return 0;
-
- error:
- *curWorkers -= gain - i;
- return -1;
}
virThreadPool *
--
2.32.1 (Apple Git-133)
1 year, 1 month
[PATCH] virthreadpool: create threads from the newly expanded workers
by Wei Gong
when the thread pool is dynamically expanded, threads should
not be created from the existing workers; they should be created
from the newly expanded workers
Signed-off-by: Wei Gong <gongwei833x(a)gmail.com>
---
src/util/virthreadpool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index d45fa92061..6140b7a0a3 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -199,7 +199,7 @@ virThreadPoolExpand(virThreadPool *pool, size_t gain, bool priority)
else
name = g_strdup(pool->jobName);
- if (virThreadCreateFull(&(*workers)[i],
+ if (virThreadCreateFull(&(*workers)[*curWorkers - gain + i],
false,
virThreadPoolWorker,
name,
--
2.32.1 (Apple Git-133)
1 year, 1 month
[libvirt PATCH 0/3] qemu: virtiofs: fixes for session mode
by Ján Tomko
Ján Tomko (3):
qemu: virtiofs: do not crash if cgroups are missing
qemu: virtiofs: set correct label when creating the socket
qemu: virtiofs: error out if getting the group or user name fails
src/qemu/qemu_virtiofs.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--
2.44.0
1 year, 1 month
[PATCH v2] openvz_conf: Use g_autofree
by Rayhan Faizel
Signed-off-by: Rayhan Faizel <rayhan.faizel(a)gmail.com>
---
src/openvz/openvz_conf.c | 60 ++++++++++++----------------------------
1 file changed, 17 insertions(+), 43 deletions(-)
diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c
index eab3f748d0..4dbaef356c 100644
--- a/src/openvz/openvz_conf.c
+++ b/src/openvz/openvz_conf.c
@@ -163,7 +163,7 @@ openvzReadNetworkConf(virDomainDef *def,
{
int ret;
virDomainNetDef *net = NULL;
- char *temp = NULL;
+ g_autofree char *temp = NULL;
char *token, *saveptr = NULL;
/*parse routing network configuration*
@@ -258,12 +258,9 @@ openvzReadNetworkConf(virDomainDef *def,
}
}
- VIR_FREE(temp);
-
return 0;
error:
- VIR_FREE(temp);
virDomainNetDefFree(net);
return -1;
}
@@ -276,7 +273,7 @@ openvzReadFSConf(virDomainDef *def,
int ret;
virDomainFSDef *fs = NULL;
g_autofree char *veid_str = NULL;
- char *temp = NULL;
+ g_autofree char *temp = NULL;
const char *param;
unsigned long long barrier, limit;
@@ -337,11 +334,8 @@ openvzReadFSConf(virDomainDef *def,
VIR_APPEND_ELEMENT(def->fss, def->nfss, fs);
- VIR_FREE(temp);
-
return 0;
error:
- VIR_FREE(temp);
virDomainFSDefFree(fs);
return -1;
}
@@ -351,7 +345,7 @@ static int
openvzReadMemConf(virDomainDef *def, int veid)
{
int ret = -1;
- char *temp = NULL;
+ g_autofree char *temp = NULL;
unsigned long long barrier, limit;
const char *param;
long kb_per_pages;
@@ -411,7 +405,6 @@ openvzReadMemConf(virDomainDef *def, int veid)
ret = 0;
error:
- VIR_FREE(temp);
return ret;
}
@@ -549,7 +542,7 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
g_autofree char *temp_file = NULL;
int temp_fd = -1;
FILE *fp;
- char *line = NULL;
+ g_autofree char *line = NULL;
size_t line_size = 0;
temp_file = g_strdup_printf("%s.tmp", conf_file);
@@ -586,12 +579,9 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
if (rename(temp_file, conf_file) < 0)
goto error;
- VIR_FREE(line);
-
return 0;
error:
- VIR_FREE(line);
VIR_FORCE_FCLOSE(fp);
VIR_FORCE_CLOSE(temp_fd);
if (temp_file)
@@ -602,14 +592,13 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va
int
openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value)
{
- char *conf_file;
+ g_autofree char *conf_file = NULL;
int ret;
if (openvzLocateConfFile(vpsid, &conf_file, "conf") < 0)
return -1;
ret = openvzWriteConfigParam(conf_file, param, value);
- VIR_FREE(conf_file);
return ret;
}
@@ -622,7 +611,7 @@ openvzWriteVPSConfigParam(int vpsid, const char *param, const char *value)
int
openvzReadConfigParam(const char *conf_file, const char *param, char **value)
{
- char *line = NULL;
+ g_autofree char *line = NULL;
size_t line_size = 0;
FILE *fp;
int err = 0;
@@ -652,7 +641,6 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
/* keep going - last entry wins */
}
}
- VIR_FREE(line);
VIR_FORCE_FCLOSE(fp);
return err ? -1 : *value ? 1 : 0;
@@ -672,21 +660,20 @@ openvzReadConfigParam(const char *conf_file, const char *param, char **value)
int
openvzReadVPSConfigParam(int vpsid, const char *param, char **value)
{
- char *conf_file;
+ g_autofree char *conf_file = NULL;
int ret;
if (openvzLocateConfFile(vpsid, &conf_file, "conf") < 0)
return -1;
ret = openvzReadConfigParam(conf_file, param, value);
- VIR_FREE(conf_file);
return ret;
}
static int
openvz_copyfile(char* from_path, char* to_path)
{
- char *line = NULL;
+ g_autofree char *line = NULL;
size_t line_size = 0;
FILE *fp;
int copy_fd;
@@ -715,12 +702,9 @@ openvz_copyfile(char* from_path, char* to_path)
if (VIR_CLOSE(copy_fd) < 0)
goto error;
- VIR_FREE(line);
-
return 0;
error:
- VIR_FREE(line);
VIR_FORCE_FCLOSE(fp);
VIR_FORCE_CLOSE(copy_fd);
return -1;
@@ -734,10 +718,10 @@ openvz_copyfile(char* from_path, char* to_path)
int
openvzCopyDefaultConfig(int vpsid)
{
- char *confdir = NULL;
- char *default_conf_file = NULL;
- char *configfile_value = NULL;
- char *conf_file = NULL;
+ g_autofree char *confdir = NULL;
+ g_autofree char *default_conf_file = NULL;
+ g_autofree char *configfile_value = NULL;
+ g_autofree char *conf_file = NULL;
int ret = -1;
if (openvzReadConfigParam(VZ_CONF_FILE, "CONFIGFILE", &configfile_value) < 0)
@@ -758,10 +742,6 @@ openvzCopyDefaultConfig(int vpsid)
ret = 0;
cleanup:
- VIR_FREE(confdir);
- VIR_FREE(default_conf_file);
- VIR_FREE(configfile_value);
- VIR_FREE(conf_file);
return ret;
}
@@ -771,7 +751,7 @@ openvzCopyDefaultConfig(int vpsid)
static int
openvzLocateConfFileDefault(int vpsid, char **conffile, const char *ext)
{
- char *confdir;
+ g_autofree char *confdir = NULL;
int ret = 0;
confdir = openvzLocateConfDir();
@@ -780,7 +760,6 @@ openvzLocateConfFileDefault(int vpsid, char **conffile, const char *ext)
*conffile = g_strdup_printf("%s/%d.%s", confdir, vpsid, ext ? ext : "conf");
- VIR_FREE(confdir);
return ret;
}
@@ -828,8 +807,8 @@ openvz_readline(int fd, char *ptr, int maxlen)
static int
openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
{
- char *conf_file;
- char *line = NULL;
+ g_autofree char *conf_file = NULL;
+ g_autofree char *line = NULL;
size_t line_size = 0;
char *saveptr = NULL;
char *uuidbuf;
@@ -868,9 +847,7 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
}
retval = 0;
cleanup:
- VIR_FREE(line);
VIR_FORCE_FCLOSE(fp);
- VIR_FREE(conf_file);
return retval;
}
@@ -881,7 +858,7 @@ openvzGetVPSUUID(int vpsid, char *uuidstr, size_t len)
int
openvzSetDefinedUUID(int vpsid, unsigned char *uuid)
{
- char *conf_file;
+ g_autofree char *conf_file = NULL;
char uuidstr[VIR_UUID_STRING_BUFLEN];
FILE *fp = NULL;
int ret = -1;
@@ -912,7 +889,6 @@ openvzSetDefinedUUID(int vpsid, unsigned char *uuid)
ret = 0;
cleanup:
VIR_FORCE_FCLOSE(fp);
- VIR_FREE(conf_file);
return ret;
}
@@ -941,7 +917,7 @@ static int openvzAssignUUIDs(void)
{
g_autoptr(DIR) dp = NULL;
struct dirent *dent;
- char *conf_dir;
+ g_autofree char *conf_dir = NULL;
int vpsid;
char *ext;
int ret = 0;
@@ -951,7 +927,6 @@ static int openvzAssignUUIDs(void)
return -1;
if (virDirOpenQuiet(&dp, conf_dir) < 0) {
- VIR_FREE(conf_dir);
return 0;
}
@@ -964,7 +939,6 @@ static int openvzAssignUUIDs(void)
openvzSetUUID(vpsid);
}
- VIR_FREE(conf_dir);
return ret;
}
--
2.34.1
1 year, 1 month
Re: [PATCH v2] Remove VIR_FREE in favor of g_autofree in some
functions in libvrit-domain.c
by Peter Krempa
On Tue, Mar 12, 2024 at 17:58:08 +0000, m kamal wrote:
> Thanks a lot for the review, Peter.
>
> The first name I used was by mistake, it's the name of my Github profile, Github desktop probably auto-configured it as the global user name for git on my machine. It's in Arabic so it could confuse many non-Unicode-aware programs or protocols. The other name "m kamal" is just a contraction I wrote when I was subscribing to the mailing list from the web UI, I didn't realize it's important.
Technically that is not important as it can be overriden by using a From
line similarly to your first subscription. The only important bit is
what will be recorded in the GIT history, you're free to use any other
version in other communication.
>
> I will change my configured name in the .gitpublish config to be the longer name "Mostafa Mahmoud", that's the first 2 names of my legal name, it appears that most names here are also 2 names. If there is also a way to change my forum name "m kamal" please let me know.a
If by 'forum' you mean the mailing list you should be able to change
that in https://lists.libvirt.org/user-profile/ once you log in.
>
> Sorry for any inconvenience. One last question: After the patch got your approval, is there something on my end to do so that it gets merged? Will it automatically gets picked up by the Gitlab CI pipeline somehow?
Depending on whether you want to test if you configured your environment
propely you can either send a v3 with updated autorship and sign-off, or
just reply with the full format you're intending to use and I can modify
this patch and push it.
Pushing is done by one of the maintainers, which would be me since I've
reviewed it.
1 year, 1 month
[PATCH 0/2] Use g_autofree annotatins instead of VIR_FREE
by Karim Taha
Substitute VIR_FREE with g_autofree annotations in openvz_driver.c and
node_device_driver.c whenever possible.
The remaining instances of VIR_FREE are used to free return values
in case of error.
Kariiem (2):
openvz_driver: use g_autofree instead of VIR_FREE in openvz_driver.c
node_device: use g_autofree instead of VIR_FREE in
node_device_driver.c
src/node_device/node_device_driver.c | 4 +---
src/openvz/openvz_driver.c | 15 ++++-----------
2 files changed, 5 insertions(+), 14 deletions(-)
--
2.44.0
1 year, 1 month
[PATCH 0/2] Use g_autofree instead of VIR_FREE
by Karim Taha
Substiute VIR_FREE with g_autofree annotations in openvz_driver.c and
node_device_driver.c, whenever possbile.
The remaining instances cannot be changed, they are used to free return
values in case of error.
Kariiem (2):
openvz_driver: use g_autofree instead of VIR_FREE in openvz_driver.c
node_device: use g_autofree instead of VIR_FREE in
node_device_driver.c
src/node_device/node_device_driver.c | 4 +---
src/openvz/openvz_driver.c | 15 ++++-----------
2 files changed, 5 insertions(+), 14 deletions(-)
--
2.44.0
1 year, 1 month