Image copyright Donna Bowater Image caption Rio de Janeiro's favelas are now home to a growing number of guesthouses and B&Bs

For most foreign visitors to Rio de Janeiro, the thought of spending the night in one of the city's favelas or shanty towns is a scary proposition.

Clinging, seemingly precariously, to the city's steep mountainsides, the chaotic, crammed masses of DIY houses have a justified reputation for violent crime orchestrated by drug gangs.

You would not imagine that a gringo (foreigner) would get a peaceful night's sleep.

Yet with a year to go until Rio hosts the 2016 Olympics, a number of entrepreneurial favela residents have turned their homes into guesthouses, and are taking bookings for next summer's event, both from Brazilians and people from overseas.

Dario Schaeffer, who runs the Babilonia guesthouse in the favela of the same name overlooking Rio's famous Copacabana beach, says: "We're almost full [for the Olympics], and we don't know if we're going to want more people than those who have already closed the deal."

Image copyright Donna Bowater Image caption Dario Schaeffer's Babilonia guesthouse has running water and electricity

While you might think that some people are seemingly prepared to risk life and limb in order to grab a bargain, since a government policy called "pacification" was introduced in 2008 there are now two very different types of favela in the city.

Under pacification, soldiers and marines supported by tanks and helicopter gunships are continuing to go into favelas to drive out the gangs, seize control, and bring law and order.

And it is in these pacified favelas where guesthouses and bed and breakfast (B&B) properties are springing up, particularly in the shanty towns near to Copacabana and Rio's other most famous beach - Ipanema.

At the Babilonia favela, which was pacified in 2009, Mr Schaeffer says: "There were shootings and drug trafficking on this road [in the past], but now everything is peaceful, and it's probably safer here than in Copacabana."

'Guesthouse fever'

Although the UK's Foreign Office warns that all of Rio's favelas remain "unpredictably dangerous", a shortage of hotel rooms in the city means that some visitors for the Olympics may have to at least consider booking accommodation in a pacified shanty town.

Image copyright Donna Bowater Image caption Dario Schaeffer says his local favela is now a safe place for tourists

Image copyright Donna Bowater Image caption Rooms at the Babilonia guesthouse are simple but clean

For while Rio is on target to meet the 40,000 hotel rooms minimum requirement as set down by the International Olympic Committee, most of those rooms will be taken up by the "Olympic Family" - officials, athletes, sponsors and media representatives.

And with the Brazilian tourist board predicting 380,000 foreign visitors for the games, there is a bit of a shortfall.

To help make sure everyone gets a bed for the night, new guesthouses and B&Bs (both called pousadas in Brazil) are springing up across Rio's non-favela areas, to rent out spare rooms for the 16 days of the Olympics, which will run from 5 to 21 August 2016.

All this has the encouragement of the authorities, with Airbnb, the US website that allows homeowners to rent out properties online, earlier this year being unveiled as an official accommodation partner for Rio 2016.

Image copyright Marta Miller Image caption Marta Miller worries that some of the newer guesthouses and B&Bs are not good enough

Marta Miller, who welcomes guests at her top floor property in the Copacabana district, says Rio now has "guesthouse fever".

She herself charges from 320 Brazilian reals ($92; £60) per room, and hopes to rent out her entire property to a TV company for use as a studio during the Olympics. This was what she did for the 2014 World Cup.

Welcoming paying guests since 1999, Ms Miller adds that she is worried that some of her newer guesthouse rivals won't offer rooms of sufficient quality, or that they will lack sufficient language skills to deal with guests' requests.

"People who are doing it just to make money... it is worrying, because they should be able to speak at least two languages, they should understand other cultures.

"We work with people's dreams, the dreams of a traveller who has never been to an Olympics in Brazil... and if you are not well prepared you can cause problems for them."

'Stupid prices'

Casa Cool Beans, in Rio's Santa Teresa district, has been rated by Tripadvisor users as the city's best B&B ever since it first opened five years ago.

Image copyright Marta Miller Image caption Marta Miller says she has had a great many booking requests for the Olympics

It has already been hired out for the duration of the Olympics by one of the national teams.

Co-owner David Laster says he is helped by the poor standards at some Rio hotels.

"It is actually because these large hotels are so poorly run, offering sub-standard services, that their clientele are writing largely poor reviews," he says.

"That offers us smaller B&Bs a greater chance of capturing visitors."

Image copyright Casa Cool Beans Image caption Casa Cools Beans is not your typical B&B

Alison McGowan, a British expat who runs Hidden Pousadas Brazil, a website which lists recommended guest houses and B&Bs, says such properties will be "absolutely crucial" during the Olympics.

She says she just hopes that such properties don't put prices up too much for the games.

Image copyright Alex Robinson Image caption Alison McGowan doesn't want guesthouses and B&Bs to raise prices too much

"The key is not to charge stupid prices," she says. "Three times the normal low season price is an absolute maximum."

Back at Mr Schaeffer's Babilonia guesthouse, his rooms start from just 160 reals. Despite the low prices, his property has electricity, running water, and a great sea view.