Skip to contentSkip to conversation

Internet Access for Browser in Qemu

Qemu-devel Dave Feustel 2 participants 2 messages Nov 13, 2005 – Nov 14, 2005

lore
Share & tools
lore
#0 lore raw

Hi!

I now have Qemu 6.1 running on OpenBSD 3.7 release. I now can successfully ping 10.0.0.1 from within Qemu and also from the Host side. I have defined a bridge containing xl0 and tun0 and I have enabled packet forwarding by setting net.inet.ip.forwarding=1. Pf is running but has no rules for traffic to/from Qemu. What else do I need to do to be able to access the internet from a browser running on Linux within Qemu?

Thanks,
Dave Feustel

Signature · 4 lines
Tired of having to defend against Malware?
You know: trojans, viruses, SPYWARE, ADWARE, 
KEYLOGGERS, rootkits, worms and popups.
Then Switch to OpenBSD with a KDE desktop!!!
#1 lore raw

[Qemu-devel] question about -n (TUN/TAP script option)

When I run qemu as root, it work ok. Now I want to no use root, and I have find that only the script(default is /etc/qemu-ifup) want root. So I write another script qemu-ifup-wrapper, source code(use c):

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>

const char* script = "/etc/qemu-ifup";
const char* cmdname = "qemu-ifup-wrapper";

int main(int ac, char* av[])

{
    const char** new_av = NULL;
    
    if (setuid(0) == -1) {
        const char* reason = strerror(errno);
        fprintf(stderr, "%s: cannot setuid root (%s)\n", cmdname,
reason);
        exit(1);
    }
    
    new_av = malloc(sizeof(char*) * (ac + 1));
    memcpy(new_av, av, sizeof(char*) * ac);
    new_av[ac] = NULL;
    new_av[0]  = script;
    
    execv(script, new_av);

    const char* reason = strerror(errno);
    fprintf(stderr, "%s: cannot execute '%s' (%s)\n", cmdname, script,
reason);
    exit(1);
}

and ls -al qemu-ifup-wrapper is:

-rwsr-sr-x 1 root root 8505 2005-11-14 19:04 qemu-ifup-wrapper

The problem is when I use qemu -n qemu-ifup-wrapper to start qemu, the script unwork. but when I use sudo qemu -n qemu-ifup-wrapper, the script work ok. I don't know why.

And in commandline, I run /etc/qemu-ifup, sudo /etc/qemu-ifup and ./qemu-ifup-wrapper, sudo ./qemu-ifup-wrapper, the result of them is same:

0.0.0.0: ERROR while getting interface flags: No such device 0.0.0.0: ERROR while getting interface flags: No such device Incorrect number of arguments for command
Usage: brctl addif <bridge> <device> add interface to bridge

Thank you!
Regard
Zheng SW