Message ID | 1346312203-29456-1-git-send-email-levinsasha928@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Aug 30, 2012 at 09:36:37AM +0200, Sasha Levin wrote: > + char *new_env[] = { "TERM=linux", "DISPLAY=192.168.33.1:0", > + "HOME=/virt/home", NULL }; > + > + mkdir("/virt/home", 0755); Please add check for mkdir error code. Frankly, this is a bad habbit to assume that mkdir never fails (this could be done on top of this series I think but should not be leaved without attention). Cyrill -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/30/2012 09:50 AM, Cyrill Gorcunov wrote: > On Thu, Aug 30, 2012 at 09:36:37AM +0200, Sasha Levin wrote: >> + char *new_env[] = { "TERM=linux", "DISPLAY=192.168.33.1:0", >> + "HOME=/virt/home", NULL }; >> + >> + mkdir("/virt/home", 0755); > > Please add check for mkdir error code. Frankly, this is a bad habbit > to assume that mkdir never fails (this could be done on top of this > series I think but should not be leaved without attention). This is actually supposed to fail most of the times, since it runs as part of the init :) There's not much we can do if it fails though, and even at that point - this failure isn't serious enough to even justify any further action on our end. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Thu, Aug 30, 2012 at 12:44 PM, Sasha Levin <levinsasha928@gmail.com> wrote: > On 08/30/2012 09:50 AM, Cyrill Gorcunov wrote: >> On Thu, Aug 30, 2012 at 09:36:37AM +0200, Sasha Levin wrote: >>> + char *new_env[] = { "TERM=linux", "DISPLAY=192.168.33.1:0", >>> + "HOME=/virt/home", NULL }; >>> + >>> + mkdir("/virt/home", 0755); >> >> Please add check for mkdir error code. Frankly, this is a bad habbit >> to assume that mkdir never fails (this could be done on top of this >> series I think but should not be leaved without attention). > > This is actually supposed to fail most of the times, since it runs as part of > the init :) You could check for errno == EEXISTS, no? On Thu, Aug 30, 2012 at 12:44 PM, Sasha Levin <levinsasha928@gmail.com> wrote: > There's not much we can do if it fails though, and even at that point - this > failure isn't serious enough to even justify any further action on our end. I'm pretty sure users would appreciate a friendly warning explaining that we are not running in "normal state". -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/30/2012 11:48 AM, Pekka Enberg wrote: > On Thu, Aug 30, 2012 at 12:44 PM, Sasha Levin <levinsasha928@gmail.com> wrote: >> On 08/30/2012 09:50 AM, Cyrill Gorcunov wrote: >>> On Thu, Aug 30, 2012 at 09:36:37AM +0200, Sasha Levin wrote: >>>> + char *new_env[] = { "TERM=linux", "DISPLAY=192.168.33.1:0", >>>> + "HOME=/virt/home", NULL }; >>>> + >>>> + mkdir("/virt/home", 0755); >>> >>> Please add check for mkdir error code. Frankly, this is a bad habbit >>> to assume that mkdir never fails (this could be done on top of this >>> series I think but should not be leaved without attention). >> >> This is actually supposed to fail most of the times, since it runs as part of >> the init :) > > You could check for errno == EEXISTS, no? > > On Thu, Aug 30, 2012 at 12:44 PM, Sasha Levin <levinsasha928@gmail.com> wrote: >> There's not much we can do if it fails though, and even at that point - this >> failure isn't serious enough to even justify any further action on our end. > > I'm pretty sure users would appreciate a friendly warning explaining > that we are not running in "normal state". This is how we ran up until now :) I'm going to move that from init.c into the setup itself then. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/tools/kvm/guest/init.c b/tools/kvm/guest/init.c index e1f377f..9655bdf 100644 --- a/tools/kvm/guest/init.c +++ b/tools/kvm/guest/init.c @@ -12,7 +12,10 @@ static int run_process(char *filename) { char *new_argv[] = { filename, NULL }; - char *new_env[] = { "TERM=linux", "DISPLAY=192.168.33.1:0", NULL }; + char *new_env[] = { "TERM=linux", "DISPLAY=192.168.33.1:0", + "HOME=/virt/home", NULL }; + + mkdir("/virt/home", 0755); return execve(filename, new_argv, new_env); }
Add a HOME env var when booting a hostfs guest. This will point out to a home dir within the given guest name. This will make several apps happier when being run under hostfs. Signed-off-by: Sasha Levin <levinsasha928@gmail.com> --- tools/kvm/guest/init.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)